public void GetDiscount_When_selected_expensive_products_Then_can_get_5percent_discount() { var service = new PurchaseService(_fakeUnitOfWorkFactory); var discount = service.GetDiscount(2, 200m); Assert.That(discount, Is.EqualTo(PurchaseService.EXPENSIVE_PRODUCTS_DISCOUNT)); }
public void GetDiscount_When_previous_orders_and_selected_expensive_products_Then_can_get_15percent_discount() { var service = new PurchaseService(_fakeUnitOfWorkFactory); var discount = service.GetDiscount(1, 200m); Assert.That(discount, Is.EqualTo(PurchaseService.EXPENSIVE_PRODUCTS_DISCOUNT + PurchaseService.ORDERS_HISTORY_DISCOUNT)); }
public void GetDiscount_When_account_selected_expensive_product_Then_expensive_products_discount() { // Arrange var service = new PurchaseService(_fakeUnitOfWorkFactory); // Act var discount = service.GetDiscount(131, 201.5m); // Assert Assert.That(discount, Is.EqualTo(PurchaseService.EXPENSIVE_PRODUCTS_DISCOUNT)); }
public void GetDiscount_When_account_has_enough_orders_and_selected_cheap_product_Then_orders_history_discount() { // Arrange var service = new PurchaseService(_fakeUnitOfWorkFactory); // Act var discount = service.GetDiscount(1, 10.5m); // Assert Assert.That(discount, Is.EqualTo(PurchaseService.ORDERS_HISTORY_DISCOUNT)); }
public void GetDiscount_When_account_has_not_enough_orders_and_selected_expensive_product_Then_orders_history_discount() { // Arrange var service = new PurchaseService(_fakeUnitOfWorkFactory); // Act var discount = service.GetDiscount(2, 200m); // Assert Assert.That(discount, Is.EqualTo(PurchaseService.EXPENSIVE_PRODUCTS_DISCOUNT)); }
public void GetDiscount_When_selected_expensive_products_price_greater_than_200m_Then_account_get_5_per_discount() { // Arrange var service = new PurchaseService(_fakeUnitOfWorkFactory); // Act var discount = service.GetDiscount(2, 200m); // Assert Assert.That(discount, Is.EqualTo(PurchaseService.EXPENSIVE_PRODUCTS_DISCOUNT)); }
public void GetDiscount_When_previous_orders_greater_than_500m_and_selected_products_greater_than_200m_Then_account_get_15_per_discount() { // Arrange var service = new PurchaseService(_fakeUnitOfWorkFactory); // Act var discount = service.GetDiscount(3, 200m); // Assert Assert.That(discount, Is.EqualTo(PurchaseService.EXPENSIVE_PRODUCTS_DISCOUNT + PurchaseService.ORDERS_HISTORY_DISCOUNT)); }
public void GetDiscount_When_selected_expensive_products_and_account_has_enought_orders_Then_max_discount() { //Arrange var service = new PurchaseService(_fakeUnitOfWorkFactory); //Act var discount = service.GetDiscount(1, 250.5m); //Assert Assert.That(discount, Is.EqualTo(PurchaseService.EXPENSIVE_PRODUCTS_DISCOUNT + PurchaseService.ORDERS_HISTORY_DISCOUNT)); }
public void GetDiscount_When_account_has_order_history_for_discount_and_selected_expensive_product_Then_sum_discounts() { //Arreng var service = new PurchaseService(_fakeUnitOfWorkFactory); //Act var discount = service.GetDiscount(1, 200m); //Assert Assert.That(discount, Is.EqualTo(PurchaseService.EXPENSIVE_PRODUCTS_DISCOUNT+PurchaseService.ORDERS_HISTORY_DISCOUNT)); }
public void GivenIMakeAPurchaseWhichIsWorth(int value) { var orderRepository = A.Fake<IRepository<Order>>(); A.CallTo(() => orderRepository.Query()).Returns(new[] { _order }.AsQueryable()); var accountRepository = A.Fake<IRepository<Account>>(); A.CallTo(() => accountRepository.Query()).Returns(new[] { _account }.AsQueryable()); var unitOfWork = A.Fake<IUnitOfWork>(); A.CallTo(() => unitOfWork.Repository<Account>()).Returns(accountRepository); A.CallTo(() => unitOfWork.Repository<Order>()).Returns(orderRepository); var unitOfWorkFactory = A.Fake<IUnitOfWorkFactory>(); A.CallTo(() => unitOfWorkFactory.Create()).Returns(unitOfWork); var service = new PurchaseService(unitOfWorkFactory); _result = service.GetDiscount(_account.Id, value); }
public void WhenIGetDiscount() { var accountRepository = A.Fake<IRepository<Account>>(); A.CallTo(() => accountRepository.Get(A<int>._)).Returns(_account); var orderRepository = A.Fake<IRepository<Order>>(); A.CallTo(() => orderRepository.Query()).Returns(new[] { _order}.AsQueryable()); var unitOfWork = A.Fake<IUnitOfWork>(); A.CallTo(() => unitOfWork.Repository<Account>()).Returns(accountRepository); A.CallTo(() => unitOfWork.Repository<Order>()).Returns(orderRepository); var unitOfWorkFactory = A.Fake<IUnitOfWorkFactory>(); A.CallTo(() => unitOfWorkFactory.Create()).Returns(unitOfWork); var service = new PurchaseService(unitOfWorkFactory); _discount = service.GetDiscount(_account.Id, _productPrice); }
public void GetDiscount_When_having_ordered_enough_products_Then_get_5percent_discount() { var account = new Account { Id = 1, Balance = 400m, Name = "John" }; var order1 = new Order { Id = 1, AccountId = 1}; var orderRepository = A.Fake<IRepository<Order>>(); A.CallTo(() => orderRepository.Query()).Returns(new[] { order1 }.AsQueryable()); var accountRepository = A.Fake<IRepository<Account>>(); A.CallTo(() => accountRepository.Query()).Returns(new[] { account }.AsQueryable()); var unitOfWork = A.Fake<IUnitOfWork>(); A.CallTo(() => unitOfWork.Repository<Account>()).Returns(accountRepository); A.CallTo(() => unitOfWork.Repository<Order>()).Returns(orderRepository); var unitOfWorkFactory = A.Fake<IUnitOfWorkFactory>(); A.CallTo(() => unitOfWorkFactory.Create()).Returns(unitOfWork); var service = new PurchaseService(unitOfWorkFactory); var discount = service.GetDiscount(account.Id, 200); Assert.That(discount, Is.EqualTo(PurchaseService.EXPENSIVE_PRODUCTS_DISCOUNT)); }
public void GetDiscount_When_products_value_and_previous_orders_value_enough_for_discount_Then_get_15percent_discount() { var account = new Account { Id = 1, Balance = 400m, Name = "John" }; var order1 = new Order { Id = 1, AccountId = 1, Total = 250m}; var order2 = new Order { Id = 2, AccountId = 1, Total = 250m}; var orderRepository = A.Fake<IRepository<Order>>(); A.CallTo(() => orderRepository.Query()).Returns(new[] { order1, order2 }.AsQueryable()); var accountRepository = A.Fake<IRepository<Account>>(); A.CallTo(() => accountRepository.Query()).Returns(new[] { account }.AsQueryable()); var unitOfWork = A.Fake<IUnitOfWork>(); A.CallTo(() => unitOfWork.Repository<Account>()).Returns(accountRepository); A.CallTo(() => unitOfWork.Repository<Order>()).Returns(orderRepository); var unitOfWorkFactory = A.Fake<IUnitOfWorkFactory>(); A.CallTo(() => unitOfWorkFactory.Create()).Returns(unitOfWork); var service = new PurchaseService(unitOfWorkFactory); var discount = service.GetDiscount(account.Id, 200); Assert.That( discount, Is.EqualTo(PurchaseService.EXPENSIVE_PRODUCTS_DISCOUNT + PurchaseService.ORDERS_HISTORY_DISCOUNT)); }
public void GetDiscount_When_account_Then_orders_products() { // Arrange var service = new PurchaseService(_fakeUnitOfWorkFactory); // Act var discount = service.GetDiscount(1, 10.5m); // Assert Assert.That(discount, Is.EqualTo(PurchaseService.ORDERS_HISTORY_DISCOUNT +PurchaseService.EXPENSIVE_PRODUCTS_DISCOUNT)); }