Exemplo n.º 1
0
        public async Task <ActionResult> GetFullShoppingList()
        {
            // Step 1
            var response = new GetShoppingListResponse();

            // Step 2??

            // Step 3 PROFIT!
            return(Ok(response));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> GetFullShoppingList()
        {
            var response = new GetShoppingListResponse();

            response.Data = await _dataContext.ShoppingItems
                            .ProjectTo <ShoppingListItemResponse>(_mapperConfig).ToListAsync();



            return(Ok(response));
        }
        public async Task <ActionResult> GetFullShoppingList()
        {
            // Step 1
            var response = new GetShoppingListResponse();

            // Step 2??
            response.Data = await DataContext.ShoppingItems
                            .ProjectTo <ShoppingListItemResponse>(MapperConfig).ToListAsync();

            // Step 3 PROFIT!
            return(Ok(response));
        }
Exemplo n.º 4
0
        public async Task GetShoppingList__HappyCase()
        {
            // arrange
            string shoppingListId = await createShoppingList();

            // Act
            GetShoppingListResponse getShoppingListResponse = await _mediator.Send(new GetShoppingListRequest
            {
                Id = shoppingListId
            });

            // Assert
            Assert.IsTrue(getShoppingListResponse != null, "response is defined");
        }
Exemplo n.º 5
0
        public async Task GetShoppingList__RecordNotFound()
        {
            // arrange

            // Act
            GetShoppingListResponse getShoppingListResponse = await _mediator.Send(new GetShoppingListRequest
            {
                Id = "badRecordID"
            });

            // Assert
            Assert.IsTrue(getShoppingListResponse != null, "response is defined");
            Assert.IsTrue(getShoppingListResponse.Code == Enums.ResponseCode.NotFound);
        }
Exemplo n.º 6
0
        public async Task DeleteShoppingList__HappyCase()
        {
            string shoppingListId = await createShoppingList();

            DeleteShoppingListRequest deleteShoppingListRequest = new DeleteShoppingListRequest
            {
                Id = shoppingListId
            };

            // Act
            var deleteResponse = await _mediator.Send(deleteShoppingListRequest);

            // Assert
            Assert.IsTrue(deleteResponse != null, "response is defined");
            GetShoppingListResponse getShoppingListResponse = await getShoppingListById(shoppingListId);

            Assert.IsTrue(getShoppingListResponse.Code == Enums.ResponseCode.NotFound, "record should not exist");
        }
Exemplo n.º 7
0
        // Deprecated methods

        private static ShoppingListWithItems ToShoppingList(GetShoppingListResponse response) =>
        new ShoppingListWithItems(
            ShoppingList.Create(response.Id, response.OwnerId),
            response.Items.Select(i => ToShoppingListItem(i, response.Id)),
            response.Recipes.Select(i => ToShoppingListRecipeItem(i, response.Id))
            );