public async void GetReceiptById_IfExist_ExpectedNotNull() { //Arrange var mockContext = new Mock<DataContext>(); mockContext.Setup(x => x.Receipts).ReturnsDbSet(GetReceipts()); var receiptLogger = Mock.Of<ILogger<ReceiptRepository>>(); var receiptRepo = new ReceiptRepository(mockContext.Object, receiptLogger); var driverLogger = Mock.Of<ILogger<DriverRepository>>(); var driverRepo = new DriverRepository(mockContext.Object, driverLogger); var parkingspotLogger = Mock.Of<ILogger<ParkingspotRepository>>(); var parkingspotRepo = new ParkingspotRepository(mockContext.Object, parkingspotLogger); var receiptController = new ReceiptController(receiptRepo, driverRepo, parkingspotRepo); //Act var result = await receiptController.GetReceiptById(1); var contentResult = result.Result as OkObjectResult; var resultReceipt = contentResult.Value as Receipt; //Assert Assert.NotNull(resultReceipt); }