Esempio n. 1
0
        public void Allow()
        {
            IWeir simpleweir = new Weir("simple");

            simpleweir.AllowNegativeFlow = true;
            simpleweir.AllowPositiveFlow = true;

            Assert.IsTrue(simpleweir.AllowNegativeFlow);
            Assert.IsTrue(simpleweir.AllowPositiveFlow);

            simpleweir.AllowPositiveFlow = false;

            Assert.IsTrue(simpleweir.AllowNegativeFlow);
            Assert.IsFalse(simpleweir.AllowPositiveFlow);

            simpleweir.AllowNegativeFlow = false;

            Assert.IsFalse(simpleweir.AllowNegativeFlow);
            Assert.IsFalse(simpleweir.AllowPositiveFlow);

            simpleweir.AllowNegativeFlow = true;
            simpleweir.AllowPositiveFlow = true;

            Assert.IsTrue(simpleweir.AllowNegativeFlow);
            Assert.IsTrue(simpleweir.AllowPositiveFlow);

        }
Esempio n. 2
0
        public void Allow()
        {
            IWeir simpleweir = new Weir("simple");

            simpleweir.AllowNegativeFlow = true;
            simpleweir.AllowPositiveFlow = true;

            Assert.IsTrue(simpleweir.AllowNegativeFlow);
            Assert.IsTrue(simpleweir.AllowPositiveFlow);

            simpleweir.AllowPositiveFlow = false;

            Assert.IsTrue(simpleweir.AllowNegativeFlow);
            Assert.IsFalse(simpleweir.AllowPositiveFlow);

            simpleweir.AllowNegativeFlow = false;

            Assert.IsFalse(simpleweir.AllowNegativeFlow);
            Assert.IsFalse(simpleweir.AllowPositiveFlow);

            simpleweir.AllowNegativeFlow = true;
            simpleweir.AllowPositiveFlow = true;

            Assert.IsTrue(simpleweir.AllowNegativeFlow);
            Assert.IsTrue(simpleweir.AllowPositiveFlow);
        }
Esempio n. 3
0
        public void IsRectangle()
        {
            IWeir simpleweir = new Weir("simple") { };
            IWeir freeformweir = new Weir("freeform") { WeirFormula = new FreeFormWeirFormula() };

            Assert.IsTrue(simpleweir.IsRectangle);
            Assert.IsFalse(freeformweir.IsRectangle);
        }
Esempio n. 4
0
        public void SpecifiyCrestLevelOnWeirIsFalseForGeneralStructure()
        {
            var weir = new Weir {
                WeirFormula = new GeneralStructureWeirFormula()
            };

            Assert.IsFalse(weir.SpecifyCrestLevelAndWidthOnWeir);
        }
Esempio n. 5
0
 public void NegativeCrestWidth()
 {
     IWeir weir = new Weir("test") {CrestWidth = (-10)};
     var validationResult = weir.Validate();
     Assert.IsFalse(validationResult.IsValid);
     Assert.AreEqual(1, validationResult.Messages.Count());
     Assert.AreEqual(weir, validationResult.ValidationException.Context.Instance);
 }
Esempio n. 6
0
        public void IsGated()
        {
            IWeir simpleweir = new Weir("simple") { };
            IWeir gatedweir = new Weir("gated") { WeirFormula = new GatedWeirFormula()};

            Assert.IsFalse(simpleweir.IsGated);
            Assert.IsTrue(gatedweir.IsGated);

        }
Esempio n. 7
0
        public void AllowFlowDirectionException2()
        {
            IWeir pierweir = new Weir("pier")
            {
                WeirFormula = new PierWeirFormula()
            };

            pierweir.AllowNegativeFlow = true;
        }
Esempio n. 8
0
        public void AllowFlowDirectionException()
        {
            IWeir riverweir = new Weir("river")
            {
                WeirFormula = new RiverWeirFormula()
            };

            riverweir.AllowNegativeFlow = true;
        }
Esempio n. 9
0
        public void CompositeStructure1SimpleWeir()
        {
            var compositeBranchStructure = new CompositeBranchStructure();
            IWeir weir = new Weir("test");
            compositeBranchStructure.Structures.Add(weir);

            var validationResult = compositeBranchStructure.Validate();
            Assert.AreEqual(true, validationResult.IsValid);
        }
Esempio n. 10
0
        public void CompositeStructure1InvalidWeir()
        {
            var compositeBranchStructure = new CompositeBranchStructure();
            IWeir weir = new Weir("test") {CrestWidth = (-1)};
            compositeBranchStructure.Structures.Add(weir);

            var validationResult = compositeBranchStructure.Validate();
            Assert.AreEqual(false, validationResult.IsValid);
            Assert.AreEqual(compositeBranchStructure, validationResult.ValidationException.Context.Instance);
        }
