public void Create_WithSoilProfile_ReturnsPersistableSoilCollection(MacroStabilityInwardsShearStrengthModel shearStrengthModel)
        {
            // Setup
            var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(
                new[]
            {
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[]
                {
                    MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D()
                })
            },
                Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>());

            var registry = new MacroStabilityInwardsExportRegistry();

            IEnumerable <MacroStabilityInwardsSoilLayer2D> originalLayers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers);

            originalLayers.ForEachElementDo(layer => layer.Data.ShearStrengthModel = shearStrengthModel);

            // Call
            PersistableSoilCollection soilCollection = PersistableSoilCollectionFactory.Create(soilProfile, new IdFactory(), registry);

            // Assert
            IEnumerable <PersistableSoil> actualSoils = soilCollection.Soils;

            PersistableDataModelTestHelper.AssertPersistableSoils(originalLayers, actualSoils);

            Assert.AreEqual(actualSoils.Count(), registry.Soils.Count);
            for (var i = 0; i < originalLayers.Count(); i++)
            {
                KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> registrySoil = registry.Soils.ElementAt(i);
                Assert.AreSame(originalLayers.ElementAt(i), registrySoil.Key);
                Assert.AreEqual(actualSoils.ElementAt(i).Id, registrySoil.Value);
            }
        }
        public void Create_SoilProfileNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => PersistableSoilCollectionFactory.Create(null, new IdFactory(), new MacroStabilityInwardsExportRegistry());

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("soilProfile", exception.ParamName);
        }
        public void Create_RegistryNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks       = new MockRepository();
            var soilProfile = mocks.Stub <IMacroStabilityInwardsSoilProfileUnderSurfaceLine>();

            mocks.ReplayAll();

            // Call
            void Call() => PersistableSoilCollectionFactory.Create(soilProfile, new IdFactory(), null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("registry", exception.ParamName);
            mocks.VerifyAll();
        }
        public void Create_WithValidData_ReturnsPersistableSoilLayerCollectionCollection()
        {
            // Setup
            var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(
                new[]
            {
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[]
                {
                    MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D()
                })
            },
                Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>());

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            PersistableSoilCollection         soils      = PersistableSoilCollectionFactory.Create(soilProfile, idFactory, registry);
            IEnumerable <PersistableGeometry> geometries = PersistableGeometryFactory.Create(soilProfile, idFactory, registry);

            // Call
            IEnumerable <PersistableSoilLayerCollection> soilLayerCollections = PersistableSoilLayerCollectionFactory.Create(soilProfile, idFactory, registry);

            // Assert
            PersistableDataModelTestHelper.AssertPersistableSoilLayers(soilProfile.Layers, soilLayerCollections, soils.Soils, geometries);

            var stages = new[]
            {
                MacroStabilityInwardsExportStageType.Daily,
                MacroStabilityInwardsExportStageType.Extreme
            };

            Assert.AreEqual(2, registry.SoilLayers.Count);

            for (var i = 0; i < stages.Length; i++)
            {
                Assert.AreEqual(registry.SoilLayers[stages[i]], soilLayerCollections.ElementAt(i).Id);
            }
        }
        public void Create_InvalidShearStrengthType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            var registry    = new MacroStabilityInwardsExportRegistry();
            var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(
                new[]
            {
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D()
            },
                Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>());
            const MacroStabilityInwardsShearStrengthModel shearStrengthModel = (MacroStabilityInwardsShearStrengthModel)99;

            soilProfile.Layers.First().Data.ShearStrengthModel = shearStrengthModel;

            // Call
            void Call() => PersistableSoilCollectionFactory.Create(soilProfile, new IdFactory(), registry);

            // Assert
            string message   = $"The value of argument 'shearStrengthModel' ({shearStrengthModel}) is invalid for Enum type '{nameof(MacroStabilityInwardsShearStrengthModel)}'.";
            var    exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, message);

            Assert.AreEqual("shearStrengthModel", exception.ParamName);
        }