Esempio n. 1
0
        public async void DeleteRoomAsyncTest()
        {
            var rId  = Guid.NewGuid();
            var room = new ApiRoom
            {
                RoomId = rId
            };
            var roomtoSend = new ApiRoomtoSend
            {
                RoomId = rId
            };
            var complexRepo = new Mock <IRepository>();
            var logger      = new Mock <ILogger <ComplexController> >();
            var rss         = new Mock <IRoomServiceSender>();
            var ar          = new Mock <IAddressRequest>();
            var rr          = new Mock <IRoomRequest>();
            var res         = true;

            complexRepo.Setup(r => r.DeleteAmenityRoomAsync(rId))
            .Returns(Task.FromResult(res));
            rss.Setup(r => r.SendRoomsMessages(roomtoSend));

            //act
            var controller = new ComplexController(complexRepo.Object, logger.Object, rss.Object, ar.Object, rr.Object);
            var model      = Assert.IsAssignableFrom <StatusCodeResult>(await controller.DeleteRoomAsync(room));

            //assert
            Assert.IsAssignableFrom <StatusCodeResult>(model);
        }
        public async Task DeleteRoomShouldDelete()
        {
            var mockRepo   = new Mock <IRepository>();
            var mockLogger = new Mock <ILogger <ComplexController> >();

            mockRepo.Setup(r => r.DeleteRoomAsync(
                               It.IsAny <Guid>()));

            var controller = new ComplexController(mockRepo.Object, mockLogger.Object);

            //act
            var result = await controller.DeleteRoomAsync(Guid.NewGuid());

            //assert
            Assert.IsAssignableFrom <NoContentResult>(result);
        }
        public async Task DeleteRoomShouldReturnGuidNotFound()
        {
            //arrange
            var mockRepo   = new Mock <IRepository>();
            var mockLogger = new Mock <ILogger <ComplexController> >();

            mockRepo.Setup(r => r.DeleteRoomAsync(
                               It.IsAny <Guid>())).Throws(new InvalidOperationException());

            var controller = new ComplexController(mockRepo.Object, mockLogger.Object);

            //act
            var result = await controller.DeleteRoomAsync(Guid.NewGuid());

            //assert
            Assert.IsType <NotFoundResult>(result);
        }