Example #1
0
        public void CustomerSearchByCustomerId()
        {
            NetcoinRepoRepresentation representation = NetcoinRepositoryUtility.CreateSampleCustomersAndAccounts(5);
            INetcoinRepository        fakeProvider   = new FakeNetcoinRepository();

            fakeProvider.GetCustomers().AddRange(representation.Customers);
            CustomerService sut    = new CustomerService(fakeProvider);
            var             result = sut.GetCustomerByCustomerId("1");

            Assert.Equal(1, result.CustomerId);
        }
Example #2
0
        public void FakeRepositoryAndSampleCreationWorksForTests()
        {
            NetcoinRepoRepresentation representation = NetcoinRepositoryUtility.CreateSampleCustomersAndAccounts(5);
            INetcoinRepository        fakeProvider   = new FakeNetcoinRepository();

            fakeProvider.GetCustomers().AddRange(representation.Customers);
            fakeProvider.GetAccounts().AddRange(representation.Accounts);

            Assert.True(fakeProvider.GetCustomers().Count == 5);
            Assert.True(fakeProvider.GetAccounts().Count == 10);
        }
Example #3
0
        public void CetCustomerByCustomerId()
        {
            NetcoinRepoRepresentation representation = NetcoinRepositoryUtility.CreateSampleCustomersAndAccounts(5);
            INetcoinRepository        fakeProvider   = new FakeNetcoinRepository();

            fakeProvider.GetCustomers().AddRange(representation.Customers);
            BankSystem sut = new BankSystem(fakeProvider);

            sut.Initialize();

            var result1 = sut.GetCustomerById("1");

            Assert.Throws <NullReferenceException>(() => sut.GetCustomerById("0"));
            Assert.Equal(1, result1.CustomerId);
        }
Example #4
0
        public void DepositToAccount()
        {
            //Assemble
            NetcoinRepoRepresentation representation = NetcoinRepositoryUtility.CreateSampleCustomersAndAccounts(5, 0M);
            INetcoinRepository        fakeProvider   = new FakeNetcoinRepository();

            fakeProvider.GetAccounts().AddRange(representation.Accounts);
            AccountService sut  = new AccountService(fakeProvider);
            BankSystem     bank = new BankSystem(fakeProvider);

            bank.Initialize();

            //Act
            sut.Deposit(2, 100M);

            //Act & assert
            Assert.True(fakeProvider.GetAccounts().Single(x => x.AccountId == 2).Balance == 100);
            Assert.Throws <ArgumentOutOfRangeException>(() => sut.Withdraw(1, -1M));
            Assert.Throws <NullReferenceException>(() => sut.Withdraw(100, 1M));
        }