public async Task GetChildrenForOrganization(
            string[] include,
            bool includeFamily,
            bool includeDeterminations
            )
        {
            Guid[] ids;
            int    organizationId;

            using (var context = new TestHedwigContextProvider().Context)
            {
                var organization = OrganizationHelper.CreateOrganization(context);
                var children     = ChildHelper.CreateChildren(context, 3, organization: organization);
                ids            = children.Select(c => c.Id).ToArray();
                organizationId = organization.Id;
            }

            using (var context = new TestHedwigContextProvider().Context)
            {
                var childRepo = new ChildRepository(context);
                var res       = await childRepo.GetChildrenForOrganizationAsync(organizationId, include);

                Assert.Equal(ids.OrderBy(id => id), res.Select(c => c.Id).OrderBy(id => id));
                Assert.Equal(includeFamily, res.TrueForAll(c => c.Family != null));
                Assert.Equal(includeDeterminations, res.TrueForAll(c => c.Family != null && c.Family.Determinations != null));
            }
        }
Example #2
0
        public void GetReportsForFiscalYear(
            int year,
            int month,
            int day,
            int total
            )
        {
            var          reportDate = new DateTime(year, month, day);
            Organization organization;

            using (var context = new TestHedwigContextProvider().Context)
            {
                var dates = new List <DateTime> {
                    new DateTime(2010, 1, 1),
                    new DateTime(2010, 5, 1),
                    new DateTime(2010, 7, 1),
                    new DateTime(2011, 2, 1),
                    new DateTime(2011, 7, 1),
                };
                organization = OrganizationHelper.CreateOrganization(context);
                foreach (var date in dates)
                {
                    var reportingPeriod = ReportingPeriodHelper.CreateReportingPeriod(context, period: date.ToString("yyyy-MM-dd"));
                    ReportHelper.CreateCdcReport(context, organization: organization, reportingPeriod: reportingPeriod);
                }
            }

            using (var context = new TestHedwigContextProvider().Context)
            {
                var reportRepo = new ReportRepository(context);
                var result     = reportRepo.GetReportsForOrganizationByFiscalYear(organization.Id, reportDate);

                Assert.Equal(total, result.Count());
            }
        }
Example #3
0
        public async Task CreatesReportForOrganization(
            bool hasFundingSpace,
            string today,
            int numOfReportsGenerated
            )
        {
            int organizationId;
            int lastReportingPeriodId;

            using (var context = new TestHedwigContextProvider().Context)
            {
                var organization = OrganizationHelper.CreateOrganization(context);
                organizationId = organization.Id;
                if (hasFundingSpace)
                {
                    FundingSpaceHelper.CreateFundingSpace(context, organizationId);
                }

                var lastReportingPeriod = ReportingPeriodHelper.GetOrCreateReportingPeriodForPeriod(
                    context,
                    period: "2010-10-01",
                    periodStart: "2010-10-01",
                    periodEnd: "2010-10-31"
                    );
                lastReportingPeriodId = lastReportingPeriod.Id;
            }

            using (var context = new TestHedwigContextProvider().Context)
            {
                var logger              = new Mock <ILogger <CdcReportGeneratorScopedService> >();
                var orgRepo             = new OrganizationRepository(context);
                var reportingPeriodRepo = new ReportingPeriodRepository(context);
                var reportRepo          = new ReportRepository(context);
                var dateTime            = new Mock <IDateTime>();
                dateTime.Setup(dateTime => dateTime.UtcNow).Returns(DateTime.Parse(today));

                var cdcReportGenerator = new CdcReportGeneratorScopedService(
                    logger.Object,
                    orgRepo,
                    reportingPeriodRepo,
                    reportRepo,
                    dateTime.Object
                    );

                var previousReports = reportRepo.GetReportsForOrganization(organizationId);

                await cdcReportGenerator.TryGenerateReports();

                var reports = reportRepo.GetReportsForOrganization(organizationId);

                Assert.Empty(previousReports);
                Assert.Equal(numOfReportsGenerated, reports.Count());
                if (numOfReportsGenerated > 0)
                {
                    Assert.True(reports.All(report => report.ReportingPeriodId == lastReportingPeriodId));
                }
            }
        }
