public async Task <ActionResult <WorkingFormViewModel> > GetCurrentWorkingFormOfDesignShop(Guid designShopId) { // Check if designshop exists if (!DesignShopExists(designShopId)) { _logger.LogError($"Unknown designshop, asked for id {designShopId}"); return(NotFound()); } _logger.LogTrace($"Searching current workingform for designshop id {designShopId}."); DesignShop shop = await _context.DesignShop .Where(shop => shop.Id == designShopId) .Include(shop => shop.CurrentDesignShopWorkingForm) .ThenInclude(wf => wf.WorkingForm) .FirstOrDefaultAsync(); var currentWorkingForm = new WorkingFormViewModel(); if (shop == null) { _logger.LogTrace($"Designshop with id {designShopId} doesn't have a current workingform.'"); } else { currentWorkingForm = new WorkingFormViewModel() { Id = shop.CurrentDesignShopWorkingForm.Id, Description = shop.CurrentDesignShopWorkingForm.WorkingForm.Description }; _logger.LogTrace( $"Designshop with id {designShopId} has workingform with id {currentWorkingForm.Id} as active workingform."); } return(currentWorkingForm); }
public async Task Test3_GetCurrentWorkingFormOfValidDesignShop() { // Act var result = await _fixture._controller.GetCurrentWorkingFormOfDesignShop(_fixture._designShop.Id); // Assert // First assert: did we get an actionresult with a list var firstResult = Assert.IsType <ActionResult <WorkingFormViewModel> >(result); // Then, get the list while checking it's a list of WorkingFormViewModels WorkingFormViewModel workingForm = Assert.IsType <WorkingFormViewModel>(firstResult.Value); // Assert that the id of the fourth item is equal to the current WorkingForm Assert.Equal(_fixture._currentWorkingForm.Id, workingForm.Id); }