Exemplo n.º 1
0
        public void DeleteEnrollment_DeletesDanglingSubObjects()
        {
            using (var context = new TestHedwigContextProvider().Context)
            {
                var enrollment = new Enrollment();
                var child      = new Child();
                var funding    = new Funding();
                enrollment.Id        = 1;
                funding.Enrollment   = enrollment;
                funding.EnrollmentId = enrollment.Id;
                enrollment.Child     = child;

                var mapper = new MapperConfiguration(opts =>
                {
                    opts.AddProfile(new EnrollmentProfile());
                    opts.AddProfile(new FundingProfile());
                    opts.AddProfile(new ChildProfile());
                    opts.AddProfile(new FamilyProfile());
                    opts.AddProfile(new SiteProfile());
                }).CreateMapper();
                var enrollmentRepo = new EnrollmentRepository(context, mapper);
                var fundingRepo    = new FundingRepository(context);
                enrollmentRepo.AddEnrollment(enrollment);

                Assert.Equal(EntityState.Added, context.Entry(enrollment).State);

                enrollmentRepo.DeleteEnrollment(enrollment);

                Assert.Equal(EntityState.Detached, context.Entry(funding).State);
                Assert.Equal(EntityState.Added, context.Entry(child).State);
                Assert.Equal(EntityState.Detached, context.Entry(enrollment).State);
            }
        }
        public void DeleteEnrollment_DeletesDanglingSubObjects()
        {
            using (var context = new TestHedwigContextProvider().Context)
            {
                var enrollment = new Enrollment();
                var child      = new Child();
                var funding    = new Funding();
                enrollment.Id        = 1;
                funding.Enrollment   = enrollment;
                funding.EnrollmentId = enrollment.Id;
                enrollment.Child     = child;

                var enrollmentRepo = new EnrollmentRepository(context);
                var fundingRepo    = new FundingRepository(context);
                enrollmentRepo.AddEnrollment(enrollment);

                Assert.Equal(EntityState.Added, context.Entry(enrollment).State);

                enrollmentRepo.DeleteEnrollment(enrollment);

                Assert.Equal(EntityState.Detached, context.Entry(funding).State);
                Assert.Equal(EntityState.Added, context.Entry(child).State);
                Assert.Equal(EntityState.Detached, context.Entry(enrollment).State);
            }
        }
Exemplo n.º 3
0
        public void DeleteEnrollment()
        {
            var mapper = new MapperConfiguration(opts =>
            {
                opts.AddProfile(new EnrollmentProfile());
                opts.AddProfile(new FundingProfile());
                opts.AddProfile(new ChildProfile());
                opts.AddProfile(new FamilyProfile());
                opts.AddProfile(new SiteProfile());
            }).CreateMapper();

            using (var context = new TestHedwigContextProvider().Context)
            {
                var enrollment = new Enrollment();

                var enrollmentRepo = new EnrollmentRepository(context, mapper);
                enrollmentRepo.AddEnrollment(enrollment);

                Assert.Equal(EntityState.Added, context.Entry(enrollment).State);

                enrollmentRepo.DeleteEnrollment(enrollment);

                Assert.Equal(EntityState.Detached, context.Entry(enrollment).State);
            }
        }
        public void DeleteEnrollment()
        {
            using (var context = new TestHedwigContextProvider().Context)
            {
                var enrollment = new Enrollment();

                var enrollmentRepo = new EnrollmentRepository(context);
                enrollmentRepo.AddEnrollment(enrollment);

                Assert.Equal(EntityState.Added, context.Entry(enrollment).State);

                enrollmentRepo.DeleteEnrollment(enrollment);

                Assert.Equal(EntityState.Detached, context.Entry(enrollment).State);
            }
        }