Exemple #1
0
        public async void Create()
        {
            Mock <ILogger <SpaceRepository> > loggerMoc = SpaceRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceRepositoryMoc.GetContext();
            var repository = new SpaceRepository(loggerMoc.Object, context);

            var entity = new Space();

            entity.SetProperties(default(int), "B", "B");
            await repository.Create(entity);

            var records = await context.Set <Space>().ToListAsync();

            records.Count.Should().Be(2);
        }
Exemple #2
0
        public async void Get()
        {
            Mock <ILogger <SpaceRepository> > loggerMoc = SpaceRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceRepositoryMoc.GetContext();
            var repository = new SpaceRepository(loggerMoc.Object, context);

            Space entity = new Space();

            entity.SetProperties(default(int), "B", "B");
            context.Set <Space>().Add(entity);
            await context.SaveChangesAsync();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
Exemple #3
0
        public async void DeleteFound()
        {
            Mock <ILogger <SpaceRepository> > loggerMoc = SpaceRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceRepositoryMoc.GetContext();
            var   repository             = new SpaceRepository(loggerMoc.Object, context);
            Space entity = new Space();

            entity.SetProperties(default(int), "B", "B");
            context.Set <Space>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            var records = await context.Set <Space>().ToListAsync();

            records.Count.Should().Be(1);
        }
Exemple #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SpaceRepository> > loggerMoc = SpaceRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceRepositoryMoc.GetContext();
            var   repository             = new SpaceRepository(loggerMoc.Object, context);
            Space entity = new Space();

            entity.SetProperties(default(int), "B", "B");
            context.Set <Space>().Add(entity);
            await context.SaveChangesAsync();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

            var records = await context.Set <Space>().ToListAsync();

            records.Count.Should().Be(2);
        }
        public async void Migrate()
        {
            var adminItem1 = new Admin();

            adminItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", 1, "A", "A", 1);
            this.context.Admins.Add(adminItem1);

            var eventItem1 = new Event();

            eventItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), 1m, 1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A");
            this.context.Events.Add(eventItem1);

            var eventStatusItem1 = new EventStatus();

            eventStatusItem1.SetProperties(1, "A");
            this.context.EventStatuses.Add(eventStatusItem1);

            var familyItem1 = new Family();

            familyItem1.SetProperties(1, "A", "A", "A", "A", "A");
            this.context.Families.Add(familyItem1);

            var rateItem1 = new Rate();

            rateItem1.SetProperties(1m, 1, 1, 1);
            this.context.Rates.Add(rateItem1);

            var spaceItem1 = new Space();

            spaceItem1.SetProperties("A", 1, "A");
            this.context.Spaces.Add(spaceItem1);

            var spaceFeatureItem1 = new SpaceFeature();

            spaceFeatureItem1.SetProperties(1, "A");
            this.context.SpaceFeatures.Add(spaceFeatureItem1);

            var studentItem1 = new Student();

            studentItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), "A", true, 1, "A", 1, true, "A", "A", true, 1);
            this.context.Students.Add(studentItem1);

            var studioItem1 = new Studio();

            studioItem1.SetProperties("A", "A", "A", 1, "A", "A", "A", "A");
            this.context.Studios.Add(studioItem1);

            var teacherItem1 = new Teacher();

            teacherItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", 1, "A", "A", 1);
            this.context.Teachers.Add(teacherItem1);

            var teacherSkillItem1 = new TeacherSkill();

            teacherSkillItem1.SetProperties(1, "A");
            this.context.TeacherSkills.Add(teacherSkillItem1);

            var tenantItem1 = new Tenant();

            tenantItem1.SetProperties(1, "A");
            this.context.Tenants.Add(tenantItem1);

            var userItem1 = new User();

            userItem1.SetProperties(1, "A", "A");
            this.context.Users.Add(userItem1);

            var vEventItem1 = new VEvent();

            vEventItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), 1m, 1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"));
            this.context.VEvents.Add(vEventItem1);

            await this.context.SaveChangesAsync();
        }