Beispiel #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);

        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #4
0
        public void SpecifiyCrestLevelOnWeirIsFalseForGeneralStructure()
        {
            var weir = new Weir {
                WeirFormula = new GeneralStructureWeirFormula()
            };

            Assert.IsFalse(weir.SpecifyCrestLevelAndWidthOnWeir);
        }
Beispiel #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);
 }
Beispiel #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);

        }
Beispiel #7
0
        public void AllowFlowDirectionException2()
        {
            IWeir pierweir = new Weir("pier")
            {
                WeirFormula = new PierWeirFormula()
            };

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

            riverweir.AllowNegativeFlow = true;
        }
        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);
        }
        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);
        }
Beispiel #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);
        }
        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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
        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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
        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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #28
0
 public void AllowFlowDirectionException()
 {
     IWeir riverweir = new Weir("river") { WeirFormula = new RiverWeirFormula() };
     riverweir.AllowNegativeFlow = true;
 }
Beispiel #29
0
 public void AllowFlowDirectionException2()
 {
     IWeir pierweir = new Weir("pier") { WeirFormula = new PierWeirFormula() };
     pierweir.AllowNegativeFlow = true;
 }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #32
0
 public void DefaultWeir()
 {
     IWeir weir = new Weir("test");
     Assert.IsTrue(weir.Validate().IsValid);
 }
 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);
 }
Beispiel #34
0
        public void DefaultWeir()
        {
            IWeir weir = new Weir("test");

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