Ejemplo n.º 1
0
 public void IsInvalidWhen_IsWhiteSpace()
 {
     var validator = new SignOnValidator(null);
     var model = new SignOnForm { EmailAddress = " \t " };
     var results = validator.Validate(model);
     results.IsValid.ShouldBeFalse();
     results.Errors.Count.ShouldBeInRange(1, int.MaxValue);
     var error = results.Errors.SingleOrDefault(e => e.PropertyName == PropertyName);
     error.ShouldNotBeNull();
     // ReSharper disable PossibleNullReferenceException
     error.ErrorMessage.ShouldEqual(
         SignOnValidator.FailedBecauseEmailAddressWasEmpty);
     // ReSharper restore PossibleNullReferenceException
 }
Ejemplo n.º 2
0
 public void IsValidWhen_IsValidEmailAddress_AndBelongsToMemberEstablishment()
 {
     var establishment = new Establishment
     {
         IsMember = true,
         EmailDomains = new[] { new EstablishmentEmailDomain { Value = "@domain.tld", } }
     };
     var entities = new Mock<IQueryEntities>(MockBehavior.Strict).Initialize();
     entities.Setup(m => m.Query<Establishment>()).Returns(new[] { establishment }.AsQueryable);
     var validator = new SignOnValidator(entities.Object);
     var model = new SignOnForm { EmailAddress = "*****@*****.**" };
     var results = validator.Validate(model);
     var error = results.Errors.SingleOrDefault(e => e.PropertyName == PropertyName);
     error.ShouldBeNull();
 }
Ejemplo n.º 3
0
 public void IsInvalidWhen_MatchingEstablishment_IsNotMember()
 {
     const string emailAddress = "*****@*****.**";
     var establishment = new Establishment
     {
         IsMember = false,
         EmailDomains = new[] { new EstablishmentEmailDomain { Value = "@domain.tld", } }
     };
     var entities = new Mock<IQueryEntities>(MockBehavior.Strict).Initialize();
     entities.Setup(m => m.Query<Establishment>()).Returns(new[] { establishment }.AsQueryable);
     var validator = new SignOnValidator(entities.Object);
     var model = new SignOnForm { EmailAddress = emailAddress };
     var results = validator.Validate(model);
     results.IsValid.ShouldBeFalse();
     results.Errors.Count.ShouldBeInRange(1, int.MaxValue);
     var error = results.Errors.SingleOrDefault(e => e.PropertyName == PropertyName);
     error.ShouldNotBeNull();
     // ReSharper disable PossibleNullReferenceException
     error.ErrorMessage.ShouldEqual(string.Format(
         SignOnValidator.FailedBecauseEstablishmentIsNotEligible, emailAddress));
     // ReSharper restore PossibleNullReferenceException
 }