public void ReadAsMacroStabilityInwardsStochasticSoilModel_SameStochasticSoilModelEntityMultipleTimes_ReturnSameStochasticSoilModel()
        {
            // Setup
            var    random           = new Random(21);
            string segmentPointsXml = new Point2DCollectionXmlSerializer().ToXml(new[]
            {
                new Point2D(random.NextDouble(), random.NextDouble())
            });

            var entity = new StochasticSoilModelEntity
            {
                Name = "StochasticSoilModel",
                StochasticSoilModelSegmentPointXml = segmentPointsXml,
                MacroStabilityInwardsStochasticSoilProfileEntities =
                {
                    MacroStabilityInwardsStochasticSoilProfileEntityTestFactory.CreateStochasticSoilProfileEntity()
                }
            };

            var collector = new ReadConversionCollector();

            // Call
            MacroStabilityInwardsStochasticSoilModel soilModel1 = entity.ReadAsMacroStabilityInwardsStochasticSoilModel(collector);
            MacroStabilityInwardsStochasticSoilModel soilModel2 = entity.ReadAsMacroStabilityInwardsStochasticSoilModel(collector);

            // Assert
            Assert.AreSame(soilModel1, soilModel2);
        }
        public void ReadAsMacroStabilityInwardsStochasticSoilModel_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 = "testName",
                StochasticSoilModelSegmentPointXml = new Point2DCollectionXmlSerializer().ToXml(geometry),
                MacroStabilityInwardsStochasticSoilProfileEntities =
                {
                    new MacroStabilityInwardsStochasticSoilProfileEntity
                    {
                        MacroStabilityInwardsSoilProfileOneDEntity = new MacroStabilityInwardsSoilProfileOneDEntity
                        {
                            MacroStabilityInwardsSoilLayerOneDEntities =
                            {
                                new MacroStabilityInwardsSoilLayerOneDEntity()
                            },
                            Name = "A"
                        },
                        Order = 1
                    },
                    new MacroStabilityInwardsStochasticSoilProfileEntity
                    {
                        MacroStabilityInwardsSoilProfileTwoDEntity = new MacroStabilityInwardsSoilProfileTwoDEntity
                        {
                            MacroStabilityInwardsSoilLayerTwoDEntities =
                            {
                                MacroStabilityInwardsSoilLayerTwoDEntityTestFactory.CreateMacroStabilityInwardsSoilLayerTwoDEntity()
                            },
                            Name = "B"
                        },
                        Order = 0
                    }
                }
            };
            var collector = new ReadConversionCollector();

            // Call
            MacroStabilityInwardsStochasticSoilModel model = entity.ReadAsMacroStabilityInwardsStochasticSoilModel(collector);

            // Assert
            Assert.IsNotNull(model);
            Assert.AreEqual(entity.Name, model.Name);
            CollectionAssert.AreEqual(geometry, model.Geometry);

            Assert.AreEqual(entity.MacroStabilityInwardsStochasticSoilProfileEntities.Count,
                            model.StochasticSoilProfiles.Count());
            CollectionAssert.AreEqual(new[]
            {
                "B",
                "A"
            }, model.StochasticSoilProfiles.Select(ssp => ssp.SoilProfile.Name));
        }
        public void ReadAsMacroStabilityInwardsStochasticSoilModel_CollectorNull_ThrowsArgumentNullException()
        {
            // Setup
            var entity = new StochasticSoilModelEntity();

            // Call
            TestDelegate test = () => entity.ReadAsMacroStabilityInwardsStochasticSoilModel(null);

            // Assert
            string parameter = Assert.Throws <ArgumentNullException>(test).ParamName;

            Assert.AreEqual("collector", parameter);
        }
        public void ReadAsMacroStabilityInwardsStochasticSoilModel_StochasticSoilModelSegmentPointXmlEmpty_ThrowsArgumentException()
        {
            // Setup
            var entity = new StochasticSoilModelEntity
            {
                Name = "Name",
                StochasticSoilModelSegmentPointXml = string.Empty
            };

            // Call
            TestDelegate test = () => entity.ReadAsMacroStabilityInwardsStochasticSoilModel(new ReadConversionCollector());

            // Assert
            string paramName = Assert.Throws <ArgumentException>(test).ParamName;

            Assert.AreEqual("xml", paramName);
        }