public void TestInitialize() { //Fields Initialization _mockRepository = new Mock <IQualityControlRepository>(); _mockInstructionRepository = new Mock <IInstructionRepository>(); _controller = new InstructionController(_mockUnitOfWork.Object, _mockFactory.Object); //Mocks SetUp _mockUnitOfWork.SetupGet(uw => uw.QualityControlRepository).Returns(_mockRepository.Object); _mockUnitOfWork.SetupGet(uw => uw.InstructionRepository).Returns(_mockInstructionRepository.Object); //Mock User Identity _userId = "1"; _controller.MockCurrentUser(_userId, "*****@*****.**"); _mockUnitOfWork.Setup(uw => uw.InstructionRepository.FindByIdAsync(It.IsAny <int>())).Returns(Task.FromResult(instruction)); _mockUnitOfWork.Setup(uw => uw.QualityControlRepository.FindByIdAsync(It.IsAny <int>())).Returns(Task.FromResult(control)); _mockUnitOfWork.Setup(uw => uw.InstructionRepository.GetWithQualityControl(It.IsAny <int>())).Returns(Task.FromResult(instruction)); }