public void UpdateRoom_Negative() { int RoomId = 30; Updateroom room = new Updateroom() { RoomId = 30, Cost = 8000, NoOfBeds = 5, City = "Bellary", Area = "Parvati Nagar", Address = "1st Link Road", Pincode = 123456, Furniture = "yes", Description = "Present in Karnataka", Status = "Valid", RoomType = "pg", Latitude = "12.4", Longitude = "33.4" }; var MockRoomBusiness = new Mock <RoomManager>(); var returnAckType = new Acknowledgement <Room> { code = 1, Set = null, Message = "something went wrong.Please Try again later", }; MockRoomBusiness.Setup(p => p.updateRoom(RoomId, room)).Throws <System.Exception>(); RoomsController roomsController = new RoomsController(MockRoomBusiness.Object); var actualReturnType = roomsController.UpdateRoomDetails(RoomId, room) as OkObjectResult; Assert.ReferenceEquals(returnAckType, actualReturnType.Value); }
public void UpdateRoom_RoomType() { var MockRoomBusiness = new Mock <RoomManager>(); var room_List = MockUpdateRoom(); room_List.RoomType = "flat and pg"; var returnAckType = new Acknowledgement <Room> { code = 2, Set = null, Message = "Invalid Room Type", }; MockRoomBusiness.Setup(p => p.updateRoom(room_List.RoomId, room_List)).Throws(new RoomUpdateDataException(returnAckType.Message)); RoomsController roomsController = new RoomsController(MockRoomBusiness.Object); var actualReturnType = roomsController.UpdateRoomDetails(room_List.RoomId, room_List) as OkObjectResult; Assert.ReferenceEquals(returnAckType, actualReturnType.Value); }