public async virtual Task <PipelineStepDestination> Create(PipelineStepDestination item) { this.Context.Set <PipelineStepDestination>().Add(item); await this.Context.SaveChangesAsync(); this.Context.Entry(item).State = EntityState.Detached; return(item); }
public async void Create() { Mock <ILogger <PipelineStepDestinationRepository> > loggerMoc = PipelineStepDestinationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PipelineStepDestinationRepositoryMoc.GetContext(); var repository = new PipelineStepDestinationRepository(loggerMoc.Object, context); var entity = new PipelineStepDestination(); await repository.Create(entity); var record = await context.Set <PipelineStepDestination>().FirstOrDefaultAsync(); record.Should().NotBeNull(); }
public async void Get() { Mock <ILogger <PipelineStepDestinationRepository> > loggerMoc = PipelineStepDestinationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PipelineStepDestinationRepositoryMoc.GetContext(); var repository = new PipelineStepDestinationRepository(loggerMoc.Object, context); PipelineStepDestination entity = new PipelineStepDestination(); context.Set <PipelineStepDestination>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async virtual Task Delete( int id) { PipelineStepDestination record = await this.GetById(id); if (record == null) { return; } else { this.Context.Set <PipelineStepDestination>().Remove(record); await this.Context.SaveChangesAsync(); } }
public async virtual Task Update(PipelineStepDestination item) { var entity = this.Context.Set <PipelineStepDestination>().Local.FirstOrDefault(x => x.Id == item.Id); if (entity == null) { this.Context.Set <PipelineStepDestination>().Attach(item); } else { this.Context.Entry(entity).CurrentValues.SetValues(item); } await this.Context.SaveChangesAsync(); }
public async void Create() { Mock <ILogger <PipelineStepDestinationRepository> > loggerMoc = PipelineStepDestinationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PipelineStepDestinationRepositoryMoc.GetContext(); var repository = new PipelineStepDestinationRepository(loggerMoc.Object, context); var entity = new PipelineStepDestination(); entity.SetProperties(default(int), 1, 1); await repository.Create(entity); var records = await context.Set <PipelineStepDestination>().ToListAsync(); records.Count.Should().Be(2); }
public async void Delete() { Mock <ILogger <PipelineStepDestinationRepository> > loggerMoc = PipelineStepDestinationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PipelineStepDestinationRepositoryMoc.GetContext(); var repository = new PipelineStepDestinationRepository(loggerMoc.Object, context); PipelineStepDestination entity = new PipelineStepDestination(); context.Set <PipelineStepDestination>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); PipelineStepDestination modifiedRecord = await context.Set <PipelineStepDestination>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <PipelineStepDestinationRepository> > loggerMoc = PipelineStepDestinationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PipelineStepDestinationRepositoryMoc.GetContext(); var repository = new PipelineStepDestinationRepository(loggerMoc.Object, context); PipelineStepDestination entity = new PipelineStepDestination(); context.Set <PipelineStepDestination>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new PipelineStepDestination()); var modifiedRecord = context.Set <PipelineStepDestination>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <PipelineStepDestinationRepository> > loggerMoc = PipelineStepDestinationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PipelineStepDestinationRepositoryMoc.GetContext(); var repository = new PipelineStepDestinationRepository(loggerMoc.Object, context); PipelineStepDestination entity = new PipelineStepDestination(); entity.SetProperties(default(int), 1, 1); context.Set <PipelineStepDestination>().Add(entity); await context.SaveChangesAsync(); context.Entry(entity).State = EntityState.Detached; await repository.Update(entity); var records = await context.Set <PipelineStepDestination>().ToListAsync(); records.Count.Should().Be(2); }
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(); }