public void GetStatsCustomerVsCustomer_Validation_Test(DateTime date, object expected) { Customer dbCustomer = new Customer { Name = "DHL", Created = new DateTime(2020, 8, 5) }; Mission dbMission = new Mission { Created = new DateTime(2020, 8, 5), Description = "Project1 for DHL", Finished = null, MissionName = "DHL Project1", Color = "#F0D87B", Start = new DateTime(2020, 8, 6), Status = 1, UserId = 1, CustomerId = 1 }; Task dbTask = new Task { UserId = 1, MissionId = 1, Status = 0, ActualHours = null, Created = new DateTime(2020, 10, 5), Description = "DHL Project 1 Task1", EstimatedHour = 8.30, Invoice = InvoiceType.Invoicable, Name = "Task1 DHL Project1", Start = new DateTime(2020, 10, 6), Finished = new DateTime(2020, 05, 6) }; List <Registry> dbRegistries = new List <Registry>(); List <Task> dbTasks = new List <Task> { new Task { TaskId = 1, } }; Mock <IRegistryRepository> regiRepoMock = new Mock <IRegistryRepository>(); regiRepoMock.Setup(r => r.GetRegistriesByDate(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <int>())).Returns(dbRegistries); Mock <ICustomerRepository> customerRepoMock = new Mock <ICustomerRepository>(); customerRepoMock.Setup(c => c.GetById(It.IsAny <int>())).Returns(dbCustomer); Mock <IMissionRepository> missionRepoMock = new Mock <IMissionRepository>(); missionRepoMock.Setup(m => m.GetById(It.IsAny <int>())).Returns(dbMission); Mock <ITaskRepository> taskRepoMock = new Mock <ITaskRepository>(); taskRepoMock.Setup(r => r.GetById(It.IsAny <int>())).Returns(dbTask); Mock <IUnitOfWork> mockUOF = new Mock <IUnitOfWork>(); mockUOF.Setup(uow => uow.TaskRepository).Returns(taskRepoMock.Object); mockUOF.Setup(uow => uow.MissionRepository).Returns(missionRepoMock.Object); mockUOF.Setup(uow => uow.RegistryRepository).Returns(regiRepoMock.Object); var controller = new StatisticsController(mockUOF.Object, httpContextAccessorMock); //Act var result = controller.GetStatsCustomerVsCustomer(date); //Assert if (expected.GetType() != StatusCodes.Status400BadRequest.GetType()) { Assert.IsType(expected.GetType(), result.Value); } else { Assert.Equal(expected, (result.Result as ObjectResult).StatusCode); } }