public void TestNameWrong_ReturnsFalse() { string name = "a"; var result = nameValidator.IsValid(name); Assert.IsFalse(result); }
public void ValidatorCheck() { string incorrect = ""; string corect = "aa"; NameValidator nv = new NameValidator(); bool correctname = nv.IsValid(corect); bool incorrectname = nv.IsValid(incorrect); Assert.IsTrue(correctname); Assert.IsFalse(incorrectname); }
public static async Task <Customer> CreateNew( string email, string name, ICustomerUniquenessChecker customerUniquenessChecker) { if (!EmailValidator.IsValid(email)) { throw new BusinessRuleValidationException($"This emailaddress is not valid: {email}"); } if (!NameValidator.IsValid(name)) { throw new BusinessRuleValidationException($"This name is not valid: {name}"); } var customer = new Customer(email, name); var isUnique = await customerUniquenessChecker.IsUnique(customer).ConfigureAwait(false); if (!isUnique) { throw new BusinessRuleValidationException("Customer with this email already exists."); } return(customer); }
public void DeclineInvalidNames(string input) { var positionValidator = new NameValidator(); var result = positionValidator.IsValid(input); Assert.False(result); }
public void AcceptValidNames(string input) { var positionValidator = new NameValidator(); var result = positionValidator.IsValid(input); Assert.True(result); }
public void Name_And_Surname_Validators_Return_Correct_Value() { NameValidator nmV = new NameValidator(); SurnameValidator snV = new SurnameValidator(); string correct = "xx"; string incorect = ""; bool nmC = nmV.IsValid(correct); bool nmI = nmV.IsValid(incorect); bool snC = snV.IsValid(correct); bool SnI = snV.IsValid(incorect); Assert.IsFalse(nmI); Assert.IsFalse(SnI); Assert.IsTrue(nmC); Assert.IsTrue(snC); }
public void ShouldValidateName(string name, bool isValid) { var sut = new NameValidator(); var result = sut.IsValid(name); Assert.Equal(isValid, result); }
public void NameValidator_ReturnsFalse() { string[] input = new string[] { "A", "", "ř" }; NameValidator fnameValidator = new NameValidator(); foreach (var item in input) { bool result = fnameValidator.IsValid(item); Assert.IsFalse(result); } }
public void NameValidator_ReturnsTrue() { string[] input = new string[] { "Adam", "Tomáš", "Čeněk" }; NameValidator fnameValidator = new NameValidator(); foreach (var item in input) { bool result = fnameValidator.IsValid(item); Assert.IsTrue(result); } }
public void IsValid_NameIsValid_ReturnsTrue(string name) { // arrange var sut = new NameValidator(); // act var result = sut.IsValid(name); // assert Assert.True(result); }
public void IsValid_InvalidName_ReturnsFalse() { var nameValidator = new NameValidator(); var name = new List <string>() { "" }; var result = nameValidator.IsValid(name); Assert.AreEqual(false, result); }
public void IsValid_ValidName_ReturnsTrue() { var nameValidator = new NameValidator(); var name = new List <string>() { "John" }; var result = nameValidator.IsValid(name); Assert.AreEqual(true, result); }
static void Main(string[] args) { var nameValidator = new NameValidator(); var documentValidator = new DocumentValidator(); var emailValidator = new EmailValidator(); bool isValid; Console.WriteLine("Please insert required data below."); do { Console.Write("Name: "); var name = Console.ReadLine(); isValid = nameValidator.IsValid(name); if (!isValid) { Console.WriteLine("Name is invalid."); } } while (!isValid); do { Console.Write("Document: "); var document = Console.ReadLine(); isValid = documentValidator.IsValid(document); if (!isValid) { Console.WriteLine("Document is invalid."); } } while (!isValid); do { Console.Write("Email: "); var email = Console.ReadLine(); isValid = emailValidator.IsValid(email); if (!isValid) { Console.WriteLine("Email is invalid."); } } while (!isValid); Console.WriteLine("Registration completed."); }
public IActionResult UpdateItem(long id, [FromBody] TodoItem payload) { if (payload == null || !NameValidator.IsValid(payload.Name)) { return(BadRequest()); } var item = _todoRepository.FindItem(id); if (item == null) { return(NotFound()); } item.IsComplete = payload.IsComplete; item.Name = payload.Name; _todoRepository.UpdateItem(item); return(CreatedAtRoute("GetTodoItem", new { id = item.Id }, item)); }
public void Name_should_be_valid(string name) { Assert.True(NameValidator.IsValid(name), $"Expected '{name}' to pass name validation."); }
public void NameIsNotValid(string name, string reason) { Assert.False(NameValidator.IsValid(name), $"Expected name '{name}' to fail validation." + $"Reason: {reason}"); }
public void AcceptValidEmployeeName(string name) { var empNameVal = new NameValidator(); Assert.True(empNameVal.IsValid(name)); }
public void ThrowExceptionWhenNullName() { var empNameVal = new NameValidator(); Assert.Throws <ArgumentNullException>(() => empNameVal.IsValid(null)); }
public void RejectInvalidSpacesInEmployeeName(string name) { var empNameVal = new NameValidator(); Assert.False(empNameVal.IsValid(name)); }