Beispiel #1
0
        public async Task ReturnCorrectViewModel()
        {
            var id             = 1;
            var feedbacksCount = 4;
            var businessName   = "Hilton";

            var businessServiceMocked = new Mock <IBusinessService>();
            var feedbackServiceMocked = new Mock <IFeedbackService>();
            var loggerFactoryMocked   = new Mock <ILogger <BusinessController> >();
            var businessDetailsDTO    = new BusinessDetailsDTO {
                Name = businessName
            };

            businessServiceMocked.Setup(b => b.FindDetaliedBusinessAsync(id, feedbacksCount))
            .ReturnsAsync(businessDetailsDTO);

            var businessController = new BusinessController(businessServiceMocked.Object, feedbackServiceMocked.Object, loggerFactoryMocked.Object);

            var vm = await businessController.Details(id) as ViewResult;

            Assert.IsInstanceOfType(vm.Model, typeof(BusinessDetailsDTO));
        }
Beispiel #2
0
        public async Task CallBusinessServiceFindDetaliedBusinessAsyncOnce()
        {
            var id             = 1;
            var feedbacksCount = 4;
            var businessName   = "Hilton";

            var businessServiceMocked = new Mock <IBusinessService>();
            var feedbackServiceMocked = new Mock <IFeedbackService>();
            var loggerFactoryMocked   = new Mock <ILogger <BusinessController> >();
            var businessDetailsDTO    = new BusinessDetailsDTO {
                Name = businessName
            };

            businessServiceMocked.Setup(b => b.FindDetaliedBusinessAsync(id, feedbacksCount))
            .ReturnsAsync(businessDetailsDTO);

            var businessController = new BusinessController(businessServiceMocked.Object, feedbackServiceMocked.Object, loggerFactoryMocked.Object);

            await businessController.Details(id);

            businessServiceMocked.Verify(b => b.FindDetaliedBusinessAsync(id, feedbacksCount), Times.Once);
        }