Esempio n. 11
0
        public void CompositeStructure1SimpleWeir()
        {
            var   compositeBranchStructure = new CompositeBranchStructure();
            IWeir weir = new Weir("test");

            compositeBranchStructure.Structures.Add(weir);

            var validationResult = compositeBranchStructure.Validate();

            Assert.AreEqual(true, validationResult.IsValid);
        }
Esempio n. 12
0
        public void Composite2NeightbourWeirs()
        {
            // 2 identical and thus overlapping weirs
            var compositeBranchStructure = new CompositeBranchStructure();
            IWeir weir1 = new Weir("test") {OffsetY = 0, CrestWidth = 100};
            compositeBranchStructure.Structures.Add(weir1);
            IWeir weir2 = new Weir("test") {OffsetY = 100, CrestWidth = 100};
            compositeBranchStructure.Structures.Add(weir2);

            var validationResult = compositeBranchStructure.Validate();
            Assert.AreEqual(true, validationResult.IsValid);
        }
Esempio n. 13
0
        public void NegativeCrestWidth()
        {
            IWeir weir = new Weir("test")
            {
                CrestWidth = (-10)
            };
            var validationResult = weir.Validate();

            Assert.IsFalse(validationResult.IsValid);
            Assert.AreEqual(1, validationResult.Messages.Count());
            Assert.AreEqual(weir, validationResult.ValidationException.Context.Instance);
        }
Esempio n. 14
0
        public void IsGated()
        {
            IWeir simpleweir = new Weir("simple")
            {
            };
            IWeir gatedweir = new Weir("gated")
            {
                WeirFormula = new GatedWeirFormula()
            };

            Assert.IsFalse(simpleweir.IsGated);
            Assert.IsTrue(gatedweir.IsGated);
        }
Esempio n. 15
0
        public void IsRectangle()
        {
            IWeir simpleweir = new Weir("simple")
            {
            };
            IWeir freeformweir = new Weir("freeform")
            {
                WeirFormula = new FreeFormWeirFormula()
            };

            Assert.IsTrue(simpleweir.IsRectangle);
            Assert.IsFalse(freeformweir.IsRectangle);
        }
Esempio n. 16
0
        public void Composite2IdenticalWeirs()
        {
            // 2 identical and thus overlapping weirs
            var compositeBranchStructure = new CompositeBranchStructure();
            IWeir weir1 = new Weir("test");
            compositeBranchStructure.Structures.Add(weir1);
            IWeir weir2 = new Weir("test");
            compositeBranchStructure.Structures.Add(weir2);

            var validationResult = compositeBranchStructure.Validate();
            Assert.AreEqual(false, validationResult.IsValid);
            Assert.AreEqual(compositeBranchStructure, validationResult.ValidationException.Context.Instance);
        }
Esempio n. 17
0
        private void AddTestStructureAt(IHydroNetwork network, IChannel branch, double offset)
        {
            IWeir weir = new Weir {
                Offset = offset
            };
            CompositeBranchStructure compositeBranchStructure = new CompositeBranchStructure
            {
                Network  = network,
                Geometry = new Point(offset, 0),
                Offset   = offset
            };

            compositeBranchStructure.Structures.Add(weir);
            branch.BranchFeatures.Add(compositeBranchStructure);
        }
Esempio n. 18
0
        public void CrestLevelAndCrestWidthAreDefinedInFormulaForGeneralStructureWeir()
        {
            double bedLevelStructureCentre = 5.0;
            double widthStructureCentre    = 1.0;
            var    weir = new Weir {
                WeirFormula = new GeneralStructureWeirFormula
                {
                    BedLevelStructureCentre = bedLevelStructureCentre,
                    WidthStructureCentre    = widthStructureCentre
                }
            };

            Assert.AreEqual(bedLevelStructureCentre, weir.CrestLevel);
            Assert.AreEqual(widthStructureCentre, weir.CrestWidth);
        }
Esempio n. 19
0
        public void CompositeStructure1InvalidWeir()
        {
            var   compositeBranchStructure = new CompositeBranchStructure();
            IWeir weir = new Weir("test")
            {
                CrestWidth = (-1)
            };

            compositeBranchStructure.Structures.Add(weir);

            var validationResult = compositeBranchStructure.Validate();

            Assert.AreEqual(false, validationResult.IsValid);
            Assert.AreEqual(compositeBranchStructure, validationResult.ValidationException.Context.Instance);
        }
