public async Task ListShoppingListItems__HappyCase() { // arrange CreateShoppingListRequest request = new CreateShoppingListRequest { Name = "Test record", UserId = TestConstants.TestUser }; CreateShoppingListResponse shoppingListResponse = await _mediator.Send(request); var createShoppingListItemResponse = await _mediator.Send(new CreateShoppingListItemRequest { Completed = false, Price = 3, ProductCategory = "Pet", ProductName = "Cat", ShoppingListId = shoppingListResponse.Id, Qty = 3, UnitPrice = 5, UserId = "mrosario" }); // Act var shoppingListItemsResponse = await _mediator.Send(new ListShoppingListItemRequest { ShoppingListId = shoppingListResponse.Id }); // Assert Assert.IsTrue(shoppingListItemsResponse.Records.Count == 1); }
public async Task CreateShoppingListWithOneItem() { // arrange CreateShoppingListRequest request = new CreateShoppingListRequest { Name = "Test record", UserId = TestConstants.TestUser }; CreateShoppingListResponse response = await _mediator.Send(request); // Act var createShoppingListItemResponse = await _mediator.Send(new CreateShoppingListItemRequest { Completed = false, Price = 3, ProductCategory = "Pet", ProductName = "Cat", ShoppingListId = response.Id, Qty = 3, UnitPrice = 5, UserId = "mrosario" }); // Assert var getRecordResponse = await _mediator.Send(new GetShoppingListItemRequest { Id = createShoppingListItemResponse.Id, UserId = "mrosario" }); Assert.IsTrue(getRecordResponse.Code == Enums.ResponseCode.Success); }
public async Task <IActionResult> Create(String Name) { CreateShoppingListRequest createShoppingListRequest = new CreateShoppingListRequest { Name = Name }; CreateShoppingListResponse response = null; try { response = await _mediator.Send(createShoppingListRequest); } catch (RequestValidationException rve) { foreach (var validationException in rve.ValidationErrors) { ModelState.AddModelError(validationException.PropertyName, validationException.ErrorMessage); } return(View(new ShoppingList { Name = Name })); } return(RedirectToAction("Index")); }
public async Task CreateShoppingList__PassNoName() { // arrange var request = new CreateShoppingListRequest { Name = "" }; // Act CreateShoppingListResponse response = await _mediator.Send(request); Assert.IsTrue(response.ValidationErrors.Count > 0); }
private async Task <string> createShoppingList() { CreateShoppingListRequest request = new CreateShoppingListRequest { Name = "Test record", UserId = TestConstants.TestUser }; CreateShoppingListResponse response = await _mediator.Send(request); string shoppingListId = response.Id; return(shoppingListId); }
public async Task CreateShoppingList__HappyCase() { // arrange CreateShoppingListRequest request = new CreateShoppingListRequest { Name = "Test record", UserId = TestConstants.TestUser }; // Act CreateShoppingListResponse response = await _mediator.Send(request); // Assert Assert.IsTrue(response != null, "response is defined"); }