public void PostRooms_Negative() { var MockRoomBusiness = new Mock <RoomManager>(); var room_List = HelperMockRooms(); var returnAckType = new Acknowledgement <Room> { code = 2, Set = null, Message = "Something went wrong.Please try again", }; MockRoomBusiness.Setup(p => p.AddingRoom(room_List)).Throws <System.Exception>(); RoomsController roomsController = new RoomsController(MockRoomBusiness.Object); var actualReturnType = roomsController.PostRooms(room_List) as OkObjectResult; Assert.ReferenceEquals(returnAckType, actualReturnType.Value); }
public void PostRoomsNegative_Cost() { var MockRoomBusiness = new Mock <RoomManager>(); var room_List = HelperMockRooms(); room_List.RoomCost = 5000; var returnAckType = new Acknowledgement <Room> { code = 2, Set = null, Message = "Invalid Room Cost" }; MockRoomBusiness.Setup(p => p.AddingRoom(room_List)).Throws(new RoomInsertingDataException(returnAckType.Message)); RoomsController roomsController = new RoomsController(MockRoomBusiness.Object); var actualRetunType = roomsController.PostRooms(room_List) as OkObjectResult; Assert.ReferenceEquals(returnAckType.Message, actualRetunType.Value); }
public void PostRooms_Positive() { var MockRoomBusiness = new Mock <RoomManager>(); var room_List = HelperMockRooms(); var returnAckType = new Acknowledgement <Room> { code = 1, Set = null, Message = "Successfully Added", }; MockRoomBusiness.Setup(p => p.AddingRoom(room_List)).Returns(returnAckType); RoomsController roomsController = new RoomsController(MockRoomBusiness.Object); //Act var actualReturnType = roomsController.PostRooms(room_List) as OkObjectResult; Assert.ReferenceEquals(returnAckType, actualReturnType.Value); }