示例#1
0
        public void ShouldSaveAndLoadTaxStatement()
        {
            IRepository repository = new Repository();
            var password = new Password { PasswordString = "abc" };
            var email = new EmailAddress("*****@*****.**");
            var taxPayer= new User(email, password);

            taxPayer.FromMetro = true;
            taxPayer.RentPaid = 8000.00;

            AnnualSalary salary = new AnnualSalary() { Basic = 10000, Epf = 2000, Hra = 6000, Id = "salary", ProfessionalTax = 200, SpecialAllowance = 5000, TaxDedeuctedAtSource = 5000};
            TaxStatement taxStatement = new TaxStatement(salary, taxPayer);

            DonationsUnder80G donationsUnder80G = new DonationsUnder80G();
            var halfExemptDonation = new HalfExemptDonation(20000);
            donationsUnder80G.AddDonation(halfExemptDonation);
            var fullyExemptDonation = new FullyExemptDonation(10000);
            donationsUnder80G.AddDonation(fullyExemptDonation);
            taxStatement.DonationsUnder80G = donationsUnder80G;
            repository.Save(taxStatement);

            List<TaxStatement> taxStatements = repository.LoadAll<TaxStatement>();
            var loadedTaxStatement = taxStatements.FirstOrDefault(stmt => stmt.Id == taxStatement.Id);
            Assert.IsNotNull(loadedTaxStatement);
            Assert.IsNotNull(loadedTaxStatement.TaxPayer);
            Assert.IsTrue(taxStatement.GetDonationsUnder80G().Contains(halfExemptDonation));
            Assert.IsTrue(taxStatement.GetDonationsUnder80G().Contains(fullyExemptDonation));
        }
示例#2
0
        public void ShouldNotRegisterUserIfNotUnique()
        {
            var repository = new Mock<IRepository>();

            var password = new Password {PasswordString = "abc"};
            var user = new User(new EmailAddress("*****@*****.**"), password, repository.Object);

            repository.Setup(rep => rep.LoadByEmailId(user.EmailAddress)).Returns(user);

            Assert.Throws<DuplicateUserException>(user.Register);
        }
示例#3
0
        public void PasswordShouldExpireAfterTheExpiryDuration()
        {
            var password = new Password {PasswordString = "twewerer34#"};
            password.CreatedOn = DateTime.Today.AddDays(-91);
            Assert.True(password.IsExpired());

            password.CreatedOn = DateTime.Today.AddDays(-90);
            Assert.False(password.IsExpired());

            password.CreatedOn = DateTime.Today.AddDays(-56);
            Assert.False(password.IsExpired());
        }
示例#4
0
        public void NewPasswordShouldNotBeSameAsLastThreePassword()
        {
            var password = new Password {PasswordString = "twewerer34#", CreatedOn = DateTime.Today};
            password.PswdHistory = new PasswordHistory();
            Assert.True(password.IsValidPassword());

            var priorOnePassword = new Password { PasswordString = "twewerer34#" };
            priorOnePassword.CreatedOn = DateTime.Today.AddDays(-12);

            password.PswdHistory.Add(priorOnePassword);
            Assert.False(password.IsValidPassword());
        }
示例#5
0
        public void ShouldRegisterUserIfUnique()
        {
            var repository = new Mock<IRepository>();

            var password = new Password {PasswordString = "abc"};
            var user = new User(new EmailAddress("*****@*****.**"), password, repository.Object);

            repository.Setup(rep => rep.LoadByEmailId(user.EmailAddress)).Returns(() => (User) null);
            repository.Setup(rep => rep.Save(user));

            user.Register();

            repository.VerifyAll();
        }
示例#6
0
        public void ReminderMailShouldBeSentOneWeekBeforeExpiration()
        {
            var password = new Password {PasswordString = "twewerer34#"};
            password.CreatedOn = DateTime.Today.AddDays(-84);
            password.ExpiryNotificationSent = false;
            password.SendNotificationOnPasswordExpiry();
            Assert.True(password.ExpiryNotificationSent);

            password.CreatedOn = DateTime.Today.AddDays(-83);
            password.ExpiryNotificationSent = false;
            password.SendNotificationOnPasswordExpiry();
            Assert.False(password.ExpiryNotificationSent);

            password.CreatedOn = DateTime.Today.AddDays(-56);
            password.ExpiryNotificationSent = false;
            password.SendNotificationOnPasswordExpiry();
            Assert.False(password.ExpiryNotificationSent);
        }
示例#7
0
        public void ShouldSatisfyAtleastThreeValidationRules()
        {
            var password = new Password();

            var passwordToMatchRuleCountDict = new Dictionary<string, int>
                                                   {
                                                       {"12345678", 1},
                                                       {"1234567A", 2},
                                                       {"1234567a", 2},
                                                       {"1234567#", 2},
                                                       {"123456A#", 3}
                                                   };
            foreach (KeyValuePair<String, int> passwordCountPair in passwordToMatchRuleCountDict){
                password.PasswordString = passwordCountPair.Key;
                if (passwordCountPair.Value < 3){
                    Assert.IsFalse(password.IsValidPassword());
                }
                else{
                    Assert.IsTrue(password.IsValidPassword());
                }
            }
        }
示例#8
0
        public void ShouldSaveAndLoadUser()
        {
            IRepository repository = new Repository();

            var password = new Password { PasswordString = "abc" };
            var email = new EmailAddress("*****@*****.**");
            var user = new User(email, password);

            user.FromMetro = true;
            user.RentPaid = 8000.00;

            user.Repository = repository;

            user.Register();

            User actualUser = repository.LoadByEmailId(email);

            Assert.IsNotNull(actualUser);
            Assert.AreEqual(email, actualUser.EmailAddress);
            Assert.AreEqual(user.FromMetro, actualUser.FromMetro);
            Assert.AreEqual(user.RentPaid, actualUser.RentPaid);
        }
示例#9
0
文件: Password.cs 项目: bagheera/tax
 public void Add(Password priorOnePassword)
 {
     PriorPasswords.Add(priorOnePassword);
 }