public void TestAutocomplete()
        {
            //Arrange
            IEnumerable <string> courseNames = new List <string>(
                new[] { "ANIMAL BEHAVIOR", "ANIMAL", "ANIMAL BEHAVIOR",
                        "BAKER", "ANIMAL KEEPER", "BAKER CLEANER", "ANIMAL CARE", "BAKER ASSISTANT" }
                );

            MockCourseDirectory.Setup(x => x.AutoSuggestCourseName(It.IsAny <string>())).Returns(courseNames);

            //Act
            var json   = Controller.Autocomplete("TEST") as JsonResult;
            var result = json.Value as List <string>;

            //Assert
            Assert.True(result != null);
            Assert.True(result.Count == 7);
            Assert.True(result[0] == "ANIMAL");
            Assert.True(result[1] == "ANIMAL BEHAVIOR");
            Assert.True(result[2] == "ANIMAL CARE");
            Assert.True(result[3] == "ANIMAL KEEPER");
            Assert.True(result[4] == "BAKER");
            Assert.True(result[5] == "BAKER ASSISTANT");
            Assert.True(result[6] == "BAKER CLEANER");
        }
        public void TestCourseSearchResultWithValidModelStateAndInvalidSearchResult()
        {
            var fromQuery = new CourseSearchRequestModel()
            {
                SubjectKeyword = "TestSubjectKeyword", LocationRadius = 20
            };
            var criteria           = new CourseSearchCriteria("test");
            var courseSearchResult = Result.Ok(new CourseSearchResult(1, 1, 1, new CourseItem[] { }));
            var expected           = new CourseSearchResultViewModel(courseSearchResult)
            {
                SubjectKeyword = fromQuery.SubjectKeyword, Location = fromQuery.Location
            };

            MockTelemetryClient.Setup(x => x.TrackEvent(It.IsAny <string>(), null, null)).Verifiable();
            MockTelemetryClient.Setup(x => x.Flush()).Verifiable();
            MockCourseDirectory.Setup(x => x.CreateCourseSearchCriteria(fromQuery)).Returns(criteria);
            MockCourseDirectory.Setup(x => x.IsSuccessfulResult(
                                          It.IsAny <IResult <CourseSearchResult> >(), It.IsAny <ITelemetryClient>(), It.IsAny <string>(),
                                          It.IsAny <string>(), It.IsAny <DateTime>()
                                          )).Returns(false); // Mock that Is Invalid Search Result
            //MockCourseDirectoryService.Setup(x => x.CourseDirectorySearch(criteria, It.IsAny<PagingOptions>()))
            //    .Returns(courseSearchResult);

            var result = Controller.CourseSearchResult(fromQuery) as ViewResult;

            MockTelemetryClient.Verify(x => x.TrackEvent(It.IsAny <string>(), null, null), (Times.AtLeastOnce()));
            MockTelemetryClient.Verify(x => x.Flush(), (Times.Never()));
            AssertDefaultErrorView(result);
        }
        public void TestIndex()
        {
            // Arrange
            MockCourseDirectory.Setup(x => x.GetQualificationLevels()).Returns(new List <SelectListItem>()).Verifiable();
            MockTelemetryClient.Setup(x => x.TrackEvent(It.IsAny <string>(), null, null)).Verifiable();

            // Act
            var result = Controller.Index();

            // Assert
            MockCourseDirectory.Verify();
            MockTelemetryClient.Verify();
            Assert.NotNull(result);
        }