public void StoreCustomer_DoesNotGetDiscount_IfLessTwoYears()
        {
            // Quickly create Bill object with a line items
            var bill             = new Bill(1, 75, "shoes");
            var storeCustomer    = new StoreCustomer(1, 1);
            var netPayableAmount = storeCustomer.getNetAmountPayable(bill);

            Assert.Equal(75, netPayableAmount);
        }
        public void StoreCustomer_Gets_FivePercentDiscount_IfOverTwoYears()
        {
            // Quickly create Bill object with a line items
            var bill             = new Bill(1, 75, "shoes");
            var storeCustomer    = new StoreCustomer(1, 3);
            var netPayableAmount = storeCustomer.getNetAmountPayable(bill);

            Assert.Equal(71.25, netPayableAmount);
        }
        public void StoreCustomer_NoPercentage_Discount_OnGroceris()
        {
            // Quickly create Bill object with a line items
            var bill = new Bill(1, 65, "Groceries");

            var storeCustomer    = new StoreCustomer(1, 8);
            var netPayableAmount = storeCustomer.getNetAmountPayable(bill);

            Assert.Equal(65, netPayableAmount);
        }
        public void StoreCustomer_Gets_FiveDollar_ForEveryHundred_DollarBill()
        {
            // Quickly create Bill object with a line items
            var bill = new Bill(1, 1600, "Laptop");

            var storeCustomer    = new StoreCustomer(1, 4);
            var netPayableAmount = storeCustomer.getNetAmountPayable(bill);

            Assert.Equal(1520, netPayableAmount);
        }
Example #5
0
        public void Method()
        {
            var bronzeCustomer = new StoreCustomer
            {
                CustomerType = 1,
            };

            double bronzeCustomerDiscount = bronzeCustomer.GetDiscount(200);

            var silverCustomer = new StoreCustomer
            {
                CustomerType = 2,
            };

            double silverCustomerDiscount = silverCustomer.GetDiscount(200);
        }
Example #6
0
        public async Task <IActionResult> StoreCustomerAsync(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "customer/management")] HttpRequest req)
        {
            var requestBody = await new StreamReader(req.Body).ReadToEndAsync();

            if (string.IsNullOrWhiteSpace(requestBody))
            {
                return(new BadRequestResult());
            }

            StoreCustomer storeCustomer = JsonConvert.DeserializeObject <StoreCustomer>(requestBody);

            CustomerInfo customerInfo = await _customerManagementService.StoreCustomerInformationAsync(storeCustomer.customerId);

            if (customerInfo is null)
            {
                return(new BadRequestResult());
            }
            return(new OkObjectResult(customerInfo));
        }
Example #7
0
        public void GetBriefInfo_SetWithFourElementsGetLastTwo_LastTwoElementsListReturned()
        {
            var thirdCustomer = new StoreCustomer
            {
                Id = 3
            };
            var fourthCustomer = new StoreCustomer
            {
                Id = 4
            };

            var context = new Mock <ICustomerContext>();

            context.Setup(c => c.Customers).ReturnsEntitySet(new[] { new StoreCustomer(), new StoreCustomer(), thirdCustomer, fourthCustomer });
            var service = new CustomerManagementService(context.Object);

            var list = service.GetBriefInfo(2, 2);

            Assert.Equal(2, list.Count);
            Assert.Contains(list, i => i.Id == 3);
            Assert.Contains(list, i => i.Id == 4);
        }
Example #8
0
        public void GetBriefInfo_SetWithFourElements_TwoElementsListReturned()
        {
            var firstCustomer = new StoreCustomer
            {
                Id = 1
            };
            var secondCustomer = new StoreCustomer
            {
                Id = 2
            };

            var context = new Mock <ICustomerContext>();

            context.Setup(c => c.Customers).ReturnsEntitySet(new[] { firstCustomer, secondCustomer, new StoreCustomer(), new StoreCustomer() });
            var service = new CustomerManagementService(context.Object);

            var list = service.GetBriefInfo(0, 2);

            Assert.Equal(2, list.Count);
            Assert.Contains(list, i => i.Id == 1);
            Assert.Contains(list, i => i.Id == 2);
        }