public ProjectStore(IMapper mapper, WavesDbContext context, ITransactionService transactionService, IProjectSearchQueryBuilder queryBuilder) { _mapper = mapper; _context = context; _transactionService = transactionService; _queryBuilder = queryBuilder; }
public void Dispose() { using (var context = new WavesDbContext(DbOptions)) { context.Database.EnsureDeleted(); } }
private IProjectStore _GetProjectStore(WavesDbContext context) { IProjectSearchQueryBuilder builder = new ProjectSearchQueryBuilder(context); ITransactionService transactionService = new TransactionService(context); return(new ProjectStore(iMapper, context, transactionService, builder)); }
public ProjectFixture() : base() { using (WavesDbContext context = new WavesDbContext(DbOptions)) { _AddTestData(context); } }
public AppUserAuthorizationService(IAuthTokenFactory tokenFactory, UserManager <AppUser> userManager, WavesDbContext context, IRolePolicyService policyService, SignInManager <AppUser> signInManager) : base(tokenFactory) { _context = context; _userManager = userManager; _policyService = policyService; _signInManager = signInManager; }
public DatabaseFixture() : base() { using (var context = new WavesDbContext(DbOptions)) { context.Database.EnsureDeleted(); context.Database.Migrate(); } }
public void Dispose() { using (var context = new WavesDbContext(DbOptions)) { context.Projects.RemoveRange(context.Projects); context.AppUsers.RemoveRange(context.AppUsers); context.AppRoles.RemoveRange(context.AppRoles); context.SaveChanges(); } }
public async Task Should_Return_Projects_Count_According_To_Filter_Parameters( ProjectSearchParametersModel parameters, Int32 expectedCount) { using (WavesDbContext context = new WavesDbContext(_fixture.DbOptions)) { IProjectStore store = _GetProjectStore(context); ItemListModel <ProjectDTO> result = await store.GetAsync(parameters); Assert.Equal(expectedCount, result.TotalCount); } }
public static void EnsureDatabaseInitialized(IServiceScope serviceScope) { WavesDbContext context = serviceScope.ServiceProvider.GetRequiredService <WavesDbContext>(); Boolean isFirstLaunch = !(context.GetService <IDatabaseCreator>() as RelationalDatabaseCreator).Exists(); context.Database.Migrate(); if (isFirstLaunch) { AddTestData(context); } context.Dispose(); }
private void _AddProjects(WavesDbContext context) { context.Database.ExecuteSqlCommand(@" SET IDENTITY_INSERT Projects ON; INSERT INTO Projects (Id, UserId, Name, IsDeleted, CreatedOn, ModifiedOn) VALUES (1, 1, 'Test', 'false', GETDATE(), GETDATE()); INSERT INTO Projects (Id, UserId, Name, IsDeleted, CreatedOn, ModifiedOn) VALUES (2, 1, 'OneMoreTest', 'true', GETDATE(), GETDATE()); INSERT INTO Projects (Id, UserId, Name, IsDeleted, CreatedOn, ModifiedOn) VALUES (3, 1, 'new project', 'true', GETDATE(), GETDATE()); INSERT INTO Projects (Id, UserId, Name, IsDeleted, CreatedOn, ModifiedOn) VALUES (4, 1, '123', 'false', GETDATE(), GETDATE()); INSERT INTO Projects (Id, UserId, Name, IsDeleted, CreatedOn, ModifiedOn) VALUES (5, 1, 'waves', 'false', GETDATE(), GETDATE()); INSERT INTO Projects (Id, UserId, Name, IsDeleted, CreatedOn, ModifiedOn) VALUES (6, 2, 'difration', 'false', GETDATE(), GETDATE()); INSERT INTO Projects (Id, UserId, Name, IsDeleted, CreatedOn, ModifiedOn) VALUES (7, 2, 'Marinara', 'false', GETDATE(), GETDATE()); SET IDENTITY_INSERT Projects OFF;"); }
private void _AddUsers(WavesDbContext context) { context.Database.ExecuteSqlCommand(@" SET IDENTITY_INSERT AppRoles ON; INSERT INTO AppRoles (Id, IsActive, Name) VALUES (1, 'true', 'Test'); INSERT INTO AppRoles (Id, IsActive, Name) VALUES (2, 'true', 'OneMoreTest'); SET IDENTITY_INSERT AppRoles OFF;"); context.Database.ExecuteSqlCommand(@" SET IDENTITY_INSERT AspNetUsers ON; INSERT INTO AspNetUsers (Id, Email, RoleId, CreatedOn, ModifiedOn, EmailConfirmed, PhoneNumberConfirmed, TwoFactorEnabled, LockoutEnabled, AccessFailedCount, IsActive) VALUES (1, '*****@*****.**', 1, GETDATE(), GETDATE(), 'false', 'false', 'false', 'false', '5', 'true'); INSERT INTO AspNetUsers (Id, Email, RoleId, CreatedOn, ModifiedOn, EmailConfirmed, PhoneNumberConfirmed, TwoFactorEnabled, LockoutEnabled, AccessFailedCount, IsActive) VALUES (2, '*****@*****.**', 2, GETDATE(), GETDATE(), 'false', 'false', 'false', 'false', '5', 'true'); SET IDENTITY_INSERT AspNetUsers OFF;"); }
public static void AddIdentityData(WavesDbContext context) { context.Database.ExecuteSqlCommand($@" SET IDENTITY_INSERT appfeatures ON; INSERT INTO appfeatures (Id, Name, Description) VALUES (1, 'FullAccess', 'Full Access'); SET IDENTITY_INSERT appfeatures OFF;"); context.Database.ExecuteSqlCommand($@" SET IDENTITY_INSERT approles ON; INSERT INTO approles (Id, Name, isActive) VALUES (1, 'SuperAdmin', 'true'); SET IDENTITY_INSERT approles OFF;"); context.Database.ExecuteSqlCommand($@" SET IDENTITY_INSERT approlefeatures ON; INSERT INTO approlefeatures (Id, CreatedOn, ModifiedOn, AppRoleId, AppFeatureId) VALUES (1, GETDATE(), GETDATE(), 1, 1); SET IDENTITY_INSERT approlefeatures OFF;"); // password for superuser: 123456 context.Database.ExecuteSqlCommand($@" SET IDENTITY_INSERT aspnetusers ON; INSERT INTO aspnetusers (Id, CreatedOn, ModifiedOn, UserName, NormalizedUserName, Email, NormalizedEmail, EmailConfirmed, PasswordHash, PhoneNumber, PhoneNumberConfirmed, TwoFactorEnabled, LockoutEnabled, AccessFailedCount, FirstName, LastName, IsActive, RoleId) VALUES (1, GETDATE(), GETDATE(), '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', 'true', 'AQAAAAEAACcQAAAAEIUEA9TSyuVATZj+snuxTMC4ZKk/jIcgJwa1M/aY/SBH1b9W4Nn7qMwLBTebRBvboA==', '123456789', 'true', 'false', 'false', '0', 'Super', 'User', 'true', '1'); SET IDENTITY_INSERT aspnetusers OFF;"); }
public UserStore(IMapper mapper, WavesDbContext context, UserManager <AppUser> userManager) { _mapper = mapper; _context = context; _userManager = userManager; }
private void _AddTestData(WavesDbContext context) { _AddUsers(context); _AddProjects(context); }
public TransactionService(WavesDbContext context) { _context = context; }
public ProjectSearchQueryBuilder(WavesDbContext context) { _context = context; }
public RolePolicyService(WavesDbContext context) { _context = context; }
public static void AddTestData(WavesDbContext context) { AddIdentityData(context); }