public void Should_return_bad_request_on_error() { var creator = new UserBuilder().BuildAndSave(); var controller = new ChatRoomController(); controller.OverrideGetUserId(() => creator.Id); var actionResult = controller.Put(new CreateChatRoom()); var badRequestResult = actionResult as BadRequestErrorMessageResult; Assert.That(badRequestResult, Is.Not.Null); Assert.That(badRequestResult.Message, Is.Not.Empty); }
public void Should_create_chat_room() { var creator = new UserBuilder().BuildAndSave(); var controller = new ChatRoomController(); controller.OverrideGetUserId(() => creator.Id); var actionResult = controller.Put(new CreateChatRoom { RoomName = "Test_Room" }); var createdResult = actionResult as CreatedAtRouteNegotiatedContentResult <ChatRoomDetail>; Assert.That(createdResult, Is.Not.Null); Assert.That(createdResult.RouteName, Is.EqualTo("DefaultApi")); Assert.That(createdResult.RouteValues["id"], Is.EqualTo("Test_Room")); }