public void LongServiceDiscountTest_LessThan1Year()
        {
            var customer = new CustomerServiceStub(new Util()).GetAccount("1");
            var discount = _discountService.LongServiceDiscount(customer);

            Assert.AreEqual(0, discount.DiscountValue);
            Assert.AreEqual(DiscountType.None, discount.DiscountType);
        }
        public void LongServiceDiscountTest_MoreThan3Years()
        {
            var customer = new CustomerServiceStub(new Util()).GetAccount("6");
            var discount = _discountService.LongServiceDiscount(customer);

            Assert.AreEqual(1, discount.DiscountValue);
            Assert.AreEqual(DiscountType.LongServiceDiscount, discount.DiscountType);
        }
Exemple #3
0
        public static ServiceFactoryHelper Create()
        {
            var serviceStub = new CustomerServiceStub();

            var customerServiceFactory = new DemoProxyFactory <ICustomerService>(serviceStub);

            var serviceFactory = new ServiceFactory <ICustomerService>(() => customerServiceFactory.Create());

            var factory = new ServiceFactoryHelper(serviceFactory, serviceStub);

            return(factory);
        }
        public void LongServiceDiscountTest_2To3Years()
        {
            var customer = new CustomerServiceStub(new Util()).GetAccount("4");
            var discount = _discountService.LongServiceDiscount(customer);

            Assert.AreEqual(0.5, discount.DiscountValue);
            Assert.AreEqual(DiscountType.LongServiceDiscount, discount.DiscountType);

            customer = new CustomerServiceStub(new Util()).GetAccount("5");
            discount = _discountService.LongServiceDiscount(customer);
            Assert.AreEqual(0.5, discount.DiscountValue);
            Assert.AreEqual(DiscountType.LongServiceDiscount, discount.DiscountType);
        }
        public void CustomerIdentificationTest()
        {
            var customer = new CustomerServiceStub(new Util()).GetAccount("1");

            Assert.AreEqual(CustomerType.None, customer.CustomerType);

            customer = new CustomerServiceStub(new Util()).GetAccount("2");
            Assert.AreEqual(CustomerType.Bronze, customer.CustomerType);

            customer = new CustomerServiceStub(new Util()).GetAccount("3");
            Assert.AreEqual(CustomerType.Bronze, customer.CustomerType);

            customer = new CustomerServiceStub(new Util()).GetAccount("4");
            Assert.AreEqual(CustomerType.Silver, customer.CustomerType);

            customer = new CustomerServiceStub(new Util()).GetAccount("5");
            Assert.AreEqual(CustomerType.Silver, customer.CustomerType);

            customer = new CustomerServiceStub(new Util()).GetAccount("6");
            Assert.AreEqual(CustomerType.Gold, customer.CustomerType);

            customer = new CustomerServiceStub(new Util()).GetAccount("7");
            Assert.AreEqual(CustomerType.Gold, customer.CustomerType);
        }
Exemple #6
0
 public DemoProxyFactory(CustomerServiceStub stub)
 {
     this.stub = stub;
 }
Exemple #7
0
 private ServiceFactoryHelper(ServiceFactory <ICustomerService> serviceFactory, CustomerServiceStub service)
 {
     ServiceFactory = serviceFactory;
     this.service   = service;
 }