Example #4
0
        public async Task Get_Report_For_Organization(bool submitted, string[] include)
        {
            using (var context = new TestHedwigContextProvider().Context)
            {
                // Set up test data
                var organization    = OrganizationHelper.CreateOrganization(context);
                var reportingPeriod = ReportingPeriodHelper.CreateReportingPeriod(context);
                var report          = ReportHelper.CreateCdcReport(context, organization: organization, reportingPeriod: reportingPeriod);
                var site            = SiteHelper.CreateSite(context, organization: organization);
                var enrollment      = EnrollmentHelper.CreateEnrollment(context, site: site, ageGroup: Age.Preschool);
                var funding         = FundingHelper.CreateFunding(context, enrollment: enrollment, firstReportingPeriod: reportingPeriod);

                if (submitted)
                {
                    Thread.Sleep(1000);

                    report.SubmittedAt = DateTime.Now;
                    context.SaveChanges();

                    Thread.Sleep(1000);
                }

                enrollment.AgeGroup = Age.SchoolAge;
                context.SaveChanges();

                // When the repository is queried
                var repo   = new ReportRepository(context);
                var result = await repo.GetReportForOrganizationAsync(report.Id, organization.Id, include) as CdcReport;

                // It returns the Report
                Assert.Equal(result.Id, report.Id);

                // It includes the Organization
                Assert.Equal(include.Contains("organizations"), result.Organization != null);

                // It includes the Sites
                Assert.Equal(include.Contains("sites"), result.Organization != null && result.Organization.Sites != null);

                // It includes the Enrollments (and Fundings too)
                Assert.Equal(
                    include.Contains("enrollments"),
                    result.Enrollments != null &&
                    result.Enrollments.FirstOrDefault().Fundings != null
                    );

                // When it includes enrollments
                if (include.Contains("enrollments"))
                {
                    var enrollmentResult = result.Enrollments.FirstOrDefault();
                    var fundingResult    = enrollmentResult.Fundings.FirstOrDefault();

                    // A submitted report should return the data as of when it was submitted
                    Assert.Equal(submitted ? Age.Preschool : Age.SchoolAge, enrollmentResult.AgeGroup);
                }
            }
        }
Example #5
0
        public async Task ReportControllerOrganizationsReportsGet_ReturnsCorrectResponseShape()
        {
            User         user;
            Organization organization;

            Site[] sites;
            Report report;

            using (var context = new TestHedwigContextProvider().Context)
            {
                organization = OrganizationHelper.CreateOrganization(context);
                var site1 = SiteHelper.CreateSite(context, organization: organization);
                var site2 = SiteHelper.CreateSite(context, organization: organization);
                report = ReportHelper.CreateCdcReport(context, organization: organization);
                sites  = new Site[] { site1, site2 };
                EnrollmentHelper.CreateEnrollment(context, site: site1);
                user = UserHelper.CreateUser(context);
                PermissionHelper.CreateSitePermission(context, user, site1);
                PermissionHelper.CreateSitePermission(context, user, site2);
                PermissionHelper.CreateOrganizationPermission(context, user, organization);
            }

            var client = _factory.CreateClient();

            var request = HedwigAPIRequests.OrganizationReports(
                user,
                organization
                );

            var response = await client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            var responseString = await response.Content.ReadAsStringAsync();

            var responseReports = JsonConvert.DeserializeObject <List <CdcReport> >(responseString);

            Assert.NotEmpty(responseReports);

            var responseReport = responseReports.First();

            Assert.NotNull(responseReport);
            Assert.Equal(report.Id, responseReport.Id);
            Assert.NotNull(responseReport.Organization);
            Assert.Null(responseReport.Organization.FundingSpaces);
            Assert.Null(responseReport.Organization.Sites);
            Assert.NotNull(responseReport.ReportingPeriod);
            Assert.Null(responseReport.Enrollments);
        }
