public void When_Perform_Get_Request_To_EducationOrganizationList_Return_Education_Organization_List()
        {
            // Arrange
            var schools = new EditableList <School>
            {
                new School()
            };

            var leas = new EditableList <LocalEducationAgency>
            {
                new LocalEducationAgency()
            };

            _mockOdsApiFacade.Setup(x => x.GetAllSchools()).Returns(schools);
            _mockOdsApiFacade.Setup(x => x.GetAllLocalEducationAgencies()).Returns(leas);
            _mockOdsApiFacadeFactory.Setup(x => x.Create())
            .Returns(Task.FromResult(_mockOdsApiFacade.Object));
            _controller =
                new EducationOrganizationsController(_mockOdsApiFacadeFactory.Object, _mockMapper.Object, _mockInstanceContext.Object);

            // Act
            var result = _controller.EducationOrganizationList().Result as PartialViewResult;

            // Assert
            result.ShouldNotBeNull();
            var model = (EducationOrganizationViewModel)result.ViewData.Model;

            model.ShouldNotBeNull();
            model.Schools.Count.ShouldBeGreaterThan(0);
            model.LocalEducationAgencies.Count.ShouldBeGreaterThan(0);
        }
コード例 #2
0
        public void When_Perform_Get_Request_To_EducationOrganizationList_Return_Education_Organization_List()
        {
            // Arrange
            var schools = new List <School>
            {
                new School()
            };

            var leas = new List <LocalEducationAgency>
            {
                new LocalEducationAgency()
            };
            const string gradeLevel = "FirstGrade";
            const string value      = "Namespace#FirstGrade";
            const string localEducationAgencyCategory      = "School";
            const string localEducationAgencyCategoryValue = "Namespace#School";

            _mockOdsApiFacade.Setup(x => x.GetAllSchools()).Returns(schools);
            _mockOdsApiFacade.Setup(x => x.GetAllLocalEducationAgencies()).Returns(leas);
            _mockOdsApiFacadeFactory.Setup(x => x.Create())
            .Returns(Task.FromResult(_mockOdsApiFacade.Object));
            _mockOdsApiFacade.Setup(x => x.GetAllGradeLevels())
            .Returns(new List <SelectOptionModel> {
                new SelectOptionModel {
                    DisplayText = gradeLevel, Value = value
                }
            });
            _mockOdsApiFacade.Setup(x => x.GetLocalEducationAgencyCategories())
            .Returns(new List <SelectOptionModel>
            {
                new SelectOptionModel {
                    DisplayText = localEducationAgencyCategory, Value = localEducationAgencyCategoryValue
                }
            });
            _controller =
                new EducationOrganizationsController(_mockOdsApiFacadeFactory.Object, _mockMapper.Object, _mockInstanceContext.Object, _tabDisplayService.Object);

            // Act
            var result = _controller.EducationOrganizationList().Result as PartialViewResult;

            // Assert
            result.ShouldNotBeNull();
            var model = (EducationOrganizationViewModel)result.ViewData.Model;

            model.ShouldNotBeNull();
            model.Schools.Count.ShouldBeGreaterThan(0);
            model.LocalEducationAgencies.Count.ShouldBeGreaterThan(0);

            var addSchoolModel = model.AddSchoolModel;

            addSchoolModel.ShouldNotBeNull();
            addSchoolModel.GradeLevelOptions.Count.ShouldBe(1);
            addSchoolModel.GradeLevelOptions.Single().DisplayText.ShouldBe(gradeLevel);
            addSchoolModel.GradeLevelOptions.Single().Value.ShouldBe(value);

            var addLocalEducationAgencyModel = model.AddLocalEducationAgencyModel;

            addLocalEducationAgencyModel.ShouldNotBeNull();
            addLocalEducationAgencyModel.LocalEducationAgencyCategoryTypeOptions.Count.ShouldBe(1);
            addLocalEducationAgencyModel.LocalEducationAgencyCategoryTypeOptions.Single().DisplayText.ShouldBe(localEducationAgencyCategory);
            addLocalEducationAgencyModel.LocalEducationAgencyCategoryTypeOptions.Single().Value.ShouldBe(localEducationAgencyCategoryValue);
        }