protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.UseEnvironment("Testing"); builder.ConfigureServices(services => { services.AddEntityFrameworkInMemoryDatabase(); var provider = services .AddEntityFrameworkInMemoryDatabase() .BuildServiceProvider(); services.AddDbContext <ClarityContext>(options => { options.UseInMemoryDatabase($"InMemoryDbForTesting-{Guid.NewGuid()}"); options.UseInternalServiceProvider(provider); }); var serviceProvider = services.BuildServiceProvider(); var scope = serviceProvider.CreateScope(); var scopedServices = scope.ServiceProvider; Context = scopedServices.GetRequiredService <ClarityContext>(); Context.Database.EnsureCreated(); SeedData.Seed(Context); }); }
public static void Seed(ClarityContext context, IConfiguration configuration) { BoardConfiguration.Seed(context, configuration); StateConfiguration.Seed(context, configuration); TeamMemberConfiguration.Seed(context, configuration); UserConfiguration.Seed(context, configuration); }
public static void Seed(ClarityContext context) { new string[1] { "Default", }.ForEach(name => { if (context.Boards.SingleOrDefault(x => x.Name == name) == null) { context.Boards.Add(new(name)); } }); context.SaveChanges(); }
public static ClarityContext WithDefaults(string databaseName) { var dbContextOptions = new DbContextOptionsBuilder() .UseInMemoryDatabase(databaseName) .Options; var context = new ClarityContext(dbContextOptions); SeedData.Seed(context); context.ChangeTracker.Clear(); return(context); }
public static void Seed(ClarityContext context, IConfiguration configuration) { var order = 0; new string[12] { "Backlog", "Analysis", "Analysis Done", "Selected", "Research", "UX", "Read for Dev", "In Progress", "QA Ready", "Testing", "Deployment", "Done" }.ForEach(name => { if (context.States.SingleOrDefault(x => x.Name == name) == null) { context.States.Add(new State { Name = name, Order = order++, BoardId = 1 }); } }); order = 0; new string[3] { "Backlog", "In Progress", "Done" }.ForEach(name => { if (context.States.SingleOrDefault(x => x.Name == name) == null) { context.States.Add(new State { Name = name, Order = order++, BoardId = 2 }); } }); context.SaveChanges(); }
public static void Seed(ClarityContext context) { var order = 0; var board = context.Boards.Single(x => x.Name == "Default"); Enum.GetValues <StateType>().ForEach(type => { if (context.BoardStates.SingleOrDefault(x => x.Type == type) == null) { context.BoardStates.Add(new(type, order++, board.BoardId)); } }); context.SaveChanges(); }
public static void Seed(ClarityContext context, IConfiguration configuration) { new string[2] { "General", "Training" }.ForEach(name => { if (context.Boards.SingleOrDefault(x => x.Name == name) == null) { context.Boards.Add(new Board { Name = name, }); } }); context.SaveChanges(); }
public static void Seed(ClarityContext context, IConfiguration configuration) { new TeamMember[3] { new TeamMember { Name = "Quinntyne" }, new TeamMember { Name = "Vanessa" }, new TeamMember { Name = "Patrick" } }.ForEach(teamMember => { if (context.TeamMembers.SingleOrDefault(x => x.Name == teamMember.Name) == null) { context.TeamMembers.Add(teamMember); } }); context.SaveChanges(); }
public static void Seed(ClarityContext context, IConfiguration configuration) { new User[3] { new User { Username = "******" }, new User { Username = "******" }, new User { Username = "******" } }.ForEach(user => { if (context.Users.SingleOrDefault(x => x.Username == user.Username) == null) { user.Password = new PasswordHasher().HashPassword(user.Salt, "P@ssw0rd"); context.Users.Add(user); } }); context.SaveChanges(); }
public static void Seed(ClarityContext context) { new TeamMember[1] { new ("Quinntyne"), }.ForEach(teamMember =>
public ClarityContextBuilder(string databaseName) { _clarityContext = WithDefaults(databaseName); }