Example #6
0
        public void GetReportsForOrganization()
        {
            using (var context = new TestHedwigContextProvider().Context)
            {
                var organization = OrganizationHelper.CreateOrganization(context);
                var reports      = ReportHelper.CreateCdcReports(context, 5, organization: organization);
                var reportIds    = reports.Select(report => report.Id);
                ReportHelper.CreateCdcReport(context);

                var reportRepo = new ReportRepository(context);
                var result     = reportRepo.GetReportsForOrganization(organization.Id);
                var resultIds  = result.Select(r => r.Id);
                Assert.Equal(reportIds, resultIds);
            }
        }
Example #7
0
        public async Task DoesNotCreateDuplicateReports()
        {
            int organizationId;

            using (var context = new TestHedwigContextProvider().Context)
            {
                var organization = OrganizationHelper.CreateOrganization(context);
                organizationId = organization.Id;
                var fundingSpace = FundingSpaceHelper.CreateFundingSpace(context, organizationId);
                organization.FundingSpaces = new List <FundingSpace> {
                    fundingSpace
                };
                var currentReportingPeriod = ReportingPeriodHelper.CreateReportingPeriod(context);
            }

            using (var context = new TestHedwigContextProvider().Context)
            {
                var logger              = new Mock <ILogger <CdcReportGeneratorScopedService> >();
                var orgRepo             = new OrganizationRepository(context);
                var reportingPeriodRepo = new ReportingPeriodRepository(context);
                var reportRepo          = new ReportRepository(context);
                var dateTime            = new Mock <IDateTime>();
                dateTime.Setup(dateTime => dateTime.UtcNow).Returns(DateTime.Parse("2019-10-01"));

                var cdcReportGenerator = new CdcReportGeneratorScopedService(
                    logger.Object,
                    orgRepo,
                    reportingPeriodRepo,
                    reportRepo,
                    dateTime.Object
                    );

                var previousReports = reportRepo.GetReportsForOrganization(organizationId);

                await cdcReportGenerator.TryGenerateReports();

                await cdcReportGenerator.TryGenerateReports();

                await cdcReportGenerator.TryGenerateReports();

                var reports = reportRepo.GetReportsForOrganization(organizationId);

                Assert.Empty(previousReports);
                Assert.Single(reports);
            }
        }
