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); }
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 SpecifiyCrestLevelOnWeirIsFalseForGeneralStructure() { var weir = new Weir { WeirFormula = new GeneralStructureWeirFormula() }; Assert.IsFalse(weir.SpecifyCrestLevelAndWidthOnWeir); }
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); }
public void IsGated() { IWeir simpleweir = new Weir("simple") { }; IWeir gatedweir = new Weir("gated") { WeirFormula = new GatedWeirFormula()}; Assert.IsFalse(simpleweir.IsGated); Assert.IsTrue(gatedweir.IsGated); }
public void AllowFlowDirectionException2() { IWeir pierweir = new Weir("pier") { WeirFormula = new PierWeirFormula() }; pierweir.AllowNegativeFlow = true; }
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); }
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); }
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); }
public void IsGated() { IWeir simpleweir = new Weir("simple") { }; IWeir gatedweir = new Weir("gated") { WeirFormula = new GatedWeirFormula() }; Assert.IsFalse(simpleweir.IsGated); Assert.IsTrue(gatedweir.IsGated); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void DefaultWeir() { IWeir weir = new Weir("test"); Assert.IsTrue(weir.Validate().IsValid); }