public void CloneHydroNetworkWithVariousBranchFeatures() { var network = new HydroNetwork(); var from = new HydroNode(); var to = new HydroNode(); network.Nodes.Add(from); network.Nodes.Add(to); var channel = new Channel { Source = from, Target = to }; network.Branches.Add(channel); var compositeBranchStructure = new CompositeBranchStructure(); NetworkHelper.AddBranchFeatureToBranch(channel, compositeBranchStructure, 0); HydroNetworkHelper.AddStructureToComposite(compositeBranchStructure, new Weir()); HydroNetworkHelper.AddStructureToComposite(compositeBranchStructure, new Pump()); NetworkHelper.AddBranchFeatureToBranch(channel, new CrossSection(), 0); var clonedHydroNetwork = (IHydroNetwork)network.Clone(); clonedHydroNetwork.CrossSections.Should().Have.Count.EqualTo(1); clonedHydroNetwork.CompositeBranchStructures.Should().Have.Count.EqualTo(1); clonedHydroNetwork.Weirs.Should().Have.Count.EqualTo(1); clonedHydroNetwork.Pumps.Should().Have.Count.EqualTo(1); }
[Category(TestCategory.BadQuality)] // TODO: test Add or change name public void AddManyBranchesWithSimpleBranchFeature() { const int count = 10000; int weirCount = 0; Action action = delegate // TODO: what are we testing here? Test only add. { var network = new HydroNetwork(); for (int i = 0; i < count; i++) { var from = new HydroNode(); var to = new HydroNode(); network.Nodes.Add(from); network.Nodes.Add(to); var channel = new Channel { Source = from, Target = to }; var compositeBranchStructure = new CompositeBranchStructure(); NetworkHelper.AddBranchFeatureToBranch(compositeBranchStructure, channel, 0); HydroNetworkHelper.AddStructureToComposite(compositeBranchStructure, new Weir()); network.Branches.Add(channel); } foreach (IWeir weir in network.Weirs) // access all Weirs should be also fast { weirCount++; } }; TestHelper.AssertIsFasterThan(2750, string.Format("Added {0} branches with {1} weirs", count, weirCount), action); }
public void CloneHydroNetworkWithVariousBranchFeatures() { var network = new HydroNetwork(); var from = new HydroNode(); var to = new HydroNode(); network.Nodes.Add(from); network.Nodes.Add(to); var channel = new Channel { Source = from, Target = to }; network.Branches.Add(channel); var compositeBranchStructure = new CompositeBranchStructure(); NetworkHelper.AddBranchFeatureToBranch(compositeBranchStructure, channel, 0); HydroNetworkHelper.AddStructureToComposite(compositeBranchStructure, new Weir()); HydroNetworkHelper.AddStructureToComposite(compositeBranchStructure, new Pump()); var crossSectionXYZ = new CrossSectionDefinitionXYZ { Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(10, 0) }) }; HydroNetworkHelper.AddCrossSectionDefinitionToBranch(channel, crossSectionXYZ, 0); var clonedHydroNetwork = (IHydroNetwork)network.Clone(); clonedHydroNetwork.CrossSections.Should().Have.Count.EqualTo(1); clonedHydroNetwork.CompositeBranchStructures.Should().Have.Count.EqualTo(1); clonedHydroNetwork.Weirs.Should().Have.Count.EqualTo(1); clonedHydroNetwork.Pumps.Should().Have.Count.EqualTo(1); }
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 EmptyCompositeStructure() { var compositeBranchStructure = new CompositeBranchStructure(); var validationResult = compositeBranchStructure.Validate(); Assert.AreEqual(false, validationResult.IsValid); Assert.AreEqual(1, validationResult.Messages.Count()); Assert.AreEqual(compositeBranchStructure, validationResult.ValidationException.Context.Instance); }
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 EmptyCompositeStructure() { var compositeBranchStructure = new CompositeBranchStructure(); var validationResult = compositeBranchStructure.Validate(); Assert.AreEqual(false, validationResult.IsValid); Assert.AreEqual(1, validationResult.Messages.Count()); Assert.AreEqual(compositeBranchStructure, validationResult.ValidationException.Context.Instance); }
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); }
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 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 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); }
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 AddManyBranchesWithSimpleBranchFeature() { DateTime t = DateTime.Now; const int count = 10000; var network = new HydroNetwork(); for (int i = 0; i < count; i++) { var from = new HydroNode(); var to = new HydroNode(); network.Nodes.Add(from); network.Nodes.Add(to); var channel = new Channel { Source = from, Target = to }; var compositeBranchStructure = new CompositeBranchStructure(); NetworkHelper.AddBranchFeatureToBranch(channel, compositeBranchStructure, 0); HydroNetworkHelper.AddStructureToComposite(compositeBranchStructure, new Weir()); network.Branches.Add(channel); } int weirCount = 0; foreach (IWeir weir in network.Weirs) // access all Weirs should be also fast { weirCount++; } TimeSpan dt = DateTime.Now - t; log.InfoFormat("Added {0} branches with {1} weirs in {2} sec", count, weirCount, dt.TotalSeconds); // 20091029 set to 5 seconds; original test only added weirs and created an invalid hydronetwork Assert.LessOrEqual(dt.TotalSeconds, 2.7); }
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 AddManyBranchesWithSimpleBranchFeature() { DateTime t = DateTime.Now; const int count = 10000; var network = new HydroNetwork(); for (int i = 0; i < count; i++) { var from = new HydroNode(); var to = new HydroNode(); network.Nodes.Add(from); network.Nodes.Add(to); var channel = new Channel {Source = from, Target = to}; var compositeBranchStructure = new CompositeBranchStructure(); NetworkHelper.AddBranchFeatureToBranch(channel, compositeBranchStructure, 0); HydroNetworkHelper.AddStructureToComposite(compositeBranchStructure, new Weir()); network.Branches.Add(channel); } int weirCount = 0; foreach (IWeir weir in network.Weirs) // access all Weirs should be also fast { weirCount++; } TimeSpan dt = DateTime.Now - t; log.InfoFormat("Added {0} branches with {1} weirs in {2} sec", count, weirCount, dt.TotalSeconds); // 20091029 set to 5 seconds; original test only added weirs and created an invalid hydronetwork Assert.LessOrEqual(dt.TotalSeconds, 2.7); }
public void CloneHydroNetworkWithVariousBranchFeatures() { var network = new HydroNetwork(); var from = new HydroNode(); var to = new HydroNode(); network.Nodes.Add(from); network.Nodes.Add(to); var channel = new Channel {Source = from, Target = to}; network.Branches.Add(channel); var compositeBranchStructure = new CompositeBranchStructure(); NetworkHelper.AddBranchFeatureToBranch(channel, compositeBranchStructure, 0); HydroNetworkHelper.AddStructureToComposite(compositeBranchStructure, new Weir()); HydroNetworkHelper.AddStructureToComposite(compositeBranchStructure, new Pump()); NetworkHelper.AddBranchFeatureToBranch(channel, new CrossSection(), 0); var clonedHydroNetwork = (IHydroNetwork) network.Clone(); clonedHydroNetwork.CrossSections.Should().Have.Count.EqualTo(1); clonedHydroNetwork.CompositeBranchStructures.Should().Have.Count.EqualTo(1); clonedHydroNetwork.Weirs.Should().Have.Count.EqualTo(1); clonedHydroNetwork.Pumps.Should().Have.Count.EqualTo(1); }