public async void Task_DeleteHotelRoom_Return_NotFoundResult()
        {
            var controller  = new HotelRoomController(context);
            var HotelRoomId = 15;
            var data        = await controller.Delete(HotelRoomId);

            Assert.IsType <NotFoundResult>(data);
        }
        public async void Task_DeleteHotelRoom_Return_BadResultResult()
        {
            var controller  = new HotelRoomController(context);
            int?HotelRoomId = null;
            var data        = await controller.Delete(HotelRoomId);

            Assert.IsType <BadRequestResult>(data);
        }
        public async void Task_DeleteHotelRoom_Return_OkResult()
        {
            var controller  = new HotelRoomController(context);
            var HotelRoomId = 20;
            var data        = await controller.Delete(HotelRoomId);

            Assert.IsType <OkObjectResult>(data);
        }
Exemplo n.º 4
0
        public async void Task_DeleteHotelRoom_return_NotFound()
        {
            //Arrange
            var controller = new HotelRoomController(context);
            var id         = 29;

            //Act
            var data = await controller.Delete(id);

            //Assert
            Assert.IsType <NotFoundResult>(data);
        }
Exemplo n.º 5
0
        public void Test_Errors()
        {
            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;

            var r  = tc.Delete(null);
            var r2 = tc.Delete(0);
            var r3 = tc.Edit(0);

            //Untestable because null is ambigious between a int? and an object
            //var r3 = tc.Edit(null);

            Assert.That(r, Is.TypeOf <HttpStatusCodeResult>());
            Assert.That(r2, Is.TypeOf <HttpNotFoundResult>());
            Assert.That(r3, Is.TypeOf <HttpNotFoundResult>());
        }