public void GetStochastNames_SubMechanismIllustrationPointWithStochast_ReturnStochastNames() { // Setup var random = new Random(21); const string stochastNameA = "Stochast A"; const string stochastNameB = "Stochast B"; var subMechanismIllustrationPoint = new TestSubMechanismIllustrationPoint(new[] { new SubMechanismIllustrationPointStochast(stochastNameA, "-", random.NextDouble(), random.NextDouble(), random.NextDouble()), new SubMechanismIllustrationPointStochast(stochastNameB, "-", random.NextDouble(), random.NextDouble(), random.NextDouble()) }); // Call IEnumerable <string> names = subMechanismIllustrationPoint.GetStochastNames(); // Assert CollectionAssert.AreEqual(new[] { stochastNameA, stochastNameB }, names); }
public void Constructor_WindDirectionNull_ThrowsArgumentNullException() { // Setup var subMechanismIllustrationPoint = new TestSubMechanismIllustrationPoint(); // Call TestDelegate call = () => new TopLevelSubMechanismIllustrationPoint(null, "closing situation", subMechanismIllustrationPoint); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("windDirection", exception.ParamName); }
public void CreateInstance_ValidArguments_ReturnFaultTreeIllustrationPointBaseProperties() { // Setup var illustrationPoint = new TestSubMechanismIllustrationPoint(); var illustrationPointNode = new IllustrationPointNode(illustrationPoint); var context = new IllustrationPointContext <SubMechanismIllustrationPoint>(illustrationPoint, illustrationPointNode, "Wind direction", "Closing situation"); // Call IObjectProperties objectProperties = info.CreateInstance(context); // Assert Assert.IsInstanceOf <SubMechanismIllustrationPointProperties>(objectProperties); Assert.AreSame(illustrationPoint, objectProperties.Data); }
public void Create_ValidTopLevelFaultTreeIllustrationPointWithChildren_ReturnsTopLevelFaultTreeIllustrationPointEntityWithChildren() { // Setup var random = new Random(21); var windDirection = new WindDirection("WindDirection Name", random.NextDouble()); var illustrationPointNode = new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint()); illustrationPointNode.SetChildren(new[] { new IllustrationPointNode(new TestSubMechanismIllustrationPoint("Point A")), new IllustrationPointNode(new TestSubMechanismIllustrationPoint("Point B")) }); var topLevelIllustrationPoint = new TopLevelFaultTreeIllustrationPoint( windDirection, "Just a situation", illustrationPointNode); int order = random.Next(); // Call TopLevelFaultTreeIllustrationPointEntity entity = topLevelIllustrationPoint.Create(order); // Assert TestHelper.AssertAreEqualButNotSame(topLevelIllustrationPoint.ClosingSituation, entity.ClosingSituation); TestHelper.AssertAreEqualButNotSame(windDirection.Name, entity.WindDirectionName); Assert.AreEqual(windDirection.Angle, entity.WindDirectionAngle, windDirection.Angle.GetAccuracy()); Assert.AreEqual(order, entity.Order); SubMechanismIllustrationPointEntity[] subMechanismIllustrationPointEntities = entity.FaultTreeIllustrationPointEntity.SubMechanismIllustrationPointEntities.ToArray(); Assert.AreEqual(2, subMechanismIllustrationPointEntities.Length); for (var i = 0; i < 2; i++) { var expectedIllustrationPoint = new TestSubMechanismIllustrationPoint(subMechanismIllustrationPointEntities[i].Name); SubMechanismIllustrationPointEntity illustrationPointEntity = subMechanismIllustrationPointEntities[i]; Assert.AreEqual(expectedIllustrationPoint.Name, illustrationPointEntity.Name); Assert.AreEqual(expectedIllustrationPoint.Beta, illustrationPointEntity.Beta, expectedIllustrationPoint.Beta.GetAccuracy()); Assert.AreEqual(expectedIllustrationPoint.IllustrationPointResults.Count(), illustrationPointEntity.IllustrationPointResultEntities.Count); Assert.AreEqual(expectedIllustrationPoint.Stochasts.Count(), illustrationPointEntity.IllustrationPointResultEntities.Count); Assert.AreEqual(i, illustrationPointEntity.Order); } }
public void Constructor_ValidArguments_ReturnsExpectedProperties() { // Setup const string closingScenario = "closing scenario"; WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); var subMechanismIllustrationPoint = new TestSubMechanismIllustrationPoint(); // Call var windDirectionClosingScenarioIllustrationPoint = new TopLevelSubMechanismIllustrationPoint(windDirection, closingScenario, subMechanismIllustrationPoint); // Assert Assert.IsInstanceOf <TopLevelIllustrationPointBase>(windDirectionClosingScenarioIllustrationPoint); Assert.AreEqual(closingScenario, windDirectionClosingScenarioIllustrationPoint.ClosingSituation); Assert.AreSame(windDirection, windDirectionClosingScenarioIllustrationPoint.WindDirection); Assert.AreSame(subMechanismIllustrationPoint, windDirectionClosingScenarioIllustrationPoint.SubMechanismIllustrationPoint); }