public void BirthdayTest()
        {
            IPerson person;
            IValidatorService validator = new ValidatorService();
            IValidationResult result = new ValidationResult();

            person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, Data.ValidEmailId, Data.BirthdayToday);
            Assert.IsTrue(person.Birthday);

            person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, Data.ValidEmailId, Data.BirthdayToday.AddDays(1));
            Assert.IsFalse(person.Birthday);

            person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, Data.ValidEmailId, Data.BirthdayToday.AddMonths(-1));
            Assert.IsFalse(person.Birthday);

            try
            {
                person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, Data.ValidEmailId);
                Assert.IsFalse(person.Birthday);
                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentNullException));
            }
        }
        public void ZodiacSignTest()
        {
            for (int month = 1; month <= 12; month++)
            {
                IPerson person;
                IValidatorService validator = new ValidatorService();
                IValidationResult result = new ValidationResult();

                person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, new DateTime(1991, month, 15));
                Assert.AreEqual(GetZodiacSign(new DateTime(1991, month, 15)), person.ZodiacSign);

                person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, new DateTime(1991, month, 27));
                Assert.AreEqual(GetZodiacSign(new DateTime(1991, month, 27)), person.ZodiacSign);

            }
        }
        public void ValidPersonTest()
        {
            IPerson person;
            IValidatorService validator = new ValidatorService();
            IValidationResult result = new ValidationResult();

            person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, Data.ValidEmailId, Data.ValidDOB);

            person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, Data.ValidEmailId);

            person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, Data.ValidDOB);
        }
        public void ScreenNameTest()
        {
            IPerson person;
            IValidatorService validator = new ValidatorService();
            IValidationResult result = new ValidationResult();

            person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, Data.ValidEmailId);
            Assert.AreEqual(Data.ValidEmailId, person.ScreenName);

            person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, Data.ValidDOB);

            StringBuilder screenName = new StringBuilder();
            screenName.Append(Data.ValidFName[0]);
            screenName.Append(Data.ValidLName.ToLowerInvariant());
            screenName.Append(Data.ValidDOB.Day.ToString());
            screenName.Append(Data.ValidDOB.Month.ToString());

            Assert.AreEqual(screenName.ToString(), person.ScreenName);
        }
        public void PersonWithNullValuesTest()
        {
            IPerson person;
            IValidatorService validator = new ValidatorService();
            IValidationResult result = new ValidationResult();
            try
            {
                person = CreateTestPerson(result, validator, String.Empty, String.Empty, String.Empty);
                Assert.Fail();
            }
            catch (ValidationException e)
            {
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.FirstName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.MissingFirstName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.LastName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.MissingLastName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.EmailId)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.MissingEmailId)));
            }

            try
            {
                person = CreateTestPerson(result, validator, String.Empty, String.Empty, String.Empty, Data.TooOld);
                Assert.Fail();
            }
            catch (ValidationException e)
            {
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.FirstName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.MissingFirstName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.LastName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.MissingLastName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.EmailId)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.MissingEmailId)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.DOB)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.DOBtooMuchinPast)));
            }
            try
            {
                person = CreateTestPerson(result, validator, String.Empty, String.Empty, Data.FutureDOB);
                Assert.Fail();
            }
            catch (ValidationException e)
            {
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.FirstName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.MissingFirstName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.LastName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.MissingLastName)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.DOB)));
                Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.FutureDOB)));
            }
        }
 public void InvalidPersonTest()
 {
     IPerson person;
     IValidatorService validator = new ValidatorService();
     IValidationResult result = new ValidationResult();
     try
     {
         person = CreateTestPerson(result, validator, Data.InvalidFName, Data.InvalidLName, Data.TooOld);
         Assert.Fail();
     }
     catch (ValidationException e)
     {
         Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.LastName)));
         Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.InvalidLastName)));
         Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.FirstName)));
         Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.InvalidFirstName)));
         Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.DOB)));
         Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.DOBtooMuchinPast)));
     }
 }
 public void ExceptionOnInvalidEmailTest()
 {
     IPerson person;
     IValidatorService validator = new ValidatorService();
     IValidationResult result = new ValidationResult();
     try
     {
         person = CreateTestPerson(result, validator, Data.ValidFName, Data.ValidLName, Data.InvalidEmailId, Data.ValidDOB);
         Assert.Fail();
     }
     catch (ValidationException e)
     {
         Assert.IsNotNull(e.Invalid.Find(invalid => invalid.FieldName.Equals(ErrorMessages.EmailId)));
         Assert.IsNotNull(e.Invalid.Find(invalid => invalid.Message.Equals(ErrorMessages.InvalidEmailId)));
     }
 }