public void ReadAsPipingStochasticSoilModel_SameStochasticSoilModelEntityMultipleTimes_ReturnSameStochasticSoilModel() { // Setup var random = new Random(21); var geometry = new[] { new Point2D(random.NextDouble(), random.NextDouble()) }; var entity = new StochasticSoilModelEntity { Name = "StochasticSoilModel", StochasticSoilModelSegmentPointXml = new Point2DCollectionXmlSerializer().ToXml(geometry), PipingStochasticSoilProfileEntities = { PipingStochasticSoilProfileEntityTestFactory.CreateStochasticSoilProfileEntity() } }; var collector = new ReadConversionCollector(); // Call PipingStochasticSoilModel soilModel1 = entity.ReadAsPipingStochasticSoilModel(collector); PipingStochasticSoilModel soilModel2 = entity.ReadAsPipingStochasticSoilModel(collector); // Assert Assert.AreSame(soilModel1, soilModel2); }
public void ReadAsPipingStochasticSoilModel_WithValidEntity_ReturnsNewStochasticSoilModelWithPropertiesSet() { // Setup var random = new Random(21); var geometry = new[] { new Point2D(random.NextDouble(), random.NextDouble()), new Point2D(random.NextDouble(), random.NextDouble()) }; var entity = new StochasticSoilModelEntity { Name = "StochasticSoilModel", StochasticSoilModelSegmentPointXml = new Point2DCollectionXmlSerializer().ToXml(geometry), PipingStochasticSoilProfileEntities = { new PipingStochasticSoilProfileEntity { PipingSoilProfileEntity = new PipingSoilProfileEntity { PipingSoilLayerEntities = { new PipingSoilLayerEntity() }, Name = "A" }, Order = 1 }, new PipingStochasticSoilProfileEntity { PipingSoilProfileEntity = new PipingSoilProfileEntity { PipingSoilLayerEntities = { new PipingSoilLayerEntity() }, Name = "B" }, Order = 0 } } }; var collector = new ReadConversionCollector(); // Call PipingStochasticSoilModel model = entity.ReadAsPipingStochasticSoilModel(collector); // Assert Assert.IsNotNull(model); Assert.AreEqual(entity.Name, model.Name); CollectionAssert.AreEqual(geometry, model.Geometry); Assert.AreEqual(entity.PipingStochasticSoilProfileEntities.Count, model.StochasticSoilProfiles.Count()); CollectionAssert.AreEqual(new[] { "B", "A" }, model.StochasticSoilProfiles.Select(ssp => ssp.SoilProfile.Name)); }
public void ReadAsPipingStochasticSoilModel_CollectorNull_ThrowsArgumentNullException() { // Setup var entity = new StochasticSoilModelEntity(); // Call TestDelegate test = () => entity.ReadAsPipingStochasticSoilModel(null); // Assert string parameter = Assert.Throws <ArgumentNullException>(test).ParamName; Assert.AreEqual("collector", parameter); }
public void ReadAsPipingStochasticSoilModel_StochasticSoilModelSegmentPointXmlEmpty_ThrowsArgumentException() { // Setup var entity = new StochasticSoilModelEntity { Name = "Name", StochasticSoilModelSegmentPointXml = string.Empty }; // Call TestDelegate test = () => entity.ReadAsPipingStochasticSoilModel(new ReadConversionCollector()); // Assert string paramName = Assert.Throws <ArgumentException>(test).ParamName; Assert.AreEqual("xml", paramName); }