Beispiel #1
0
        public async Task Should_Not_Create_Basket_If_It_Does_Exists()
        {
            using (var context = await MockDbContext.GetDbContext())
            {
                controller = new BasketsController(context);
                var basketMock = new Basket.API.Models.Basket
                {
                    User = 3
                };
                var actionResult = await controller.PostItemAsync(basketMock) as ObjectResult;

                Assert.Equal((int)HttpStatusCode.BadRequest, (actionResult as ObjectResult).StatusCode);
            }
        }
Beispiel #2
0
        public async Task Should_Create_Basket_If_It_Does_Not_Exists()
        {
            using (var context = await MockDbContext.GetDbContext())
            {
                controller = new BasketsController(context);
                var basketMock = new Basket.API.Models.Basket
                {
                    User = 10
                };
                var actionResult = await controller.PostItemAsync(basketMock);

                var returnedObject = (actionResult as ObjectResult).Value as Basket.API.Models.Basket;
                Assert.Equal(201, (actionResult as ObjectResult).StatusCode);
                Assert.Equal(4, returnedObject.Id);
                Assert.Equal(10, returnedObject.User);
                Assert.Equal(BasketStates.PENDING, returnedObject.State);
            }
        }