public void IsValid_ThrowsArgumentNullExceptionBecauseNullAccountNumberPassed() { // Assert var sut = new ModulusCheckingService(new List <IModulusCheckStrategy>(), _modulusWeightEntityAdapter); // Act Action act = () => sut.IsValid(ValidSortCode, null, new ModulusWeightEntity()); // Assert act.Should().ThrowExactly <ArgumentNullException>().WithMessage("*input*"); }
public void IsValid_ThrowsArgumentExceptionBecauseInvalidSortCodePassed(string invalidSortCode) { // Assert var sut = new ModulusCheckingService(new List <IModulusCheckStrategy>(), _modulusWeightEntityAdapter); // Act Action act = () => sut.IsValid(invalidSortCode, ValidAccountNumber, new ModulusWeightEntity()); // Assert act.Should().ThrowExactly <ArgumentException>().WithMessage("*sortCode*"); }
public void IsValid_ThrowsInvalidOperationExceptionAsNoApplicableStrategyFound() { // Arrange var sut = new ModulusCheckingService(new List <IModulusCheckStrategy> { CreateModulusCheckStrategy(true, new ModulusWeightEntity { ModCheck = "NotValid" }) }, _modulusWeightEntityAdapter); // Act Action act = () => sut.IsValid(ValidSortCode, ValidAccountNumber, new ModulusWeightEntity()); // Assert act.Should().ThrowExactly <InvalidOperationException>().WithMessage("Sequence contains no matching element"); }
public void IsValid_ThrowsInvalidOperationExceptionAsMoreThanOneApplicableStrategyFound() { // Arrange var modulusWeight = new ModulusWeightEntity { ModCheck = ValidModulusMethodName }; var sut = new ModulusCheckingService(new List <IModulusCheckStrategy> { CreateModulusCheckStrategy(true, modulusWeight), CreateModulusCheckStrategy(true, modulusWeight) }, _modulusWeightEntityAdapter); // Act Action act = () => sut.IsValid(ValidSortCode, ValidAccountNumber, modulusWeight); // Assert act.Should().ThrowExactly <InvalidOperationException>().WithMessage("Sequence contains more than one matching element"); }
public void IsValid_ExecutesSuccessfully(bool isValidResult) { // Arrange var modulusWeight = new ModulusWeightEntity { ModCheck = ValidModulusMethodName }; var modulusWeightsList = new List <int> { 1 }; _modulusWeightEntityAdapter.Execute(ValidSortCode + ValidAccountNumber, modulusWeight).Returns(modulusWeightsList); var sut = new ModulusCheckingService(new List <IModulusCheckStrategy> { CreateModulusCheckStrategy(isValidResult, modulusWeight), }, _modulusWeightEntityAdapter); // Act var result = sut.IsValid(ValidSortCode, ValidAccountNumber, modulusWeight); // Assert result.Should().Be(isValidResult); _modulusWeightEntityAdapter.Received(1).Execute(ValidSortCode + ValidAccountNumber, modulusWeight); }