public void Execute_DoesNotAddEnrollmentsToReport(bool reportHasEnrollmentsReference)
        {
            CdcReport report;

            using (var context = new TestHedwigContextProvider().Context)
            {
                report = ReportHelper.CreateCdcReport(context) as CdcReport;
                var site        = SiteHelper.CreateSite(context, organization: report.Organization);
                var enrollments = EnrollmentHelper.CreateEnrollments(context, 1, site: site);
                report.Enrollments = enrollments;
            }

            if (!reportHasEnrollmentsReference)
            {
                report.Enrollments = null;
            }

            using (var context = new TestHedwigContextProvider().Context)
            {
                context.Attach(report);

                var _serviceProvider = new Mock <IServiceProvider>();
                _serviceProvider.Setup(sp => sp.GetService(typeof(IEnumerable <IValidationRule <Enrollment> >)))
                .Returns(new List <IValidationRule <Enrollment> >());
                var _validator = new NonBlockingValidator(_serviceProvider.Object);
                var _reports   = new ReportRepository(context);

                // when
                var rule = new EnrollmentsAreValid(_validator, _reports);
                rule.Execute(report, new NonBlockingValidationContext());

                // then
                Assert.Equal(reportHasEnrollmentsReference, report.Enrollments != null);
            }
        }
        public async Task GetEnrollmentsForSite_ReturnsEnrollmentsWithSiteId_IncludesEntities(
            string[] include,
            bool includeFundings,
            bool includeChildren,
            bool includeFamilies,
            bool includeDeterminations
            )
        {
            int[] ids;
            int   siteId;

            using (var context = new TestHedwigContextProvider().Context)
            {
                var site        = SiteHelper.CreateSite(context);
                var enrollments = EnrollmentHelper.CreateEnrollments(context, 3, site: site);
                ids    = enrollments.Select(e => e.Id).ToArray();
                siteId = site.Id;
            }

            using (var context = new TestHedwigContextProvider().Context)
            {
                var enrollmentRepo = new EnrollmentRepository(context);
                var res            = await enrollmentRepo.GetEnrollmentsForSiteAsync(siteId, include : include);

                Assert.Equal(ids.OrderBy(id => id), res.Select(e => e.Id).OrderBy(id => id));
                Assert.Equal(includeFundings, res.TrueForAll(e => e.Fundings != null));
                Assert.Equal(includeChildren, res.TrueForAll(e => e.Child != null));
                Assert.Equal(includeFamilies, res.TrueForAll(e => e.Child != null && e.Child.Family != null));
                Assert.Equal(includeDeterminations, res.TrueForAll(e => e.Child != null && e.Child.Family != null && e.Child.Family.Determinations != null));
            }
        }