public void Create_PersistenceRegistryNull_ThrowArgumentNullException() { // Setup HeightStructure structure = new TestHeightStructure(); // Call TestDelegate call = () => structure.Create(null, 0); // Assert string paramName = Assert.Throws <ArgumentNullException>(call).ParamName; Assert.AreEqual("registry", paramName); }
public void Create_StructureAlreadyRegistered_ReturnRegisteredEntity() { // Setup var structure = new TestHeightStructure(); var registeredEntity = new HeightStructureEntity(); var registry = new PersistenceRegistry(); registry.Register(registeredEntity, structure); // Call HeightStructureEntity entity = structure.Create(registry, 0); // Assert Assert.AreSame(registeredEntity, entity); }
public void Create_ValidStructure_ReturnEntity() { // Setup HeightStructure structure = new TestHeightStructure(); var registry = new PersistenceRegistry(); const int order = 4; // Call HeightStructureEntity entity = structure.Create(registry, order); // Assert Assert.AreEqual(structure.Name, entity.Name); Assert.AreNotSame(structure.Name, entity.Name); Assert.AreEqual(structure.Id, entity.Id); Assert.AreNotSame(structure.Id, entity.Id); Assert.AreEqual(structure.Location.X, entity.X); Assert.AreEqual(structure.Location.Y, entity.Y); Assert.AreEqual(structure.StructureNormalOrientation.Value, entity.StructureNormalOrientation); Assert.AreEqual(structure.AllowedLevelIncreaseStorage.Mean.Value, entity.AllowedLevelIncreaseStorageMean); Assert.AreEqual(structure.AllowedLevelIncreaseStorage.StandardDeviation.Value, entity.AllowedLevelIncreaseStorageStandardDeviation); Assert.AreEqual(structure.CriticalOvertoppingDischarge.Mean.Value, entity.CriticalOvertoppingDischargeMean); Assert.AreEqual(structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value, entity.CriticalOvertoppingDischargeCoefficientOfVariation); Assert.AreEqual(structure.FailureProbabilityStructureWithErosion, entity.FailureProbabilityStructureWithErosion); Assert.AreEqual(structure.FlowWidthAtBottomProtection.Mean.Value, entity.FlowWidthAtBottomProtectionMean); Assert.AreEqual(structure.FlowWidthAtBottomProtection.StandardDeviation.Value, entity.FlowWidthAtBottomProtectionStandardDeviation); Assert.AreEqual(structure.LevelCrestStructure.Mean.Value, entity.LevelCrestStructureMean); Assert.AreEqual(structure.LevelCrestStructure.StandardDeviation.Value, entity.LevelCrestStructureStandardDeviation); Assert.AreEqual(structure.StorageStructureArea.Mean.Value, entity.StorageStructureAreaMean); Assert.AreEqual(structure.StorageStructureArea.CoefficientOfVariation.Value, entity.StorageStructureAreaCoefficientOfVariation); Assert.AreEqual(structure.WidthFlowApertures.Mean.Value, entity.WidthFlowAperturesMean); Assert.AreEqual(structure.WidthFlowApertures.StandardDeviation.Value, entity.WidthFlowAperturesStandardDeviation); Assert.AreEqual(order, entity.Order); Assert.IsTrue(registry.Contains(structure)); }