public IntegrationTestBase() { BuildTestConfiguration(); _dbContext = GetDbContext(); _eventDbContext = GetEventDbContext(); _testHttpContext = new DefaultHttpContext(); _httpContextAccessor = new HttpContextAccessor(); _httpContextAccessor.HttpContext = _testHttpContext; _fakeHttpContextItems = new Dictionary <object, object>(); var memoryCache = new MemoryCache(new MemoryCacheOptions() { }); var accessTokenRetriever = new TestAccessTokenRetriever(); _graphService = new MockGraphService(); _encryptionService = new EncryptionService(); _applicationIdentityService = new ApplicationIdentityService(_dbContext, _graphService, _httpContextAccessor, _fakeHttpContextItems); _eventService = new EventService(_eventDbContext, _applicationIdentityService); _permissionService = new PermissionService(_dbContext, _graphService, _eventService, _applicationIdentityService); _projectsService = new ProjectsService(_dbContext, _encryptionService, _eventService, _applicationIdentityService, _permissionService); _assetService = new AssetService(_dbContext, _projectsService, _encryptionService, _eventService, _applicationIdentityService); _testUser = _applicationIdentityService.FindUserAsync(u => u.AzureAdObjectIdentifier == "TestAdObjectId11234567890").Result; if (_testUser == null) { _testUser = new ApplicationUser() { DisplayName = "Test User 123456789", AzureAdObjectIdentifier = "TestAdObjectId11234567890", TenantId = "1234-12345-123", AzureAdName = "Test User Name", AzureAdNameIdentifier = "123123kl21j3lk12j31", Upn = "*****@*****.**", }; _dbContext.ApplicationIdentities.Add(_testUser); _dbContext.SaveChanges(); _testUser = _applicationIdentityService.FindUserAsync(u => u.AzureAdObjectIdentifier == "TestAdObjectId11234567890").Result; } }
public ApplicationIdentityServiceTests() { BuildTestConfiguration(); var memoryCache = new MemoryCache(new MemoryCacheOptions() { }); var accessTokenRetriever = new TestAccessTokenRetriever(); var telemetryService = new MockTelemetryService(); _graphService = new GraphService(memoryCache, _configuration, accessTokenRetriever, telemetryService); _testHttpContext = new DefaultHttpContext(); _httpContextAccessor = new HttpContextAccessor(); _httpContextAccessor.HttpContext = _testHttpContext; var dbContextOptionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>(); dbContextOptionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString()); _dbContext = new ApplicationDbContext(dbContextOptionsBuilder.Options, false, true, false); _applicationIdentityService = new ApplicationIdentityService(_dbContext, _graphService, _httpContextAccessor); SetApplicationUser(); }