Inheritance: EntityBase
Exemplo n.º 1
0
 private static void DisallowManualChargesForOntarioCustomers(Customer customer)
 {
     if (customer.Address != null
        && !string.IsNullOrEmpty(customer.Address.Province)
        && customer.Address.Province.Equals("Ontario"))
         throw new Exception("A manual charge cannot be run for Ontario customers.");
 }
Exemplo n.º 2
0
 public void BillForMonthlyChargeMethod_CustomerIsFromOntario_ThrowsException()
 {
     var monthlyPackage = new MonthlyPackage { Id = 1235, Name = "Top Fit", Price = 9.20M };
     var address = new Address("1234 Happy St", "Toronto", "Ontario");
     var sut = new Customer { Id = 91352, MonthlyPackage = monthlyPackage, Address = address };
     sut.BillForMonthlyCharge(DateTime.Today);
 }
        public void CustomerAddsAnInvoiceAndInvoiceIncrements()
        {
            var customer = new Customer();
            var invoice = new Invoice(new TaxesService());
            customer.AddInvoice(invoice);

            Assert.AreEqual(1, customer.Invoices.Count);
        }
Exemplo n.º 4
0
        public void MonthlyPackageProperty_Set_PackageEqualsCustomerMonthlyPackage()
        {
            var monthlyPackage = new MonthlyPackage { Id = 91351 };

            var sut = new Customer {MonthlyPackage = monthlyPackage};

            Assert.AreEqual(monthlyPackage, sut.MonthlyPackage);
        }
Exemplo n.º 5
0
 public void BillForMonthlyChargeMethod_CustomerPackageInput_GeneratesBatchWithTransaction()
 {
     const decimal price = 12.20M;
     var monthlyPackage = new MonthlyPackage { Id = 1235, Name = "Top Fit", Price = price };
     var sut = new Customer { Id = 91352, MonthlyPackage = monthlyPackage };
     var batch = sut.BillForMonthlyCharge(DateTime.Today);
     Assert.IsTrue(batch.TransactionsContainsChargeOf(price));
 }
Exemplo n.º 6
0
        public void PackageNameAndPriceProperties_Getters_WrapMonthlyPackageProperties()
        {
            var monthlyPackage = new MonthlyPackage { Id = 91351, Name = "Top Fit", Price = 35.00M };

            var sut = new Customer {MonthlyPackage = monthlyPackage};

            Assert.AreEqual(sut.PackageName, monthlyPackage.Name);
            Assert.AreEqual(sut.PackagePrice, monthlyPackage.Price);
        }
Exemplo n.º 7
0
        public void AddressProperty_Set_AddressEqualsCustomerAddress()
        {
            const string street = "1234 Happy St";
            const string city = "Winnipeg";
            const string province = "MB";

            var address = new Address(street, city, province);

            var sut = new Customer {Address = address};

            Assert.AreEqual(address, sut.Address);
        }
        public void InvoiceGetCustomerEventRetrievesCustomerInformation()
        {
            _mockInvoiceView.GetCustomer += null;
            var getCustomerEventRaiser = LastCall.IgnoreArguments().GetEventRaiser();
            _mockInvoiceView.AddInvoiceLine += null;
            LastCall.IgnoreArguments();
            _mockInvoiceView.CalculateTotals += null;
            LastCall.IgnoreArguments();
            _mockInvoiceView.SaveInvoice += null;
            LastCall.IgnoreArguments();

            const string customerCode = "JIMSMI";
            var customer = new Customer();
            Expect.Call(_mockInvoiceView.CustomerCode).Return(customerCode);
            Expect.Call(_mockCustomerRepository.FindCustomerByCode(customerCode)).Return(customer);
            _mockInvoiceView.CustomerFirstName = customer.FirstName;
            _mockInvoiceView.CustomerLastName = customer.LastName;

            _mockRepository.ReplayAll();

            var invoicePresenter = new InvoicePresenter(_mockCustomerRepository, _mockTaxesRepository, _mockInvoiceRepository, _mockInvoiceView);
            getCustomerEventRaiser.Raise(_mockInvoiceView, EventArgs.Empty);
        }
Exemplo n.º 9
0
 public void Constructor_NoInputParams_IsInstanceOfEntityBase()
 {
     var sut = new Customer();
     Assert.IsInstanceOfType(typeof(EntityBase), sut);
 }
Exemplo n.º 10
0
 public void BillForMonthlyChargeMethod_CustomerPackagePriceLessThanTenDollars_ThrowsException()
 {
     var monthlyPackage = new MonthlyPackage { Id = 1235, Name = "Top Fit", Price = 9.20M };
     var sut = new Customer { Id = 91352, MonthlyPackage = monthlyPackage };
     sut.BillForMonthlyCharge(DateTime.Today);
 }