Example #8
0
        public void UserCanAccessSite_OrganizationPermission()
        {
            using (var context = new TestHedwigContextProvider().Context)
            {
                // If user exists with organization permission that includes site
                var user         = UserHelper.CreateUser(context);
                var site         = SiteHelper.CreateSite(context);
                var organization = OrganizationHelper.CreateOrganization(context, sites: new Site[] { site });
                PermissionHelper.CreateOrganizationPermission(context, user, organization);

                // When repository is queried for user access to site
                var permissionRepo = new PermissionRepository(context);
                var res            = permissionRepo.UserCanAccessSite(user.WingedKeysId, site.Id);

                // Then result is true
                Assert.True(res);
            }
        }
        public void Other_Controller_User_Has_Organization_Access_Evaluate_Returns_True()
        {
            using (var dbContext = new TestHedwigContextProvider().Context)
            {
                // If user exists with access to organization
                var user         = UserHelper.CreateUser(dbContext);
                var organization = OrganizationHelper.CreateOrganization(dbContext);
                PermissionHelper.CreateOrganizationPermission(dbContext, user, organization);

                // When requirement is evaluated with:
                // - claim for that user
                var claim     = new Claim("sub", $"{user.WingedKeysId}");
                var userClaim = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { claim }));

                // - httpContext for request to other controller nested under that organization
                var httpContext         = new Mock <HttpContext>();
                var httpContextAccessor = new HttpContextAccessor
                {
                    HttpContext = httpContext.Object
                };
                var routeValues = new RouteValueDictionary(new Dictionary <string, string> {
                    { "controller", "Other" },
                    { "orgId", $"{organization.Id}" }
                });
                httpContext.Setup(hc => hc.Features.Get <IRoutingFeature>()).Returns(new Mock <IRoutingFeature>().Object);
                httpContext.Setup(hc => hc.Request.RouteValues).Returns(routeValues);

                // - permission repository
                var permissions = new PermissionRepository(dbContext);

                var reqHandler = new OrganizationAccessHandler(httpContextAccessor, permissions);
                var req        = new OrganizationAccessRequirement();

                var authContext = new AuthorizationHandlerContext(new List <IAuthorizationRequirement> {
                    req
                }, userClaim, new object());

                // When requirement handler handles authorization context
                reqHandler.HandleAsync(authContext);

                // Then authorization context will have succeeded
                Assert.True(authContext.HasSucceeded);
            }
        }
        public async Task GetSitesForOrganizationAsync_ReturnsSitesWithOrganizationId()
        {
            using (var context = new TestHedwigContextProvider().Context)
            {
                var organization        = OrganizationHelper.CreateOrganization(context);
                var anotherOrganization = OrganizationHelper.CreateOrganization(context);
                var sites      = SiteHelper.CreateSites(context, 3, organization: organization);
                var otherSites = SiteHelper.CreateSite(context, organization: anotherOrganization);
                var siteIds    = sites.Select(site => site.Id);

                var siteRepo = new SiteRepository(context);
                var res      = await siteRepo.GetSitesForOrganizationAsync(organization.Id);

                var resIds = res.Select(rSite => rSite.Id);

                // Assert all returned sites are in the created sites with correct org id
                Assert.All(res, rSite => Assert.Contains(rSite.Id, siteIds));
                // Assert all created sites with correct org id are in the created sites
                Assert.All(siteIds, id => Assert.Contains(id, resIds));
                // Assert all returned sites have the correct org id
                Assert.All(res, rSite => Assert.Equal(rSite.OrganizationId, rSite.OrganizationId));
            }
        }
        public async Task OrganizationControllerOrganizationsGet_ReturnsCorrectResponseShape(
            string[] include,
            bool isInclude
            )
        {
            User         user;
            Organization organization;

            Site[] sites;
            using (var context = new TestHedwigContextProvider().Context)
            {
                organization = OrganizationHelper.CreateOrganization(context);
                var site1 = SiteHelper.CreateSite(context, organization: organization);
                var site2 = SiteHelper.CreateSite(context, organization: organization);
                sites = new Site[] { site1, site2 };
                EnrollmentHelper.CreateEnrollment(context, site: site1);
                user = UserHelper.CreateUser(context);
                PermissionHelper.CreateSitePermission(context, user, site1);
                PermissionHelper.CreateSitePermission(context, user, site2);
                PermissionHelper.CreateOrganizationPermission(context, user, organization);
            }

            var client = _factory.CreateClient();

            var request = HedwigAPIRequests.Organizations(
                user,
                organization,
                include
                );

            var response = await client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            var responseString = await response.Content.ReadAsStringAsync();

            var responseOrganization = JsonConvert.DeserializeObject <Organization>(responseString);

            Assert.NotNull(responseOrganization);
            Assert.Equal(organization.Id, responseOrganization.Id);
            Assert.Equal(organization.Name, responseOrganization.Name);
            Assert.Null(responseOrganization.Reports);
            if (isInclude)
            {
                Assert.NotEmpty(responseOrganization.Sites);
                Assert.All(
                    responseOrganization.Sites,
                    site =>
                {
                    Assert.NotNull(site.Name);
                    Assert.Null(site.Organization);
                    Assert.Null(site.Enrollments);
                }
                    );
                Assert.Null(responseOrganization.Reports);
                Assert.NotNull(responseOrganization.FundingSpaces);
                Assert.All(
                    responseOrganization.FundingSpaces,
                    fundingSpace =>
                {
                    Assert.NotNull(fundingSpace);
                    Assert.Equal(fundingSpace.Time == FundingTime.Split, fundingSpace.TimeSplit != null);
                }
                    );
            }
            else
            {
                Assert.Null(responseOrganization.Sites);
                Assert.Null(responseOrganization.FundingSpaces);
            }
        }
