public void WhenCollectionIsNotEmptyThenGetAllReturnsInfoCollection() { var testContext = new TestContext(); var inMemoryCollection = new CartsCollection(); inMemoryCollection.Add(new CartsCollection.CartsCollectionEntry( new CartInfo(), testContext.CartFactory.Create())); var controller = new CartController(null, inMemoryCollection, testContext.CartFactory, testContext.PriceList, new NeutralPipeline()); var response = controller.GetAll(); Assert.NotNull(response); Assert.Equal(CartOperationStatus.Successful, response.Status); Assert.NotEmpty(response.Body); Assert.Single(response.Body); }
public void CannotDeleteCheckedOutCart() { var testContext = new TestContext(); var inMemoryCollection = new CartsCollection(); var cartEntry = new CartsCollection.CartsCollectionEntry( new CartInfo(), testContext.CartFactory.Create()); cartEntry.Info.CheckedOut = true; inMemoryCollection.Add(cartEntry); var controller = new CartController(null, inMemoryCollection, testContext.CartFactory, testContext.PriceList, new NeutralPipeline()); var response = controller.Delete(cartEntry.Id); Assert.NotNull(response); Assert.Equal(CartOperationStatus.Error, response.Status); Assert.NotNull(response.Exception); Assert.Null(response.Body); }
public void WhenCheckoutEmptyCartThenExceptionIsReturnedInMessage() { var testContext = new TestContext(); var inMemoryCollection = new CartsCollection(); var cartEntry = new CartsCollection.CartsCollectionEntry( new CartInfo(), testContext.CartFactory.Create()); inMemoryCollection.Add(cartEntry); var controller = new CartController(null, inMemoryCollection, testContext.CartFactory, testContext.PriceList, new NeutralPipeline()); var response = controller.Checkout(cartEntry.Id); Assert.NotNull(response); Assert.Equal(CartOperationStatus.Error, response.Status); Assert.NotNull(response.Exception); Assert.Null(response.Body); }
public void WhenCheckoutCartThenCartMarkedInCollectionAndNotRemoved() { var testContext = new TestContext(); var inMemoryCollection = new CartsCollection(); var cartEntry = new CartsCollection.CartsCollectionEntry( new CartInfo(), testContext.CartFactory.Create()); cartEntry.Cart.Add(testContext.CreateNewSku("A", 100)); inMemoryCollection.Add(cartEntry); var controller = new CartController(null, inMemoryCollection, testContext.CartFactory, testContext.PriceList, new NeutralPipeline()); var response = controller.Checkout(cartEntry.Id); Assert.NotNull(response); Assert.Equal(CartOperationStatus.Successful, response.Status); Assert.NotNull(response.Body); Assert.True(cartEntry.Info.CheckedOut); }
public void WhenCartExistsThenGetCartReturnsCartContent() { var testContext = new TestContext(); var inMemoryCollection = new CartsCollection(); var cartEntry = new CartsCollection.CartsCollectionEntry( new CartInfo(), testContext.CartFactory.Create()); inMemoryCollection.Add(cartEntry); var controller = new CartController(null, inMemoryCollection, testContext.CartFactory, testContext.PriceList, new NeutralPipeline()); var response = controller.GetCart(cartEntry.Id); Assert.NotNull(response); Assert.Equal(CartOperationStatus.Successful, response.Status); Assert.Null(response.Exception); Assert.NotNull(response.Body); Assert.NotNull(response.Body.Info); Assert.NotNull(response.Body.CartEntries); }
public void WhenAddingToCartThenCartIsUpdatedInCollection() { var testContext = new TestContext(); var sku = testContext.CreateNewSku("A", 100); var inMemoryCollection = new CartsCollection(); var cartEntry = new CartsCollection.CartsCollectionEntry( new CartInfo(), testContext.CartFactory.Create()); inMemoryCollection.Add(cartEntry); Assert.Empty(cartEntry.Cart); var controller = new CartController(null, inMemoryCollection, testContext.CartFactory, testContext.PriceList, new NeutralPipeline()); var response = controller.Add(cartEntry.Id, sku.Id, null); Assert.NotNull(response); Assert.Equal(CartOperationStatus.Successful, response.Status); Assert.NotNull(response.Body); Assert.NotEmpty(cartEntry.Cart); }
public void WhenAddingToCheckedOutCartThenExceptionIsReturnedInMessage() { var testContext = new TestContext(); var sku = testContext.CreateNewSku("A", 100); var inMemoryCollection = new CartsCollection(); var cartEntry = new CartsCollection.CartsCollectionEntry( new CartInfo(), testContext.CartFactory.Create()); cartEntry.Info.CheckedOut = true; inMemoryCollection.Add(cartEntry); var controller = new CartController(null, inMemoryCollection, testContext.CartFactory, testContext.PriceList, new NeutralPipeline()); var response = controller.Add(cartEntry.Id, sku.Id, null); Assert.NotNull(response); Assert.Equal(CartOperationStatus.Error, response.Status); Assert.NotNull(response.Exception); Assert.Null(response.Body); }