public void GivenCreatedEntity_WhenCreateCalledOnSameObject_ThenSameEntityInstanceReturned() { // Given MacroStabilityInwardsSoilProfile2D soilProfile = CreateMacroStabilityInwardsSoilProfile2D(); var registry = new PersistenceRegistry(); MacroStabilityInwardsSoilProfileTwoDEntity firstEntity = soilProfile.Create(registry); // When MacroStabilityInwardsSoilProfileTwoDEntity secondEntity = soilProfile.Create(registry); // Then Assert.AreSame(firstEntity, secondEntity); }
public void Create_StringPropertiesDoNotShareReference() { // Setup MacroStabilityInwardsSoilProfile2D soilProfile = CreateMacroStabilityInwardsSoilProfile2D("some name"); var registry = new PersistenceRegistry(); // Call MacroStabilityInwardsSoilProfileTwoDEntity entity = soilProfile.Create(registry); // Assert TestHelper.AssertAreEqualButNotSame(soilProfile.Name, entity.Name); }
public void Create_PersistenceRegistryNull_ThrowsArgumentNullException() { // Setup MacroStabilityInwardsSoilProfile2D soilProfile = CreateMacroStabilityInwardsSoilProfile2D(); // Call TestDelegate test = () => soilProfile.Create(null); // Assert string parameterName = Assert.Throws <ArgumentNullException>(test).ParamName; Assert.AreEqual("registry", parameterName); }
public void Create_WithValidProperties_ReturnsEntityWithPropertiesSet() { // Setup var soilProfile = new MacroStabilityInwardsSoilProfile2D("some name", new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(), MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D() }, new[] { MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress() }); var registry = new PersistenceRegistry(); // Call MacroStabilityInwardsSoilProfileTwoDEntity entity = soilProfile.Create(registry); // Assert Assert.IsNotNull(entity); Assert.AreEqual(soilProfile.Layers.Count(), entity.MacroStabilityInwardsSoilLayerTwoDEntities.Count); Assert.AreEqual(soilProfile.PreconsolidationStresses.Count(), entity.MacroStabilityInwardsPreconsolidationStressEntities.Count); AssertPreconsolidationStress(soilProfile.PreconsolidationStresses.First(), entity.MacroStabilityInwardsPreconsolidationStressEntities.First()); }