Example #12
0
        public async Task ReportControllerOrganizationsReportGet_ReturnsCorrectResponseShape()
        {
            User         user;
            Organization organization;

            Site[] sites;
            Report report;

            using (var context = new TestHedwigContextProvider().Context)
            {
                organization = OrganizationHelper.CreateOrganization(context);
                var site1 = SiteHelper.CreateSite(context, organization: organization);
                var site2 = SiteHelper.CreateSite(context, organization: organization);
                report = ReportHelper.CreateCdcReport(context, organization: organization);
                sites  = new Site[] { site1, site2 };
                EnrollmentHelper.CreateEnrollment(context, site: site1);
                user = UserHelper.CreateUser(context);
                PermissionHelper.CreateSitePermission(context, user, site1);
                PermissionHelper.CreateSitePermission(context, user, site2);
                PermissionHelper.CreateOrganizationPermission(context, user, organization);
            }

            var client = _factory.CreateClient();

            var request = HedwigAPIRequests.OrganizationReport(
                user,
                organization,
                report
                );

            var response = await client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            var responseString = await response.Content.ReadAsStringAsync();

            var responseReport = JsonConvert.DeserializeObject <CdcReport>(responseString);

            Assert.NotNull(responseReport);
            Assert.Equal(report.Id, responseReport.Id);
            Assert.NotNull(responseReport.Organization);
            Assert.All(
                responseReport.Organization.Sites,
                site =>
            {
                Assert.NotNull(site.Name);
                Assert.Null(site.Organization);
                Assert.Null(site.Enrollments);
            }
                );
            Assert.NotNull(responseReport.Organization.FundingSpaces);
            Assert.All(
                responseReport.Organization.FundingSpaces,
                fundingSpace =>
            {
                Assert.NotNull(fundingSpace);
                Assert.Equal(fundingSpace.Time == FundingTime.Split, fundingSpace.TimeSplit != null);
            }
                );
            Assert.NotNull(responseReport.ReportingPeriod);
            Assert.NotNull(responseReport.Enrollments);
            Assert.All(
                responseReport.Enrollments,
                enrollment =>
            {
                Assert.NotNull(enrollment.Child);
                Assert.Null(enrollment.Child.Family);
                Assert.Null(enrollment.Child.Enrollments);
                Assert.Null(enrollment.Child.Organization);
                Assert.Null(enrollment.Site);
                Assert.All(
                    enrollment.Fundings,
                    funding =>
                {
                    Assert.NotNull(funding.FundingSpace);
                    Assert.Equal(funding.FundingSpace.Time == FundingTime.Split, funding.FundingSpace.TimeSplit != null);
                    Assert.NotNull(funding.Source);
                    Assert.NotNull(funding.FirstReportingPeriod);
                    Assert.NotNull(funding.LastReportingPeriod);
                }
                    );
                Assert.Null(enrollment.PastEnrollments);
            }
                );
        }
