public void AddDetail_ValidInput_OkRequest() { var mock = new Mock <bookingrepo>(db); BookingsController obj = new BookingsController(mock.Object); Booking book = new Booking { Id = 1, FullName = "SB", RoomType = "Single", AdhaarCardNo = 253624 }; var data = obj.AddDetail(book); var res = data as ObjectResult; Assert.AreEqual(200, res.StatusCode); }
public void AddDetail_InvalidInput_BadRequest() { try { var mock = new Mock <bookingrepo>(db); BookingsController obj = new BookingsController(mock.Object); Booking book = new Booking { Id = 1, FullName = "SB", RoomType = "Single", AdhaarCardNo = 253624 }; var data = obj.AddDetail(book); var res = data as BadRequestObjectResult; Assert.AreEqual(400, res.StatusCode); } catch (Exception e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } }