public async virtual Task <HandlerPipelineStep> Create(HandlerPipelineStep item)
        {
            this.Context.Set <HandlerPipelineStep>().Add(item);
            await this.Context.SaveChangesAsync();

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

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

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

            record.Should().NotBeNull();
        }
Esempio n. 3
0
        public async void Create()
        {
            Mock <ILogger <HandlerPipelineStepRepository> > loggerMoc = HandlerPipelineStepRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerPipelineStepRepositoryMoc.GetContext();
            var repository = new HandlerPipelineStepRepository(loggerMoc.Object, context);

            var entity = new HandlerPipelineStep();

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

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

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

            HandlerPipelineStep entity = new HandlerPipelineStep();

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

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

            record.Should().NotBeNull();
        }
        public async virtual Task Delete(
            int id)
        {
            HandlerPipelineStep record = await this.GetById(id);

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

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

            await this.Context.SaveChangesAsync();
        }
        public async void Delete()
        {
            Mock <ILogger <HandlerPipelineStepRepository> > loggerMoc = HandlerPipelineStepRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerPipelineStepRepositoryMoc.GetContext();
            var repository             = new HandlerPipelineStepRepository(loggerMoc.Object, context);
            HandlerPipelineStep entity = new HandlerPipelineStep();

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new HandlerPipelineStep());

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

            modifiedRecord.Should().NotBeNull();
        }
Esempio n. 9
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <HandlerPipelineStepRepository> > loggerMoc = HandlerPipelineStepRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerPipelineStepRepositoryMoc.GetContext();
            var repository             = new HandlerPipelineStepRepository(loggerMoc.Object, context);
            HandlerPipelineStep entity = new HandlerPipelineStep();

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

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

            await repository.Update(entity);

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

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

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

            var airTransportItem1 = new AirTransport();

            airTransportItem1.SetProperties(1, 1, "A", 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 countryItem1 = new Country();

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

            var countryRequirementItem1 = new CountryRequirement();

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

            var customerItem1 = new Customer();

            customerItem1.SetProperties(1, "A", "A", "A", "A", "A");
            this.Context.Customers.Add(customerItem1);

            var customerCommunicationItem1 = new CustomerCommunication();

            customerCommunicationItem1.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, "A");
            this.Context.CustomerCommunications.Add(customerCommunicationItem1);

            var destinationItem1 = new Destination();

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

            var employeeItem1 = new Employee();

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

            var handlerItem1 = new Handler();

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

            var handlerPipelineStepItem1 = new HandlerPipelineStep();

            handlerPipelineStepItem1.SetProperties(1, 1, 1);
            this.Context.HandlerPipelineSteps.Add(handlerPipelineStepItem1);

            var otherTransportItem1 = new OtherTransport();

            otherTransportItem1.SetProperties(1, 1, 1);
            this.Context.OtherTransports.Add(otherTransportItem1);

            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 pipelineStatusItem1 = new PipelineStatus();

            pipelineStatusItem1.SetProperties(1, "A");
            this.Context.PipelineStatus.Add(pipelineStatusItem1);

            var pipelineStepItem1 = new PipelineStep();

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

            var pipelineStepDestinationItem1 = new PipelineStepDestination();

            pipelineStepDestinationItem1.SetProperties(1, 1, 1);
            this.Context.PipelineStepDestinations.Add(pipelineStepDestinationItem1);

            var pipelineStepNoteItem1 = new PipelineStepNote();

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

            var pipelineStepStatusItem1 = new PipelineStepStatus();

            pipelineStepStatusItem1.SetProperties(1, "A");
            this.Context.PipelineStepStatus.Add(pipelineStepStatusItem1);

            var pipelineStepStepRequirementItem1 = new PipelineStepStepRequirement();

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

            var saleItem1 = new Sale();

            saleItem1.SetProperties(1, 1m, 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();
        }