Example #13
0
        public async Task ReportControllerOrganizationsReportPut_IsSuccessfull_OrReturnsValidationError(
            int partTimeWeeksUsed,
            bool shouldSucceed
            )
        {
            User         user;
            Organization organization;
            FundingSpace fundingSpace;
            Site         site;
            CdcReport    report;

            using (var context = new TestHedwigContextProvider().Context)
            {
                organization = OrganizationHelper.CreateOrganization(context);
                var reportingPeriod = ReportingPeriodHelper.CreateReportingPeriod(context, period: "2010-01-01", periodStart: "2010-01-01", periodEnd: "2010-01-31");
                fundingSpace = FundingSpaceHelper.CreateFundingSpace(context, organization.Id, time: FundingTime.Split);
                site         = SiteHelper.CreateSite(context, organization: organization);
                report       = ReportHelper.CreateCdcReport(context, organization: organization, reportingPeriod: reportingPeriod) as CdcReport;
                EnrollmentHelper.CreateEnrollment(context, site: site);
                user = UserHelper.CreateUser(context);
                PermissionHelper.CreateSitePermission(context, user, site);
                PermissionHelper.CreateOrganizationPermission(context, user, organization);
            }

            var timeSplitUtilization = new FundingTimeSplitUtilization
            {
                ReportId          = report.Id,
                ReportingPeriodId = report.ReportingPeriodId,
                FundingSpaceId    = fundingSpace.Id,
                PartTimeWeeksUsed = partTimeWeeksUsed,
                FullTimeWeeksUsed = 0,
            };

            typeof(FundingTimeSplitUtilization).GetProperty(nameof(FundingTimeSplitUtilization.ReportingPeriod)).SetValue(timeSplitUtilization, report.ReportingPeriod);
            var reportForPut = new CdcReport
            {
                Id                    = report.Id,
                Accredited            = report.Accredited,
                Comment               = report.Comment,
                Enrollments           = report.Enrollments,
                C4KRevenue            = 0,
                FamilyFeesRevenue     = 0,
                OrganizationId        = report.OrganizationId,
                ReportingPeriodId     = report.ReportingPeriodId,
                TimeSplitUtilizations = new List <FundingTimeSplitUtilization> {
                    timeSplitUtilization
                },
            };

            typeof(Report).GetProperty(nameof(Report.ReportingPeriod)).SetValue(reportForPut, report.ReportingPeriod);

            var request = HedwigAPIRequests.OrganizationReportPut(
                user,
                organization,
                reportForPut
                );

            var client   = _factory.CreateClient();
            var response = await client.SendAsync(request);

            if (shouldSucceed)
            {
                response.EnsureSuccessStatusCode();
            }
            else
            {
                Assert.False(response.IsSuccessStatusCode);
            }
        }
Example #14
0
        public async Task EnrollmentControllerOrganizationSiteEnrollmentGet_ReturnsCorrectResponseShape()
        {
            Enrollment   enrollment;
            User         user;
            Organization organization;
            Site         site;

            using (var context = new TestHedwigContextProvider().Context)
            {
                organization = OrganizationHelper.CreateOrganization(context);
                site         = SiteHelper.CreateSite(context, organization: organization);
                enrollment   = EnrollmentHelper.CreateEnrollment(context, site: site);
                user         = UserHelper.CreateUser(context);
                PermissionHelper.CreateSitePermission(context, user, site);
                PermissionHelper.CreateOrganizationPermission(context, user, organization);
            }

            var client = _factory.CreateClient();

            var request = HedwigAPIRequests.OrganizationSiteEnrollmentDetail(
                user,
                enrollment,
                organization,
                site
                );

            var response = await client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            var responseString = await response.Content.ReadAsStringAsync();

            var responseEnrollment = JsonConvert.DeserializeObject <Enrollment>(responseString);

            Assert.NotNull(responseEnrollment);
            Assert.Equal(enrollment.Id, responseEnrollment.Id);
            Assert.Equal(enrollment.ChildId, responseEnrollment.ChildId);
            Assert.NotNull(responseEnrollment.Child);
            Assert.Equal(enrollment.ChildId, responseEnrollment.Child.Id);
            Assert.Equal(enrollment.Child.FirstName, responseEnrollment.Child.FirstName);
            Assert.Equal(enrollment.Child.MiddleName, responseEnrollment.Child.MiddleName);
            Assert.Equal(enrollment.Child.LastName, responseEnrollment.Child.LastName);
            Assert.Empty(responseEnrollment.Child.Enrollments);
            Assert.Equal(enrollment.SiteId, responseEnrollment.SiteId);
            Assert.NotNull(responseEnrollment.Site);
            Assert.NotNull(responseEnrollment.Site.Name);
            Assert.Empty(responseEnrollment.Site.Enrollments);
            Assert.Equal(enrollment.AgeGroup, responseEnrollment.AgeGroup);
            Assert.Equal(enrollment.Entry, responseEnrollment.Entry);
            Assert.Equal(enrollment.Exit, responseEnrollment.Exit);
            Assert.Equal(enrollment.ExitReason, responseEnrollment.ExitReason);
            Assert.All(
                responseEnrollment.Fundings,
                funding =>
            {
                Assert.NotNull(funding.FundingSpace);
                Assert.Equal(funding.FundingSpace.Time == FundingTime.Split, funding.FundingSpace.TimeSplit != null);
                Assert.NotNull(funding.Source);
                Assert.NotNull(funding.FirstReportingPeriod);
                Assert.NotNull(funding.LastReportingPeriod);
            }
                );
        }
