コード例 #1
0
        public void ShouldNotValidateAddSchoolModelIfGradeLevelsListIsEmpty()
        {
            // Arrange
            _addSchoolModel.GradeLevels = new List <string>();

            var existingLeaWithDifferentId = new LocalEducationAgency
            {
                EducationOrganizationId = 2
            };

            _mockOdsApiFacade.Setup(x => x.GetAllLocalEducationAgencies()).Returns(new List <LocalEducationAgency>
            {
                existingLeaWithDifferentId
            });

            var existingSchoolWithDifferentId = new School
            {
                EducationOrganizationId = 3
            };

            _mockOdsApiFacade.Setup(x => x.GetAllSchools()).Returns(new List <School>
            {
                existingSchoolWithDifferentId
            });

            _mockOdsApiFacadeFactory.Setup(x => x.Create())
            .Returns(Task.FromResult(_mockOdsApiFacade.Object));

            var validator = new AddSchoolModelValidator(_mockOdsApiFacadeFactory.Object);

            validator.ShouldNotValidate(_addSchoolModel, "You must choose at least one grade level");
        }
コード例 #2
0
        public void ShouldNotValidateAddSchoolModelIfSchoolIdIsEmpty()
        {
            _addSchoolModel.SchoolId = null;
            var validator = new AddSchoolModelValidator(_mockOdsApiFacadeFactory.Object);

            validator.ShouldNotValidate(_addSchoolModel, "'School ID' must not be empty.");
        }
コード例 #3
0
        public void ShouldNotValidateAddSchoolModelIfPassedWithExistingSchoolEdOrgId()
        {
            // Arrange
            var existingLeaWithDifferentId = new LocalEducationAgency
            {
                EducationOrganizationId = 2
            };

            _mockOdsApiFacade.Setup(x => x.GetAllLocalEducationAgencies()).Returns(new List <LocalEducationAgency>
            {
                existingLeaWithDifferentId
            });

            var existingSchoolWithSameId = new School
            {
                EducationOrganizationId = Id
            };

            _mockOdsApiFacade.Setup(x => x.GetAllSchools()).Returns(new List <School>
            {
                existingSchoolWithSameId
            });

            _mockOdsApiFacadeFactory.Setup(x => x.Create())
            .Returns(Task.FromResult(_mockOdsApiFacade.Object));

            var validator = new AddSchoolModelValidator(_mockOdsApiFacadeFactory.Object);

            validator.ShouldNotValidate(_addSchoolModel, "This 'School ID' is already associated with another Education Organization. Please provide a unique value.");
        }
コード例 #4
0
        public void ShouldNotValidateAddSchoolModelIfSchoolIdIsEmpty()
        {
            _addSchoolModel.SchoolId = null;
            var validator = new AddSchoolModelValidator();

            validator.ShouldNotValidate(_addSchoolModel, "'School ID' must not be empty.");
        }
コード例 #5
0
        public void ShouldNotValidateAddSchoolModelIfGradeLevelsListIsEmpty()
        {
            // Arrange
            _addSchoolModel.GradeLevels = new List <string>();

            var existingLeaWithDifferentId = new LocalEducationAgency
            {
                EducationOrganizationId = 2
            };

            _mockOdsApiFacade.Setup(x => x.GetAllLocalEducationAgencies()).Returns(new List <LocalEducationAgency>
            {
                existingLeaWithDifferentId
            });

            var existingSchoolWithDifferentId = new School
            {
                EducationOrganizationId = 3
            };

            _mockOdsApiFacade.Setup(x => x.GetAllSchools()).Returns(new List <School>
            {
                existingSchoolWithDifferentId
            });

            var existingPsiWithDifferentId = new PostSecondaryInstitution
            {
                EducationOrganizationId = 4
            };

            _mockOdsApiFacade.Setup(x => x.GetAllPostSecondaryInstitutions()).Returns(new List <PostSecondaryInstitution>
            {
                existingPsiWithDifferentId
            });

            var validator = new AddSchoolModelValidator();

            validator.ShouldNotValidate(_addSchoolModel, "You must choose at least one grade level");
        }