Exemplo n.º 1
0
        public void Migrate()
        {
            var chainItem1 = new Chain();

            chainItem1.SetProperties(1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1, "A", 1);
            this.context.Chains.Add(chainItem1);

            var chainStatusItem1 = new ChainStatus();

            chainStatusItem1.SetProperties(1, "A");
            this.context.ChainStatus.Add(chainStatusItem1);

            var claspItem1 = new Clasp();

            claspItem1.SetProperties(1, 1, 1);
            this.context.Clasps.Add(claspItem1);

            var linkItem1 = new Link();

            linkItem1.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1, 1, "A", 1, "A", "A", 1);
            this.context.Links.Add(linkItem1);

            var linkLogItem1 = new LinkLog();

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

            var linkStatusItem1 = new LinkStatus();

            linkStatusItem1.SetProperties(1, "A");
            this.context.LinkStatus.Add(linkStatusItem1);

            var machineItem1 = new Machine();

            machineItem1.SetProperties("A", 1, "A", "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A");
            this.context.Machines.Add(machineItem1);

            var machineRefTeamItem1 = new MachineRefTeam();

            machineRefTeamItem1.SetProperties(1, 1, 1);
            this.context.MachineRefTeams.Add(machineRefTeamItem1);

            var organizationItem1 = new Organization();

            organizationItem1.SetProperties(1, "A");
            this.context.Organizations.Add(organizationItem1);

            var teamItem1 = new Team();

            teamItem1.SetProperties(1, "A", 1);
            this.context.Teams.Add(teamItem1);

            var versionInfoItem1 = new VersionInfo();

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

            this.context.SaveChanges();
        }
Exemplo n.º 2
0
        public async virtual Task <Clasp> Create(Clasp item)
        {
            this.Context.Set <Clasp>().Add(item);
            await this.Context.SaveChangesAsync();

            this.Context.Entry(item).State = EntityState.Detached;
            return(item);
        }
Exemplo n.º 3
0
        public async void Create()
        {
            Mock <ILogger <ClaspRepository> > loggerMoc = ClaspRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClaspRepositoryMoc.GetContext();
            var repository = new ClaspRepository(loggerMoc.Object, context);

            var entity = new Clasp();
            await repository.Create(entity);

            var record = await context.Set <Clasp>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
Exemplo n.º 4
0
        public async void Get()
        {
            Mock <ILogger <ClaspRepository> > loggerMoc = ClaspRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClaspRepositoryMoc.GetContext();
            var repository = new ClaspRepository(loggerMoc.Object, context);

            Clasp entity = new Clasp();

            context.Set <Clasp>().Add(entity);
            await context.SaveChangesAsync();

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

            record.Should().NotBeNull();
        }
Exemplo n.º 5
0
        public async void Create()
        {
            Mock <ILogger <ClaspRepository> > loggerMoc = ClaspRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClaspRepositoryMoc.GetContext();
            var repository = new ClaspRepository(loggerMoc.Object, context);

            var entity = new Clasp();

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

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

            records.Count.Should().Be(2);
        }
Exemplo n.º 6
0
        public async virtual Task Delete(
            int id)
        {
            Clasp record = await this.GetById(id);

            if (record == null)
            {
                return;
            }
            else
            {
                this.Context.Set <Clasp>().Remove(record);
                await this.Context.SaveChangesAsync();
            }
        }
Exemplo n.º 7
0
        public async virtual Task Update(Clasp item)
        {
            var entity = this.Context.Set <Clasp>().Local.FirstOrDefault(x => x.Id == item.Id);

            if (entity == null)
            {
                this.Context.Set <Clasp>().Attach(item);
            }
            else
            {
                this.Context.Entry(entity).CurrentValues.SetValues(item);
            }

            await this.Context.SaveChangesAsync();
        }
Exemplo n.º 8
0
        public async void Delete()
        {
            Mock <ILogger <ClaspRepository> > loggerMoc = ClaspRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClaspRepositoryMoc.GetContext();
            var   repository             = new ClaspRepository(loggerMoc.Object, context);
            Clasp entity = new Clasp();

            context.Set <Clasp>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            Clasp modifiedRecord = await context.Set <Clasp>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
Exemplo n.º 9
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <ClaspRepository> > loggerMoc = ClaspRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClaspRepositoryMoc.GetContext();
            var   repository             = new ClaspRepository(loggerMoc.Object, context);
            Clasp entity = new Clasp();

            context.Set <Clasp>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Update(new Clasp());

            var modifiedRecord = context.Set <Clasp>().FirstOrDefaultAsync();

            modifiedRecord.Should().NotBeNull();
        }
Exemplo n.º 10
0
        public async void DeleteFound()
        {
            Mock <ILogger <ClaspRepository> > loggerMoc = ClaspRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClaspRepositoryMoc.GetContext();
            var   repository             = new ClaspRepository(loggerMoc.Object, context);
            Clasp entity = new Clasp();

            entity.SetProperties(default(int), 1, 1);
            context.Set <Clasp>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

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

            records.Count.Should().Be(1);
        }
Exemplo n.º 11
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <ClaspRepository> > loggerMoc = ClaspRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClaspRepositoryMoc.GetContext();
            var   repository             = new ClaspRepository(loggerMoc.Object, context);
            Clasp entity = new Clasp();

            entity.SetProperties(default(int), 1, 1);
            context.Set <Clasp>().Add(entity);
            await context.SaveChangesAsync();

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

            await repository.Update(entity);

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

            records.Count.Should().Be(2);
        }