public async void UnitTest_CurrentlyActiveActions() { mockDB(); var controller = new CharityActionsController(_dbContext); var result = await controller.Index(); var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <IEnumerable <CharityAction> >(viewResult.ViewData.Model); Assert.Equal(_dbContext.action.Where(a => a.endDateTime >= DateTime.Now).Count(), model.Count()); }
public async void UnitTest_addAction() { mockDB(); var controller = new CharityActionsController(_dbContext); int counter = _dbContext.action.Count(); var org = _dbContext.organization.FirstOrDefault(); string loggedOrg = (org.Id).ToString(); var result = await controller.Create(new CharityAction { name = "newAction", description = "description of new action", actionType = true, startDateTime = new DateTime(2020, 2, 5, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), endDateTime = new DateTime(2020, 4, 5, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second) }, loggedOrg); Assert.Equal(counter + 1, _dbContext.action.Count()); }