Esempio n. 20
0
        public void Composite2IdenticalWeirs()
        {
            // 2 identical and thus overlapping weirs
            var   compositeBranchStructure = new CompositeBranchStructure();
            IWeir weir1 = new Weir("test");

            compositeBranchStructure.Structures.Add(weir1);
            IWeir weir2 = new Weir("test");

            compositeBranchStructure.Structures.Add(weir2);

            var validationResult = compositeBranchStructure.Validate();

            // offsetY is representing property only and should not generate validation error
            Assert.IsTrue(validationResult.IsValid);
        }
Esempio n. 21
0
        public void Composite2IdenticalWeirs()
        {
            // 2 identical and thus overlapping weirs
            var   compositeBranchStructure = new CompositeBranchStructure();
            IWeir weir1 = new Weir("test");

            compositeBranchStructure.Structures.Add(weir1);
            IWeir weir2 = new Weir("test");

            compositeBranchStructure.Structures.Add(weir2);

            var validationResult = compositeBranchStructure.Validate();

            Assert.AreEqual(false, validationResult.IsValid);
            Assert.AreEqual(compositeBranchStructure, validationResult.ValidationException.Context.Instance);
        }
Esempio n. 22
0
        public void BindingTest()
        {
            var pierweir = new Weir("pier")
            {
                WeirFormula = new PierWeirFormula()
            };
            int callCount = 0;

            ((INotifyPropertyChanged)pierweir).PropertyChanged += (s, e) =>
                                                                  //pierweir.PropertyChanged += (s, e) =>
            {
                callCount++;
                Assert.AreEqual(pierweir, s);
                Assert.AreEqual("CrestShape", e.PropertyName);
            };
            pierweir.CrestShape = CrestShape.Triangular;
            Assert.AreEqual(1, callCount);
        }
Esempio n. 23
0
        public void CloneWeir()
        {
            IWeir weir = new Weir
                             {
                                 Geometry = new Point(7, 0),
                                 OffsetY = 175,
                                 CrestWidth = 75,
                                 CrestLevel = -3,
                                 Name = "Weir one",
                                 AllowNegativeFlow = true,
                             };
            IWeir clonedWeir = (IWeir) weir.Clone();

            Assert.AreEqual(clonedWeir.Name, weir.Name);
            Assert.AreEqual(clonedWeir.OffsetY, weir.OffsetY);
            Assert.AreEqual(clonedWeir.Geometry, weir.Geometry);
            Assert.AreEqual(clonedWeir.CrestWidth, weir.CrestWidth);
            Assert.AreEqual(clonedWeir.CrestLevel, weir.CrestLevel);
        }
Esempio n. 24
0
        public void CloneWeir()
        {
            IWeir weir = new Weir
            {
                Geometry          = new Point(7, 0),
                OffsetY           = 175,
                CrestWidth        = 75,
                CrestLevel        = -3,
                Name              = "Weir one",
                AllowNegativeFlow = true,
            };
            IWeir clonedWeir = (IWeir)weir.Clone();

            Assert.AreEqual(clonedWeir.Name, weir.Name);
            Assert.AreEqual(clonedWeir.OffsetY, weir.OffsetY);
            Assert.AreEqual(clonedWeir.Geometry, weir.Geometry);
            Assert.AreEqual(clonedWeir.CrestWidth, weir.CrestWidth);
            Assert.AreEqual(clonedWeir.CrestLevel, weir.CrestLevel);
        }
Esempio n. 25
0
        public void Composite2NeightbourWeirs()
        {
            // 2 identical and thus overlapping weirs
            var   compositeBranchStructure = new CompositeBranchStructure();
            IWeir weir1 = new Weir("test")
            {
                OffsetY = 0, CrestWidth = 100
            };

            compositeBranchStructure.Structures.Add(weir1);
            IWeir weir2 = new Weir("test")
            {
                OffsetY = 100, CrestWidth = 100
            };

            compositeBranchStructure.Structures.Add(weir2);

            var validationResult = compositeBranchStructure.Validate();

            Assert.AreEqual(true, validationResult.IsValid);
        }
Esempio n. 26
0
        public void PropertyChangedForFormula()
        {
            //translates the event so view etc don't have to know about formula.
            //requires a hack in weir that can be removed with new PS (hopefully)
            var formula  = new GatedWeirFormula();
            var pierweir = new Weir("pier")
            {
                WeirFormula = formula
            };

            int callCount = 0;

            ((INotifyPropertyChanged)pierweir).PropertyChanged += (s, e) =>
            {
                Assert.AreEqual(new[] { "GateOpening", "WeirFormula" }[callCount], e.PropertyName);
                Assert.AreEqual(new object[] { formula, pierweir }[callCount], s);
                callCount++;
            };

            formula.GateOpening = 22.0;
            Assert.AreEqual(2, callCount);
        }
