public void GetShiftsPerWorker_WhenShiftExists_ThenShiftsShouldBeReturned() { // Arrange var mockedRepository = new Mock <IRepository>(); var mockedPublisher = new Mock <IMessagePublisher>(); IList <Shift> list = new List <Shift>(); var shift = new Shift() { Id = 1, Day = new DateTime(2020, 11, 11), Type = ShiftType.ShiftFrom0To8, WorkerId = 1 }; list.Add(shift); shift = new Shift() { Id = 2, Day = new DateTime(2021, 12, 11), Type = ShiftType.ShiftFrom8To16, WorkerId = 1 }; list.Add(shift); mockedRepository.Setup(m => m.GetShiftsPerWorker(It.IsAny <int>())).Returns(Task.FromResult(list)); var controller = new ShiftController(mockedRepository.Object, mockedPublisher.Object); // Act var result = controller.GetShiftsPerWorkerAsync(1); var okResult = result.Result as OkObjectResult; // Assert Assert.IsNotNull(okResult); Assert.AreEqual(200, okResult.StatusCode); var resultList = (List <Shift>)okResult.Value; Assert.AreEqual(2, resultList.Count); var firstRecord = resultList[0]; Assert.AreEqual(1, firstRecord.Id); Assert.AreEqual(1, firstRecord.WorkerId); Assert.AreEqual(ShiftType.ShiftFrom0To8, firstRecord.Type); Assert.AreEqual(new DateTime(2020, 11, 11), firstRecord.Day); }