<commit_before>﻿namespace SoundMetrics.Aris.AcousticSettings

open SoundMetrics.Aris.AcousticSettings.Experimental
open Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols
open Microsoft.VisualStudio.TestTools.UnitTesting
open System

open BunnyHill

[<TestClass>]
type BunnyHillTests () =

    [<TestMethod>]
    member __.``Show constraint from float32 MIN/MAX`` () =
        let bh = {
            DownrangeWindow =
                { Start = Double.MinValue * 1.0<m>
                  End = Double.MaxValue * 1.0<m> } }
        let ctx = {
            SystemType = ArisSystemType.Aris3000
            WaterTemp = 20.0<degC>
            Salinity = Salinity.Seawater
            Depth = 10.0<m>
            AuxLens = AuxLensType.None
            AntialiasingPeriod = 0<Us>
        }
        let constrained = bunnyHillProjection.Constrain.Invoke(bh, ctx)

        Assert.AreNotEqual<BunnyHillSettings>(bh, constrained, "Must show *some* constraint!")

    [<TestMethod>]
    member __.``Change window start`` () =

        let bh = { DownrangeWindow = { Start = 3.0<m>; End = 5.0<m> } }
        let newWindowStart = bh.DownrangeWindow.Start + 0.1<m>
        let change = ChangeWindowStart newWindowStart
        let systemContext = {
            SystemType = ArisSystemType.Aris3000
            WaterTemp = 20.0<degC>
            Salinity = Salinity.Seawater
            Depth = 10.0<m>
            AuxLens = AuxLensType.None
            AntialiasingPeriod = 0<Us>
        }

        let changed = bunnyHillProjection.Change.Invoke(bh, systemContext, change)

        Assert.AreEqual(newWindowStart, changed.DownrangeWindow.Start)
        Assert.AreEqual(bh.DownrangeWindow.End, changed.DownrangeWindow.End)

    [<TestMethod>]
    member __.``Change window end`` () =

        let bh = { DownrangeWindow = { Start = 3.0<m>; End = 5.0<m> } }
        let newWindowEnd = bh.DownrangeWindow.End + 0.1<m>
        let change = ChangeWindowEnd newWindowEnd
        let systemContext = {
            SystemType = ArisSystemType.Aris3000
            WaterTemp = 20.0<degC>
            Salinity = Salinity.Seawater
            Depth = 10.0<m>
            AuxLens = AuxLensType.None
            AntialiasingPeriod = 0<Us>
        }

        let changed = bunnyHillProjection.Change.Invoke(bh, systemContext, change)

        Assert.AreEqual(bh.DownrangeWindow.Start, changed.DownrangeWindow.Start)
        Assert.AreEqual(newWindowEnd, changed.DownrangeWindow.End)<commit_msg>Minor quibbles in unit tests.<commit_after>﻿namespace SoundMetrics.Aris.AcousticSettings

open SoundMetrics.Aris.AcousticSettings.Experimental
open Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols
open Microsoft.VisualStudio.TestTools.UnitTesting
open System

open BunnyHill

[<TestClass>]
type BunnyHillTests () =

    [<TestMethod>]
    member __.``Show constraint from float32 MIN/MAX`` () =
        let bh = {
            DownrangeWindow =
                { Start = Double.MinValue * 1.0<m>
                  End = Double.MaxValue * 1.0<m> } }
        let ctx = {
            SystemType = ArisSystemType.Aris3000
            WaterTemp = 20.0<degC>
            Salinity = Salinity.Seawater
            Depth = 10.0<m>
            AuxLens = AuxLensType.None
            AntialiasingPeriod = 0<Us>
        }

        let constrained = bunnyHillProjection.Constrain.Invoke(bh, ctx)

        Assert.AreNotEqual<BunnyHillSettings>(bh, constrained, "Must show *some* constraint!")

    [<TestMethod>]
    member __.``Change window start`` () =

        let initialStart, initialEnd = 3.0<m>, 5.0<m>
        let bh = { DownrangeWindow = { Start = initialStart; End = initialEnd } }
        let newWindowStart = initialStart + 0.1<m>
        let expectedWindow = { bh.DownrangeWindow with Start = newWindowStart }
        let change = ChangeWindowStart newWindowStart
        let systemContext = {
            SystemType = ArisSystemType.Aris3000
            WaterTemp = 20.0<degC>
            Salinity = Salinity.Seawater
            Depth = 10.0<m>
            AuxLens = AuxLensType.None
            AntialiasingPeriod = 0<Us>
        }

        let changed = bunnyHillProjection.Change.Invoke(bh, systemContext, change)

        let actualWindow = changed.DownrangeWindow
        Assert.AreEqual<DownrangeWindow>(expectedWindow, actualWindow)

    [<TestMethod>]
    member __.``Change window end`` () =

        let initialStart, initialEnd = 3.0<m>, 5.0<m>
        let bh = { DownrangeWindow = { Start = initialStart; End = initialEnd } }
        let newWindowEnd = initialEnd + 0.1<m>
        let expectedWindow = { bh.DownrangeWindow with End = newWindowEnd }
        let change = ChangeWindowEnd newWindowEnd

        let systemContext = {
            SystemType = ArisSystemType.Aris3000
            WaterTemp = 20.0<degC>
            Salinity = Salinity.Seawater
            Depth = 10.0<m>
            AuxLens = AuxLensType.None
            AntialiasingPeriod = 0<Us>
        }

        let changed = bunnyHillProjection.Change.Invoke(bh, systemContext, change)

        let actualWindow = changed.DownrangeWindow
        Assert.AreEqual<DownrangeWindow>(expectedWindow, actualWindow)
{'fraction_non_alphanumeric': 0.09526581296080713, 'fraction_numerical': 0.01979045401629802, 'mean_word_length': 2.3172458172458175, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6022069', 'n_tokens_mistral': 1652, 'n_tokens_neox': 1514, 'n_words': 309}