public async Task DeleteComplexShouldReturnNotFound()
        {
            //arrange
            var mockRepo   = new Mock <IRepository>();
            var mockLogger = new Mock <ILogger <ComplexController> >();

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

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

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

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

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

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

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

            //assert
            Assert.IsAssignableFrom <NoContentResult>(result);
        }
Exemplo n.º 3
0
        public async void DeleteComplexAsyncTest()
        {
            var cId         = Guid.NewGuid();
            var aId         = Guid.NewGuid();
            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.DeleteAmenityComplexAsync(cId))
            .Returns(Task.FromResult(res));
            complexRepo.Setup(r => r.DeleteComplexAsync(cId))
            .Returns(Task.FromResult(res));

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

            //assert
            Assert.IsAssignableFrom <StatusCodeResult>(model);
        }