public void TryParse_given_postalCodeAndLocality_maps_postalCode_and_locality(string postalCodeAndLocality, string expectedPostalCode, string expectedLocality) { var parsed = PostalCodeValidator.TryParse(postalCodeAndLocality, out var postalCode, out var locality); Assert.Equal(expectedPostalCode, postalCode); Assert.Equal(expectedLocality, locality); }
public void TryParse_given_2000_Frederiksberg_returns_true() { var valid = PostalCodeValidator.TryParse("2000 Frederiksberg", out var postalCode, out var locality); Assert.True(valid); Assert.Equal("2000", postalCode); Assert.Equal("Frederiksberg", locality); }
public void TryParse_given_2720_Vanløse_returns_true() { var valid = PostalCodeValidator.TryParse("2720 Vanløse", out var postalCode, out var locality); Assert.True(valid); Assert.Equal("2720", postalCode); Assert.Equal("Vanløse", locality); }
public void TryParse_given_postal_code_and_locality_outs_locality(string postalCodeAndLocality, string expectedLocality) { var val = new PostalCodeValidator(); val.TryParse(postalCodeAndLocality, out var _, out var actualLocality); Assert.Equal(expectedLocality, actualLocality); }
public void TryParse_given_postal_code_and_locality_returns_true(string postalCodeAndLocality) { var val = new PostalCodeValidator(); var actual = val.TryParse(postalCodeAndLocality, out var _, out var _); Assert.True(actual); }
public void IsValid_given_invalid_code_returns_true(string code) { var val = new PostalCodeValidator(); var actual = val.IsValid(code); Assert.False(actual); }
public void IsValid_given_2000_returns_true() { // Arrange var postalCode = "2000"; // Act var valid = PostalCodeValidator.IsValid(postalCode); // Assert Assert.True(valid); }
public void CodeIsNull() { // Arrange var validator = new PostalCodeValidator(null, codeService); //Act validator.Validate(controller.ModelState); // Assert controller.ModelState.IsValid.Should().BeTrue(); }
public void IsValid_given_2000foo_returns_false() { // Arrange var postalCode = "2000foo"; // Act var valid = PostalCodeValidator.IsValid(postalCode); // Assert Assert.False(valid); }
public void TryParse_given_2000_Frederiksberg_returns_true_and_outs_values() { var input = "2000 Frederiksberg"; string postalCode; string locality; var actual = PostalCodeValidator.TryParse(input, out postalCode, out locality); Assert.True(actual); Assert.Equal("2000", postalCode); Assert.Equal("Frederiksberg", locality); }
public void CodeNotExistsCodeServiceReturnsEmpty() { // Arrange codeServiceMockSetup.Setup(c => c.GetPostalCodeByCode(It.IsAny <string>(), false)).Returns(string.Empty); var validator = new PostalCodeValidator("code", codeServiceMockSetup.Object); //Act validator.Validate(controller.ModelState); // Assert controller.ModelState.IsValid.Should().BeFalse(); }
public void IsValid() { var v = new PostalCodeValidator(); Assert.IsTrue(v.IsValid("12-345", null)); Assert.IsTrue(v.IsValid(null, null)); Assert.IsTrue(v.IsValid(string.Empty, null)); Assert.IsFalse(v.IsValid("12 -345", null)); Assert.IsFalse(v.IsValid("12345", null)); Assert.IsFalse(v.IsValid(" 12-345", null)); Assert.IsFalse(v.IsValid("12-345 ", null)); }
public void TryParse_given_2100_København_Ø_return_true_and_sets_fields() { // Arrange var postalCodeAndLocality = "2100 København Ø"; string postalCode; string locality; // Act var valid = PostalCodeValidator.TryParse(postalCodeAndLocality, out postalCode, out locality); // Assert Assert.True(valid); Assert.Equal("2100", postalCode); Assert.Equal("København Ø", locality); }
public void IsValid_given_2000_returns_true() { var valid = PostalCodeValidator.IsValid("2000"); Assert.True(valid); }
public void IsValid_given_postalCode_returns_expected(string postalCode, bool expected) { var valid = PostalCodeValidator.IsValid(postalCode); Assert.Equal(expected, valid); }
public void IsValid_given_100_Tórshavn_returns_true() { var valid = PostalCodeValidator.IsValid("100"); Assert.True(valid); }
public void TryParse_given_postalCodeAndLocality_returns_true(string postalCodeAndLocality) { var parsed = PostalCodeValidator.TryParse(postalCodeAndLocality, out var _, out var _); Assert.True(parsed); }
public void IsValid_given_2000x_returns_false() { var valid = PostalCodeValidator.IsValid("2000x"); Assert.False(valid); }
public void IsValid_given_2000_returns_true() { var actual = PostalCodeValidator.IsValid("2000"); Assert.True(actual); }