Ejemplo n.º 1
0
 public void TearDown()
 {
     ValidationPortalDbContextMock.Reset();
     DbContextFactoryMock.Reset();
     AppUserServiceMock.Reset();
     SchoolYearServiceMock.Reset();
     LoggingServiceMock.Reset();
 }
Ejemplo n.º 2
0
 public void TearDown()
 {
     EngineConfigMock.Reset();
     AppUserServiceMock.Reset();
     EdOrgServiceMock.Reset();
     SchoolYearServiceMock.Reset();
     LoggingServiceMock.Reset();
     ValidationPortalDbContextMock.Reset();
     OdsConfigurationValuesMock.Reset();
     SchoolYearDbContextFactoryMock.Reset();
     DbContextFactoryMock.Reset();
     SchoolYearDbContextMock.Reset();
 }
Ejemplo n.º 3
0
        public void SetupValidationRun_Should_ReturnValidationReportSummary()
        {
            var rulesEngineService = new RulesEngineService(
                AppUserServiceMock.Object,
                EdOrgServiceMock.Object,
                SchoolYearServiceMock.Object,
                EngineConfigMock.Object,
                LoggingServiceMock.Object,
                DbContextFactoryMock.Object,
                SchoolYearDbContextFactoryMock.Object,
                EngineObjectModel,
                null);

            var schoolYear = new SchoolYear
            {
                Id             = 1,
                Enabled        = true,
                ErrorThreshold = null,
                StartYear      = "2019",
                EndYear        = "2020"
            };

            var submissionCycle = new SubmissionCycle {
                SchoolYearId = schoolYear.Id, CollectionId = "collection"
            };

            SchoolYearServiceMock.Setup(x => x.GetSchoolYearById(schoolYear.Id)).Returns(schoolYear);

            AppUserServiceMock.Setup(x => x.GetSession()).Returns(DefaultTestAppUserSession);
            AppUserServiceMock.Setup(x => x.GetUser()).Returns(DefaultTestAppUserSession.UserIdentity);

            var result = rulesEngineService.SetupValidationRun(submissionCycle, submissionCycle.CollectionId);

            result.ShouldNotBeNull();
            result.SchoolYearId.ShouldEqual(schoolYear.Id);
            result.Collection.ShouldEqual(submissionCycle.CollectionId);

            SchoolYearDbContextMock.Verify(
                x => x.RuleValidations.Add(
                    It.Is <RuleValidation>(y => y.CollectionId == submissionCycle.CollectionId)));
        }
Ejemplo n.º 4
0
        public void GetEdOrgById_Should_ReturnSpecifiedEdOrgIfPresent()
        {
            const int    testEdOrgId      = 12345;
            const int    testSchoolYearId = 111;
            const string testSchoolName   = "12345 Elementary";

            var allEdOrgs = new List <EdOrg>
            {
                new EdOrg
                {
                    Id                    = testEdOrgId,
                    SchoolYearId          = testSchoolYearId,
                    OrganizationName      = testSchoolName,
                    OrganizationShortName = testSchoolName
                },
                new EdOrg {
                    Id = 23456
                },
                new EdOrg {
                    Id = 34567
                }
            };

            EntityFrameworkMocks.SetupMockDbSet(
                EntityFrameworkMocks.GetQueryableMockDbSet(allEdOrgs),
                ValidationPortalDbContextMock,
                x => x.EdOrgs,
                x => x.EdOrgs = It.IsAny <DbSet <EdOrg> >(),
                allEdOrgs);

            var testSchoolYear = new SchoolYear
            {
                Id        = testSchoolYearId,
                StartYear = "1776",
                EndYear   = "1777",
                Enabled   = true
            };

            var schoolYears = new List <SchoolYear>(new[] { testSchoolYear });

            EntityFrameworkMocks.SetupMockDbSet(
                EntityFrameworkMocks.GetQueryableMockDbSet(schoolYears),
                ValidationPortalDbContextMock,
                x => x.SchoolYears,
                x => x.SchoolYears = It.IsAny <DbSet <SchoolYear> >(),
                schoolYears);

            var edOrgService = new EdOrgService(
                DbContextFactoryMock.Object,
                AppUserServiceMock.Object,
                SchoolYearServiceMock.Object,
                SchoolYearDbContextFactoryMock.Object,
                LoggingServiceMock.Object);

            SchoolYearServiceMock.Setup(x => x.GetSchoolYearById(testSchoolYearId)).Returns(testSchoolYear);

            LoggingServiceMock.Setup(x => x.LogDebugMessage($"EdOrg cache: {allEdOrgs.Count} currently in ValidationPortal database"));

            var result = edOrgService.GetEdOrgById(testEdOrgId, testSchoolYearId);

            result.ShouldNotBeNull();
        }