Esempio n. 1
0
        public async virtual Task <AirTransport> Create(AirTransport item)
        {
            this.Context.Set <AirTransport>().Add(item);
            await this.Context.SaveChangesAsync();

            this.Context.Entry(item).State = EntityState.Detached;
            return(item);
        }
        public async void Create()
        {
            Mock <ILogger <AirTransportRepository> > loggerMoc = AirTransportRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = AirTransportRepositoryMoc.GetContext();
            var repository = new AirTransportRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Esempio n. 3
0
        public async virtual Task Delete(
            int airlineId)
        {
            AirTransport record = await this.GetById(airlineId);

            if (record == null)
            {
                return;
            }
            else
            {
                this.Context.Set <AirTransport>().Remove(record);
                await this.Context.SaveChangesAsync();
            }
        }
Esempio n. 4
0
        public async virtual Task Update(AirTransport item)
        {
            var entity = this.Context.Set <AirTransport>().Local.FirstOrDefault(x => x.AirlineId == item.AirlineId);

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

            await this.Context.SaveChangesAsync();
        }
        public async void Get()
        {
            Mock <ILogger <AirTransportRepository> > loggerMoc = AirTransportRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = AirTransportRepositoryMoc.GetContext();
            var repository = new AirTransportRepository(loggerMoc.Object, context);

            AirTransport entity = new AirTransport();

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

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

            record.Should().NotBeNull();
        }
        public async void Create()
        {
            Mock <ILogger <AirTransportRepository> > loggerMoc = AirTransportRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = AirTransportRepositoryMoc.GetContext();
            var repository = new AirTransportRepository(loggerMoc.Object, context);

            var entity = new AirTransport();

            entity.SetProperties(default(int), 2, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, DateTime.Parse("1/1/1988 12:00:00 AM"));
            await repository.Create(entity);

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

            records.Count.Should().Be(2);
        }
        public async void Delete()
        {
            Mock <ILogger <AirTransportRepository> > loggerMoc = AirTransportRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = AirTransportRepositoryMoc.GetContext();
            var          repository      = new AirTransportRepository(loggerMoc.Object, context);
            AirTransport entity          = new AirTransport();

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

            await repository.Delete(entity.AirlineId);

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

            modifiedRecord.Should().BeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <AirTransportRepository> > loggerMoc = AirTransportRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = AirTransportRepositoryMoc.GetContext();
            var          repository      = new AirTransportRepository(loggerMoc.Object, context);
            AirTransport entity          = new AirTransport();

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

            await repository.Update(new AirTransport());

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

            modifiedRecord.Should().NotBeNull();
        }
        public async void Get()
        {
            Mock <ILogger <AirTransportRepository> > loggerMoc = AirTransportRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = AirTransportRepositoryMoc.GetContext();
            var repository = new AirTransportRepository(loggerMoc.Object, context);

            AirTransport entity = new AirTransport();

            entity.SetProperties(default(int), 2, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <AirTransport>().Add(entity);
            await context.SaveChangesAsync();

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

            record.Should().NotBeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <AirTransportRepository> > loggerMoc = AirTransportRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = AirTransportRepositoryMoc.GetContext();
            var          repository      = new AirTransportRepository(loggerMoc.Object, context);
            AirTransport entity          = new AirTransport();

            entity.SetProperties(default(int), 2, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <AirTransport>().Add(entity);
            await context.SaveChangesAsync();

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

            await repository.Update(entity);

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

            records.Count.Should().Be(2);
        }
Esempio n. 11
0
        public async void Migrate()
        {
            var airlineItem1 = new Airline();

            airlineItem1.SetProperties(1, "A");
            this.context.Airlines.Add(airlineItem1);

            var airTransportItem1 = new AirTransport();

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

            var breedItem1 = new Breed();

            breedItem1.SetProperties(1, "A", 1);
            this.context.Breeds.Add(breedItem1);

            var clientItem1 = new Client();

            clientItem1.SetProperties("A", "A", 1, "A", "A", "A");
            this.context.Clients.Add(clientItem1);

            var clientCommunicationItem1 = new ClientCommunication();

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

            var countryItem1 = new Country();

            countryItem1.SetProperties(1, "A");
            this.context.Countries.Add(countryItem1);

            var countryRequirementItem1 = new CountryRequirement();

            countryRequirementItem1.SetProperties(1, "A", 1);
            this.context.CountryRequirements.Add(countryRequirementItem1);

            var destinationItem1 = new Destination();

            destinationItem1.SetProperties(1, 1, "A", 1);
            this.context.Destinations.Add(destinationItem1);

            var employeeItem1 = new Employee();

            employeeItem1.SetProperties("A", 1, true, true, "A");
            this.context.Employees.Add(employeeItem1);

            var handlerItem1 = new Handler();

            handlerItem1.SetProperties(1, "A", "A", 1, "A", "A");
            this.context.Handlers.Add(handlerItem1);

            var petItem1 = new Pet();

            petItem1.SetProperties(1, 1, 1, "A", 1);
            this.context.Pets.Add(petItem1);

            var pipelineItem1 = new Pipeline();

            pipelineItem1.SetProperties(1, 1, 1);
            this.context.Pipelines.Add(pipelineItem1);

            var pipelineStatuItem1 = new PipelineStatu();

            pipelineStatuItem1.SetProperties(1, "A");
            this.context.PipelineStatus.Add(pipelineStatuItem1);

            var pipelineStepItem1 = new PipelineStep();

            pipelineStepItem1.SetProperties(1, "A", 1, 1);
            this.context.PipelineSteps.Add(pipelineStepItem1);

            var pipelineStepNoteItem1 = new PipelineStepNote();

            pipelineStepNoteItem1.SetProperties(1, 1, "A", 1);
            this.context.PipelineStepNotes.Add(pipelineStepNoteItem1);

            var pipelineStepStatuItem1 = new PipelineStepStatu();

            pipelineStepStatuItem1.SetProperties(1, "A");
            this.context.PipelineStepStatus.Add(pipelineStepStatuItem1);

            var pipelineStepStepRequirementItem1 = new PipelineStepStepRequirement();

            pipelineStepStepRequirementItem1.SetProperties("A", 1, 1, true);
            this.context.PipelineStepStepRequirements.Add(pipelineStepStepRequirementItem1);

            var saleItem1 = new Sale();

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

            var speciesItem1 = new Species();

            speciesItem1.SetProperties(1, "A");
            this.context.Species.Add(speciesItem1);

            await this.context.SaveChangesAsync();
        }