Example #1
0
        public async Task ReturnCorrectViewResult()
        {
            string keyword      = null;
            var    businessName = "Hilton";

            var businessServiceMocked = new Mock <IBusinessService>();
            var feedbackServiceMocked = new Mock <IFeedbackService>();
            var loggerFactoryMocked   = new Mock <ILogger <BusinessController> >();
            var businessDTO           = new BusinessDTO {
                Name = businessName
            };
            var businesses = new List <BusinessDTO> {
                businessDTO
            };

            businessServiceMocked.Setup(b => b.ListAllBusinessesContainsKeyWordAsync(keyword))
            .ReturnsAsync(businesses);

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

            var result = await businessController.FindBusiness(keyword);

            Assert.IsInstanceOfType(result, typeof(JsonResult));
        }
Example #2
0
        public async Task CallBusinessServiceListAllBusinessesContainsKeyWordAsyncOnce_WhenKeywordIsNull()
        {
            string keyword      = null;
            var    businessName = "Hilton";

            var businessServiceMocked = new Mock <IBusinessService>();
            var feedbackServiceMocked = new Mock <IFeedbackService>();
            var loggerFactoryMocked   = new Mock <ILogger <BusinessController> >();
            var businessDTO           = new BusinessDTO {
                Name = businessName
            };
            var businesses = new List <BusinessDTO> {
                businessDTO
            };

            businessServiceMocked.Setup(b => b.ListAllBusinessesContainsKeyWordAsync(keyword))
            .ReturnsAsync(businesses);

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

            await businessController.FindBusiness(keyword);

            businessServiceMocked.Verify(b => b.ListAllBusinessesContainsKeyWordAsync(""), Times.Once);
        }