public void ReadStochasticSoilModel_ModelWithStochasticProfilesWith2DProfiles_ReturnsModelWithStochasticProfiles() { // Setup string dbFile = Path.Combine(testDataPath, "modelWithStochasticSoilProfile2D.soil"); using (var reader = new StochasticSoilModelReader(dbFile)) { reader.Validate(); // Call StochasticSoilModel model = reader.ReadStochasticSoilModel(); // Assert Assert.AreEqual("SoilModel", model.Name); Assert.AreEqual(FailureMechanismType.Stability, model.FailureMechanismType); CollectionAssert.AreEqual(new[] { 0.15, 0.175, 0.075, 0.05, 0.05, 0.15, 0.175, 0.075, 0.05, 0.05 }.OrderBy(p => p), model.StochasticSoilProfiles.Select(profile => profile.Probability)); CollectionAssert.AllItemsAreInstancesOfType(model.StochasticSoilProfiles.Select(profile => profile.SoilProfile), typeof(SoilProfile2D)); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void Constructor_PathToExistingFile_ExpectedValues() { // Setup string dbFile = Path.Combine(testDataPath, "emptySchema.soil"); // Call using (var reader = new StochasticSoilModelReader(dbFile)) { // Assert Assert.AreEqual(dbFile, reader.Path); Assert.IsInstanceOf <SqLiteDatabaseReaderBase>(reader); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void Validate_InvalidSoilProfile2d_ThrowsStochasticSoilModelException() { // Setup string dbFile = Path.Combine(soilProfile2DReaderTestDataPath, "2dProfileWithXInvalid.soil"); using (var reader = new StochasticSoilModelReader(dbFile)) { // Call TestDelegate call = () => reader.Validate(); // Assert var exception = Assert.Throws <StochasticSoilModelException>(call); Assert.IsInstanceOf <SoilProfileReadException>(exception.InnerException); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void HasNext_ValidDatabase_ReturnsTrue() { // Setup string dbFile = Path.Combine(testDataPath, "complete.soil"); using (var reader = new StochasticSoilModelReader(dbFile)) { reader.Validate(); // Call bool hasNext = reader.HasNext; // Assert Assert.IsTrue(hasNext); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void Validate_NonUniqueSoilModelNames_ThrowsCriticalFileReadException() { // Setup string dbFile = Path.Combine(constraintsReaderTestDataPath, "nonUniqueSoilModelNames.soil"); using (var reader = new StochasticSoilModelReader(dbFile)) { // Call TestDelegate test = () => reader.Validate(); // Assert var exception = Assert.Throws <CriticalFileReadException>(test); string expectedMessage = new FileReaderErrorMessageBuilder(dbFile).Build("Namen van ondergrondmodellen zijn niet uniek."); Assert.AreEqual(expectedMessage, exception.Message); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void GivenDatabaseWithStochasticSoilModelWithAndWithoutSoilProfiles_WhenReading_ReturnsAllModels() { // Setup string dbFile = Path.Combine(testDataPath, "modelsWithAndWithoutStochasticSoilProfiles.soil"); var readModels = new List <StochasticSoilModel>(); using (var reader = new StochasticSoilModelReader(dbFile)) { reader.Validate(); // Call while (reader.HasNext) { readModels.Add(reader.ReadStochasticSoilModel()); } // Assert Assert.IsFalse(reader.HasNext); CollectionAssert.AreEqual(new[] { "36005_Stability", "36005_Piping", "36006_Stability", "36006_Piping", "36007_Stability", "36007_Piping" }, readModels.Select(m => m.Name)); CollectionAssert.AreEqual(new[] { 10, 0, 6, 0, 8, 0 }, readModels.Select(m => m.StochasticSoilProfiles.Count)); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void Validate_IncorrectFormatFileOrInvalidSchema_ThrowsCriticalFileReadException(string dbName) { // Setup string dbFile = Path.Combine(testDataPath, dbName); using (var reader = new StochasticSoilModelReader(dbFile)) { // Call TestDelegate test = () => reader.Validate(); // Assert var exception = Assert.Throws <CriticalFileReadException>(test); string expectedMessage = new FileReaderErrorMessageBuilder(dbFile).Build( "Kritieke fout opgetreden bij het uitlezen van waardes uit kolommen in de database."); Assert.AreEqual(expectedMessage, exception.Message); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void ReadStochasticSoilModel_SoilModelWithoutStochasticSoilProfiles_ReturnsSoilModelWithoutLayers() { // Setup string dbFile = Path.Combine(testDataPath, "modelWithoutStochasticSoilProfiles.soil"); using (var reader = new StochasticSoilModelReader(dbFile)) { reader.Validate(); // Call StochasticSoilModel model = reader.ReadStochasticSoilModel(); // Assert Assert.AreEqual("SoilModel", model.Name); Assert.AreEqual(FailureMechanismType.Piping, model.FailureMechanismType); CollectionAssert.IsEmpty(model.StochasticSoilProfiles); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void ReadStochasticSoilModel_EmptyDatabase_ReturnsNull() { // Setup string dbFile = Path.Combine(testDataPath, "emptySchema.soil"); using (var reader = new StochasticSoilModelReader(dbFile)) { reader.Validate(); int nrOfModels = reader.StochasticSoilModelCount; // Call StochasticSoilModel model = reader.ReadStochasticSoilModel(); // Assert Assert.IsNull(model); Assert.AreEqual(0, nrOfModels); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void Validate_InvalidSchemaThatPassesVersionValidation_ThrowsCriticalFileReadException() { // Setup string dbFile = Path.Combine(constraintsReaderTestDataPath, "missingStochasticSoilModelTable.soil"); using (var reader = new StochasticSoilModelReader(dbFile)) { // Call TestDelegate test = () => reader.Validate(); // Assert var exception = Assert.Throws <CriticalFileReadException>(test); string expectedMessage = new FileReaderErrorMessageBuilder(dbFile).Build( "Kan geen ondergrondmodellen lezen. Mogelijk bestaat de 'StochasticSoilModel' tabel niet."); Assert.AreEqual(expectedMessage, exception.Message); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void ReadStochasticSoilModel_OtherFailureMechanism_ThrowsStochasticSoilModelException() { // Setup string dbFile = Path.Combine(testDataPath, "otherFailureMechanism.soil"); using (var reader = new StochasticSoilModelReader(dbFile)) { reader.Validate(); // Call TestDelegate test = () => reader.ReadStochasticSoilModel(); // Assert var exception = Assert.Throws <StochasticSoilModelException>(test); const string expectedMessage = "Het faalmechanisme 'UNKNOWN' wordt niet ondersteund."; Assert.AreEqual(expectedMessage, exception.Message); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void ReadStochasticSoilModel_InvalidSegmentPoint_ThrowsStochasticSoilModelException() { // Setup string dbFile = Path.Combine(testDataPath, "invalidSegmentPoint.soil"); using (var reader = new StochasticSoilModelReader(dbFile)) { reader.Validate(); // Call TestDelegate test = () => reader.ReadStochasticSoilModel(); // Assert var exception = Assert.Throws <StochasticSoilModelException>(test); const string expectedMessage = "Het stochastische ondergrondmodel 'StochasticSoilModelName' moet een geometrie bevatten."; Assert.AreEqual(expectedMessage, exception.Message); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void Validate_IncorrectVersion_ThrowsCriticalFileReadException() { // Setup string dbFile = Path.Combine(versionReaderTestDataPath, "incorrectVersion.soil"); using (var reader = new StochasticSoilModelReader(dbFile)) { // Call TestDelegate test = () => reader.Validate(); // Assert var exception = Assert.Throws <CriticalFileReadException>(test); const string version = "17.2.0.0"; string expectedMessage = new FileReaderErrorMessageBuilder(dbFile).Build( "De database heeft niet de vereiste versie informatie. " + $"Vereiste versie is '{version}'."); Assert.AreEqual(expectedMessage, exception.Message); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void ReadStochasticSoilModel_ModelWithStochasticProfilesWith2DProfilesLastProfileEmpty_ReturnsModelWithStochasticProfiles() { // Setup string dbFile = Path.Combine(testDataPath, "modelWith2dProfilesLastProfileEmpty.soil"); using (var reader = new StochasticSoilModelReader(dbFile)) { reader.Validate(); // Call StochasticSoilModel model = reader.ReadStochasticSoilModel(); // Assert Assert.AreEqual("43003_Stability", model.Name); Assert.AreEqual(FailureMechanismType.Stability, model.FailureMechanismType); Assert.AreEqual(2, model.StochasticSoilProfiles.Count); var emptyProfile = (SoilProfile2D)model.StochasticSoilProfiles.First().SoilProfile; var profileWithLayers = (SoilProfile2D)model.StochasticSoilProfiles.Last().SoilProfile; CollectionAssert.IsEmpty(emptyProfile.Layers); CollectionAssert.IsNotEmpty(profileWithLayers.Layers); } Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }
public void ReadStochasticSoilModel_CompleteDatabase_SixModelsWithProfiles() { // Setup string dbFile = Path.Combine(testDataPath, "complete.soil"); var readModels = new List <StochasticSoilModel>(); using (var reader = new StochasticSoilModelReader(dbFile)) { reader.Validate(); int nrOfModels = reader.StochasticSoilModelCount; while (reader.HasNext) { // Call readModels.Add(reader.ReadStochasticSoilModel()); } // Assert Assert.IsFalse(reader.HasNext); Assert.AreEqual(6, nrOfModels); } var expectedSegmentAndModelNames = new[] { "36005_Stability", "36005_Piping", "36006_Stability", "36006_Piping", "36007_Stability", "36007_Piping" }; var expectedSegmentPointCount = new[] { 1797, 1797, 144, 144, 606, 606 }; var expected1DProfileCount = new[] { 0, 10, 6, 6, 8, 8 }; var expected2DProfileCount = new[] { 10, 0, 0, 0, 0, 0 }; Assert.AreEqual(expectedSegmentAndModelNames.Length, readModels.Count); CollectionAssert.AreEqual(expectedSegmentAndModelNames, readModels.Select(m => m.Name)); CollectionAssert.AreEqual(expectedSegmentPointCount, readModels.Select(m => m.Geometry.Count)); CollectionAssert.AreEqual(expected1DProfileCount, readModels.Select(m => m.StochasticSoilProfiles.Select(ssp => ssp.SoilProfile).OfType <SoilProfile1D>().Count())); CollectionAssert.AreEqual(expected2DProfileCount, readModels.Select(m => m.StochasticSoilProfiles.Select(ssp => ssp.SoilProfile).OfType <SoilProfile2D>().Count())); Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); }