Esempio n. 27
0
        public void CopyFromTest()
        {
            //create two different weirs
            //the target should copy all the property values form the source
            //into the target, but not the name and geometry!!
            IWeir sourceWeir = new Weir
            {
                Geometry          = new Point(7, 0),
                OffsetY           = 175,
                CrestWidth        = 75,
                CrestLevel        = -3,
                Name              = "Source Weir",
                AllowNegativeFlow = true,
                WeirFormula       = new GatedWeirFormula()
            };
            IWeir targetWeir = new Weir
            {
                Geometry          = new Point(42, 0),
                OffsetY           = 571,
                CrestWidth        = 55,
                CrestLevel        = -1,
                Name              = "Target Weir",
                AllowNegativeFlow = false,
                WeirFormula       = new FreeFormWeirFormula()
            };

            targetWeir.CopyFrom(sourceWeir);

            Assert.AreNotEqual(sourceWeir.Name, targetWeir.Name);
            Assert.AreEqual(sourceWeir.OffsetY, targetWeir.OffsetY);
            Assert.AreEqual(sourceWeir.CrestWidth, targetWeir.CrestWidth);
            Assert.AreEqual(sourceWeir.CrestLevel, targetWeir.CrestLevel);
            Assert.AreEqual(sourceWeir.AllowNegativeFlow, targetWeir.AllowNegativeFlow);
            Assert.AreEqual(sourceWeir.WeirFormula.HasFlowDirection, targetWeir.WeirFormula.HasFlowDirection);
            Assert.AreEqual(sourceWeir.IsGated, targetWeir.IsGated);
        }
Esempio n. 28
0
 public void AllowFlowDirectionException()
 {
     IWeir riverweir = new Weir("river") { WeirFormula = new RiverWeirFormula() };
     riverweir.AllowNegativeFlow = true;
 }
Esempio n. 29
0
 public void AllowFlowDirectionException2()
 {
     IWeir pierweir = new Weir("pier") { WeirFormula = new PierWeirFormula() };
     pierweir.AllowNegativeFlow = true;
 }
Esempio n. 30
0
        public void BindingTest()
        {
            var  pierweir = new Weir("pier") { WeirFormula = new PierWeirFormula() };
            int callCount = 0;

            ((INotifyPropertyChanged)pierweir).PropertyChanged += (s, e) =>
            //pierweir.PropertyChanged += (s, e) =>
                                            {
                                                callCount++;
                                                Assert.AreEqual(pierweir, s);
                                                Assert.AreEqual("CrestShape", e.PropertyName);
                                            };
            pierweir.CrestShape = CrestShape.Triangular;
            Assert.AreEqual(1,callCount);
        }
Esempio n. 31
0
        public void PropertyChangedForFormula()
        {
            //translates the event so view etc don't have to know about formula. 
            //requires a hack in weir that can be removed with new PS (hopefully)
            var formula = new GatedWeirFormula();
            var pierweir = new Weir("pier") { WeirFormula = formula };

            int callCount = 0;
            ((INotifyPropertyChanged) pierweir).PropertyChanged += (s, e) =>
                                                                       {
                                                                           Assert.AreEqual(new[]{"GateOpening","WeirFormula"}[callCount], e.PropertyName);
                                                                           Assert.AreEqual(new object[]{formula,pierweir}[callCount], s);
                                                                           callCount++;
                                                                       };

            formula.GateOpening = 22.0;
            Assert.AreEqual(2,callCount);
        }
Esempio n. 32
0
 public void DefaultWeir()
 {
     IWeir weir = new Weir("test");
     Assert.IsTrue(weir.Validate().IsValid);
 }
Esempio n. 33
0
 private void AddTestStructureAt(IHydroNetwork network, IChannel branch, double offset)
 {
     IWeir weir = new Weir { Offset = offset };
     CompositeBranchStructure compositeBranchStructure = new CompositeBranchStructure
                                                             {
                                                                 Network = network,
                                                                 Geometry = new Point(offset, 0),
                                                                 Offset = offset
                                                             };
     compositeBranchStructure.Structures.Add(weir);
     branch.BranchFeatures.Add(compositeBranchStructure);
 }
Esempio n. 34
0
        public void DefaultWeir()
        {
            IWeir weir = new Weir("test");

            Assert.IsTrue(weir.Validate().IsValid);
        }