public void Task_Details_HotelRoom_Return_OkResult()
        {
            //Arrange
            var controller = new HotelRoomController(context);
            int RoomId     = 5;
            //Act
            var data = controller.Details(RoomId);

            //Assert
            Assert.IsType <ViewResult>(data);
        }
Exemplo n.º 2
0
        public void Test_Dispose()
        {
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            IHotelRoomRepository    tr = new HotelRoomRepository(c);
            HotelRoomController     tc = new HotelRoomController(tr);
            var ccMock = new Mock <ControllerContext>();

            ccMock.SetupGet(x => x.HttpContext.Session["User"]).Returns("testUser");
            ccMock.SetupGet(x => x.HttpContext.Session["Role"]).Returns(UserRole.Staff);
            tc.ControllerContext = ccMock.Object;

            tc.Dispose();
            InvalidOperationException e = new InvalidOperationException("Wrong exception");

            try
            {
                tc.Details(1);
            }
            catch (InvalidOperationException exception)
            {
                e = exception;
            }
            Assert.AreEqual(e.Message, "The operation cannot be completed because the DbContext has been disposed.");
        }