public TripServiceTests() { _context = InterviewContextFactory.Create(); _mapper = AutoMapperFactory.Create(); _authorizationService = new AuthorizationService(); _tripService = new TripService(_context, _mapper, _authorizationService); }
public InterviewDbContext GetDbContext(bool useSqlLite = false) { var builder = new DbContextOptionsBuilder <InterviewDbContext>(); if (useSqlLite) { builder.UseSqlite("DataSource=:memory:", x => { }); } else { builder.UseInMemoryDatabase(Guid.NewGuid().ToString()); } var dbContext = new InterviewDbContext(builder.Options); if (useSqlLite) { // SQLite needs to open connection to the DB. // Not required for in-memory-database. dbContext.Database.OpenConnection(); } dbContext.Database.EnsureCreated(); return(dbContext); }
public static InterviewDbContext Create() { var options = new DbContextOptionsBuilder <InterviewDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new InterviewDbContext(options); context.Database.EnsureCreated(); context.Artists.AddRange(new[] { new Artist { FirstName = "test", Id = 2, UserId = "123" }, new Artist { FirstName = "test2", Id = 3 }, }); context.Trips.AddRange(new[] { new Trip { Country = "test", Id = 2, UserId = "123" }, new Trip { Country = "test2", Id = 3 }, }); context.CarMakes.AddRange(new[] { new CarMake { Title = "testmake1", Id = 2 }, new CarMake { Title = "testmake2", Id = 3 }, }); context.CarModels.AddRange(new[] { new CarModel { Title = "testmodel1", Id = 2, CarMakeId = 2 }, new CarModel { Title = "testmodel2", Id = 3, CarMakeId = 3 }, }); context.Cars.AddRange(new[] { new Car { Country = "test", Id = 2, CarMakeId = 2, CarModelId = 2, UserId = "123" }, new Car { Country = "test2", Id = 3, CarMakeId = 3, CarModelId = 3 }, }); context.SaveChanges(); return(context); }
public static void SeedHostDb(InterviewDbContext context) { context.SuppressAutoSetTenantId = true; // Host seed new InitialHostDbBuilder(context).Create(); // Default tenant seed (in host database). new DefaultTenantBuilder(context).Create(); new TenantRoleAndUserBuilder(context, 1).Create(); }
public InitialHostDbBuilder(InterviewDbContext context) { _context = context; }
public RecruiterProcessTechnologiesRepository(InterviewDbContext context) : base(context) { }
public DefaultSettingsCreator(InterviewDbContext context) { _context = context; }
public InterviewsController(InterviewDbContext context) { _context = context; }
public static void Destroy(InterviewDbContext context) { context.Database.EnsureDeleted(); context.Dispose(); }
public DefaultTenantBuilder(InterviewDbContext context) { _context = context; }
public TechnologiesRepository(InterviewDbContext context) : base(context) { }
public DefaultEditionCreator(InterviewDbContext context) { _context = context; }
public ApplicantsRepository(InterviewDbContext context) : base(context) { }
public UnitOfWork(InterviewDbContext context) { _context = context ?? throw new ArgumentNullException("context"); }
public HostRoleAndUserCreator(InterviewDbContext context) { _context = context; }
/// <summary> /// Initializes a new instance of the <see cref="BaseRepository{TIdType,T}" /> class. /// </summary> /// <param name="context">The session.</param> protected BaseRepository(InterviewDbContext context) { Context = context; }
public AssetsFieldsController(InterviewDbContext dbContext) { _dbContext = dbContext; }
public DefaultLanguagesCreator(InterviewDbContext context) { _context = context; }
public TenantRoleAndUserBuilder(InterviewDbContext context, int tenantId) { _context = context; _tenantId = tenantId; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, InterviewDbContext context) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); // Shows UseCors with CorsPolicyBuilder. app.UseCors(builder => builder.WithOrigins("http://localhost:4200")); app.UseMvc(); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Interview API V1"); }); // context.Database.EnsureDeleted(); DbInitializer.Initialize(context); }
public CarMakeServiceTests() { _context = InterviewContextFactory.Create(); _mapper = AutoMapperFactory.Create(); _carMakeService = new CarMakeService(_context, _mapper); }
public InterviewsRepository(InterviewDbContext context) : base(context) { }