Пример #1
0
        public void PlannerClass_CalculateDivePlan_SelectedValuesAndEdgeCases()
        {
            // no dives
            Assert.IsNull(_classUnderTest.CalculateDivePlan(new List <Dive>()), "Unexpected dive plans returned");

            // single dive
            List <Dive> divePlan1 = _classUnderTest.CalculateDivePlan(new List <Dive>
            {
                new Dive(10, 20)
                {
                    PressureGroupBeforeDive = 'A'
                }
            });

            Assert.AreEqual(1, divePlan1.Count, "Unexpected number of plans returned");
            divePlan1[0].AssertHasSamePropertyValues(new Dive(10, 20)
            {
                AdjustedNoDecompressionLimitBroughtForward = 0,
                AdjustedNoDecompressionLimitToCarryForward = 0,
                PressureGroupAfterDive             = 'B',
                PressureGroupAfterSurfaceInterval  = null,
                PressureGroupBeforeDive            = 'A',
                ResidualNitrogenTimeBroughtForward = 0,
                ResidualNitrogenTimeToCarryForward = 0,
                SafetyStop      = false,
                SurfaceInterval = null,
                TotalBottomTime = 20
            });

            // two dives
            List <Dive> divePlan2 = _classUnderTest.CalculateDivePlan(new List <Dive>
            {
                new Dive(20, 21),
                new Dive(30, 10)
            });

            Assert.AreEqual(2, divePlan2.Count, "Unexpected number of plans returned");
            divePlan2[0].AssertHasSamePropertyValues(new Dive(20, 21)
            {
                AdjustedNoDecompressionLimitBroughtForward = 0,
                AdjustedNoDecompressionLimitToCarryForward = 10,
                PressureGroupAfterDive             = 'H',
                PressureGroupAfterSurfaceInterval  = 'E',
                PressureGroupBeforeDive            = 'A',
                ResidualNitrogenTimeBroughtForward = 0,
                ResidualNitrogenTimeToCarryForward = 10,
                SafetyStop      = false,
                SurfaceInterval = new TimeSpan(0, 21, 0),
                TotalBottomTime = 21
            });

            divePlan2[1].AssertHasSamePropertyValues(new Dive(30, 10)
            {
                AdjustedNoDecompressionLimitBroughtForward = 10,
                AdjustedNoDecompressionLimitToCarryForward = 0,
                PressureGroupAfterDive             = 'N',
                PressureGroupAfterSurfaceInterval  = null,
                PressureGroupBeforeDive            = 'E',
                ResidualNitrogenTimeBroughtForward = 10,
                ResidualNitrogenTimeToCarryForward = 0,
                SafetyStop      = true,
                SurfaceInterval = null,
                TotalBottomTime = 20
            });

            // three dives - no surface intervals
            List <Dive> divePlan3 = _classUnderTest.CalculateDivePlan(new List <Dive>
            {
                new Dive(20, 30),
                new Dive(15, 25),
                new Dive(10, 20)
            });

            Assert.AreEqual(3, divePlan3.Count, "Unexpected number of plans returned");
            divePlan3[0].AssertHasSamePropertyValues(new Dive(20, 30)
            {
                ResidualNitrogenTimeBroughtForward         = 0,
                AdjustedNoDecompressionLimitBroughtForward = 0,
                PressureGroupBeforeDive = 'A',
                TotalBottomTime         = 30,
                SafetyStop                                 = false,
                PressureGroupAfterDive                     = 'M',
                SurfaceInterval                            = new TimeSpan(0, 0, 0),
                PressureGroupAfterSurfaceInterval          = 'M',
                ResidualNitrogenTimeToCarryForward         = 39,
                AdjustedNoDecompressionLimitToCarryForward = 33
            });

            divePlan3[1].AssertHasSamePropertyValues(new Dive(15, 25)
            {
                ResidualNitrogenTimeBroughtForward         = 39,
                AdjustedNoDecompressionLimitBroughtForward = 33,
                PressureGroupBeforeDive = 'M',
                TotalBottomTime         = 64,
                SafetyStop                                 = true,
                PressureGroupAfterDive                     = 'V',
                SurfaceInterval                            = new TimeSpan(0, 0, 0),
                PressureGroupAfterSurfaceInterval          = 'V',
                ResidualNitrogenTimeToCarryForward         = 145,
                AdjustedNoDecompressionLimitToCarryForward = 74
            });
            divePlan3[2].AssertHasSamePropertyValues(new Dive(10, 20)
            {
                ResidualNitrogenTimeBroughtForward         = 145,
                AdjustedNoDecompressionLimitBroughtForward = 74,
                PressureGroupBeforeDive = 'V',
                TotalBottomTime         = 165,
                SafetyStop                                 = true,
                PressureGroupAfterDive                     = 'X',
                SurfaceInterval                            = null,
                PressureGroupAfterSurfaceInterval          = null,
                ResidualNitrogenTimeToCarryForward         = 0,
                AdjustedNoDecompressionLimitToCarryForward = 0
            });

            // three dives - requested 1 hour between dives
            List <Dive> divePlan4 = _classUnderTest.CalculateDivePlan(new List <Dive>
            {
                new Dive(20, 30, new TimeSpan(1, 0, 0)),
                new Dive(15, 25, new TimeSpan(1, 0, 0)),
                new Dive(10, 20)
            });

            Assert.AreEqual(3, divePlan4.Count, "Unexpected number of plans returned");
            divePlan4[0].AssertHasSamePropertyValues(new Dive(20, 30, new TimeSpan(1, 0, 0))
            {
                ResidualNitrogenTimeBroughtForward         = 0,
                AdjustedNoDecompressionLimitBroughtForward = 0,
                PressureGroupBeforeDive = 'A',
                TotalBottomTime         = 30,
                SafetyStop                                 = false,
                PressureGroupAfterDive                     = 'M',
                SurfaceInterval                            = new TimeSpan(0, 56, 0),
                PressureGroupAfterSurfaceInterval          = 'D',
                ResidualNitrogenTimeToCarryForward         = 19,
                AdjustedNoDecompressionLimitToCarryForward = 53
            });

            divePlan4[1].AssertHasSamePropertyValues(new Dive(15, 25, new TimeSpan(1, 0, 0))
            {
                ResidualNitrogenTimeBroughtForward         = 19,
                AdjustedNoDecompressionLimitBroughtForward = 53,
                PressureGroupBeforeDive = 'D',
                TotalBottomTime         = 44,
                SafetyStop                                 = false,
                PressureGroupAfterDive                     = 'O',
                SurfaceInterval                            = new TimeSpan(0, 56, 0),
                PressureGroupAfterSurfaceInterval          = 'E',
                ResidualNitrogenTimeToCarryForward         = 34,
                AdjustedNoDecompressionLimitToCarryForward = 185
            });
            divePlan4[2].AssertHasSamePropertyValues(new Dive(10, 20, new TimeSpan(1, 0, 0))
            {
                ResidualNitrogenTimeBroughtForward         = 34,
                AdjustedNoDecompressionLimitBroughtForward = 185,
                PressureGroupBeforeDive = 'E',
                TotalBottomTime         = 54,
                SafetyStop                                 = false,
                PressureGroupAfterDive                     = 'J',
                SurfaceInterval                            = null,
                PressureGroupAfterSurfaceInterval          = null,
                ResidualNitrogenTimeToCarryForward         = 0,
                AdjustedNoDecompressionLimitToCarryForward = 0
            });
        }