public void TryReadForeshoreProfile_WithForeshoreProfileToFindForeshoreProfilesContainsProfile_ReturnsTrue() { // Setup const string profileName = "someName"; const string calculationName = "name"; string filePath = Path.Combine(readerPath, "validConfiguration.xml"); var calculationGroup = new CalculationGroup(); var importer = new CalculationConfigurationImporter(filePath, calculationGroup); ForeshoreProfile expectedProfile = new TestForeshoreProfile(profileName); // Call bool valid = importer.PublicTryReadForeshoreProfile(profileName, calculationName, new[] { new TestForeshoreProfile("otherNameA"), expectedProfile, new TestForeshoreProfile("otherNameB") }, out ForeshoreProfile profile); // Assert Assert.IsTrue(valid); Assert.AreSame(expectedProfile, profile); }
public void TryReadForeshoreProfile_WithForeshoreProfileToFindForeshoreProfilesEmpty_LogsErrorReturnsFalse() { // Setup string filePath = Path.Combine(readerPath, "validConfiguration.xml"); var calculationGroup = new CalculationGroup(); var importer = new CalculationConfigurationImporter(filePath, calculationGroup); ForeshoreProfile profile = null; var valid = true; const string profileName = "someName"; const string calculationName = "name"; // Call void Validate() => valid = importer.PublicTryReadForeshoreProfile( profileName, calculationName, Enumerable.Empty<ForeshoreProfile>(), out profile); // Assert var expectedMessage = $"Het voorlandprofiel met ID '{profileName}' bestaat niet. Berekening '{calculationName}' is overgeslagen."; TestHelper.AssertLogMessageWithLevelIsGenerated(Validate, Tuple.Create(expectedMessage, LogLevelConstant.Error)); Assert.IsFalse(valid); Assert.IsNull(profile); }
public void TryReadForeshoreProfile_NoForeshoreProfileToFindForeshoreProfilesEmpty_ReturnsTrue() { // Setup string filePath = Path.Combine(readerPath, "validConfiguration.xml"); var calculationGroup = new CalculationGroup(); var importer = new CalculationConfigurationImporter(filePath, calculationGroup); // Call bool valid = importer.PublicTryReadForeshoreProfile(null, "name", Enumerable.Empty<ForeshoreProfile>(), out ForeshoreProfile profile); // Assert Assert.IsTrue(valid); Assert.IsNull(profile); }
public void TryReadForeshoreProfile_NoForeshoreProfiles_ThrowsArgumentNullException() { // Setup string filePath = Path.Combine(readerPath, "validConfiguration.xml"); var calculationGroup = new CalculationGroup(); var importer = new CalculationConfigurationImporter(filePath, calculationGroup); // Call void Call() => importer.PublicTryReadForeshoreProfile(null, "name", null, out ForeshoreProfile _); // Assert var exception = Assert.Throws<ArgumentNullException>(Call); Assert.AreEqual("foreshoreProfiles", exception.ParamName); }