Example #15
0
        public async Task EnrollmentControllerOrganizationSiteEnrollmentPost_AddsEnrollment_And_ReturnsCorrectResponseShape(
            string firstName,
            string lastName,
            bool isSuccess
            )
        {
            User         user;
            Organization organization;
            Site         site;

            using (var context = new TestHedwigContextProvider().Context)
            {
                organization = OrganizationHelper.CreateOrganization(context);
                site         = SiteHelper.CreateSite(context, organization: organization);
                user         = UserHelper.CreateUser(context);
                PermissionHelper.CreateSitePermission(context, user, site);
                PermissionHelper.CreateOrganizationPermission(context, user, organization);
            }

            Child child = new Child
            {
                FirstName      = firstName,
                LastName       = lastName,
                OrganizationId = organization.Id
            };
            Enrollment enrollment = new Enrollment
            {
                Child  = child,
                SiteId = site.Id
            };

            var client = _factory.CreateClient();

            var request = HedwigAPIRequests.EnrollmentPost(
                user,
                enrollment,
                organization,
                site
                );

            var response = await client.SendAsync(request);

            if (!isSuccess)
            {
                Assert.False(response.IsSuccessStatusCode);
            }
            else
            {
                response.EnsureSuccessStatusCode();

                var responseString = await response.Content.ReadAsStringAsync();

                var responseEnrollment = JsonConvert.DeserializeObject <Enrollment>(responseString);
                Assert.NotNull(responseEnrollment);
                Assert.NotNull(responseEnrollment.Child);
                Assert.Equal(enrollment.Child.FirstName, responseEnrollment.Child.FirstName);
                Assert.Equal(enrollment.Child.MiddleName, responseEnrollment.Child.MiddleName);
                Assert.Equal(enrollment.Child.LastName, responseEnrollment.Child.LastName);
                Assert.Null(responseEnrollment.Child.Family);
                Assert.Empty(responseEnrollment.Child.Enrollments);
                Assert.Equal(site.Id, responseEnrollment.SiteId);
                Assert.Null(responseEnrollment.Site);
                Assert.Equal(enrollment.AgeGroup, responseEnrollment.AgeGroup);
                Assert.Equal(enrollment.Entry, responseEnrollment.Entry);
                Assert.Equal(enrollment.Exit, responseEnrollment.Exit);
                Assert.Equal(enrollment.ExitReason, responseEnrollment.ExitReason);
                Assert.Null(responseEnrollment.Fundings);

                using (var context = new TestHedwigContextProvider().Context)
                {
                    var dbEnrollment = context.Enrollments.FirstOrDefault(
                        e => e.Id == responseEnrollment.Id
                        );
                    Assert.NotNull(dbEnrollment);
                }
            }
        }