public async void CreateReceipt_IfCreateReceipt_Expected201StatusCode() { //Arrange var receiptRepo = new Mock<IReceiptRepository>(); receiptRepo.Setup(x => x.Save()).Returns(Task.FromResult(true)); var driverRepo = new Mock<IDriverRepository>(); var parkingspotRepo = new Mock<IParkingspotRepository>(); var receiptController = new ReceiptController(receiptRepo.Object, driverRepo.Object, parkingspotRepo.Object); //Act var createdResult = await receiptController.CreateReceipt(new PostReceipt { DriverId = new Driver { DriverId = 1 }.DriverId, ParkingspotId = new Parkingspot { ParkingspotId = 1 }.ParkingspotId }); var contentResult = createdResult.Result as CreatedResult; //Assert Assert.Equal(201, contentResult.StatusCode); }