예제 #1
0
      public void BankAccountWithNullAccountNumberProduceValidationError()
      {
         //Arrange
         var bankAccount = new BankAccount();
         bankAccount.BankAccountNumber = new BankAccountNumber("1111", "2222", null, "01");

         //act
         var validationContext = new ValidationContext(bankAccount, null, null);
         var validationResults = bankAccount.Validate(validationContext);

         //assert
         Assert.IsNotNull(validationResults);
         Assert.IsTrue(validationResults.Any());
         Assert.IsTrue(validationResults.First().MemberNames.Contains("AccountNumber"));
      }
예제 #2
0
      public void BankAccountWithEmptyCheckDigistsProduceValidationError()
      {
         //Arrange
         var bankAccount = new BankAccount();
         bankAccount.BankAccountNumber = new BankAccountNumber("1111", "2222", "3333333333", string.Empty);

         //act
         var validationContext = new ValidationContext(bankAccount, null, null);
         var validationResults = bankAccount.Validate(validationContext);

         //assert
         Assert.IsNotNull(validationResults);
         Assert.IsTrue(validationResults.Any());
         Assert.IsTrue(validationResults.First().MemberNames.Contains("CheckDigits"));
      }
        public void BankAccountWithEmptyOfficeNumberProduceValidationError()
        {
            //Arrange
            BankAccount bankAccount = new BankAccount();
            bankAccount.BankAccountNumber = new BankAccountNumber(string.Empty, "2222", "3333333333", "01");
            //act
            var validationContext = new ValidationContext(bankAccount, null, null);
            var validationResults = bankAccount.Validate(validationContext);

            //assert
            Assert.IsNotNull(validationResults);
            Assert.IsTrue(validationResults.Any());
            Assert.IsTrue(validationResults.First().MemberNames.Contains("OfficeNumber"));
        }