示例#1
0
 public BranchContactRepository(CablePortalAppDataContext dbContext)
     : base(dbContext)
 {
 }
 public CompanyRepository(CablePortalAppDataContext dbContext)
     : base(dbContext)
 {
 }
        public RequestStatusRepository(CablePortalAppDataContext dbContext)
            : base(dbContext)
        {

        }
示例#4
0
 public GenericRepository(CablePortalAppDataContext dbContext)
     : base(dbContext)
 {
 }
示例#5
0
 public UserRepository(CablePortalAppDataContext dbContext)
     : base(dbContext)
 {
 }
示例#6
0
        public async Task InitializeAsync()
        {
            lock (_lock)
            {
                var builder = new ConfigurationBuilder()
                              .AddJsonFile("appsettings.json", optional: true);

                var configuration = builder.Build();

                IWebHostBuilder webHostBuild =
                    WebHost.CreateDefaultBuilder()
                    .UseStartup <TestStartUp>()
                    .UseWebRoot(Directory.GetCurrentDirectory())
                    .UseContentRoot(Directory.GetCurrentDirectory());

                var cableDbConnectionString = configuration.GetConnectionString("cpdb");
                var dbConnectionString      = configuration.GetConnectionString("db");

                if (string.IsNullOrWhiteSpace(cableDbConnectionString) || string.IsNullOrWhiteSpace(dbConnectionString))
                {
                    throw new ApplicationException("Missing the connection string to database");
                }
                ;
                webHostBuild.ConfigureServices(service =>
                {
                    service.AddDbContextPool <CablePortalAppDataContext>(ctxOptions =>
                    {
                        ctxOptions.UseInMemoryDatabase(cableDbConnectionString).EnableSensitiveDataLogging();
                        ctxOptions.ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning));
                    });
                    service.AddDbContextPool <AppDataContext>(ctxOptions =>
                    {
                        ctxOptions.UseInMemoryDatabase(dbConnectionString).EnableSensitiveDataLogging();
                        ctxOptions.ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning));
                    });
                    service.Configure <UserLoginOption>(options => configuration.Bind("TestUserCredential", options));
                    service.AddScoped <IHttpServiceTest, HttpServiceTest>();
                    string azureStorageConnectionString = configuration["connectionStrings:storageAccount"];

                    if (!CloudStorageAccount.TryParse(azureStorageConnectionString, out CloudStorageAccount storageAccount))
                    {
                        throw new ApplicationException("Missing Azure Blob Storage settings");
                    }
                    var blobStorageClient = storageAccount.CreateCloudBlobClient();
                    _cloudBlobContainer   = blobStorageClient.GetContainerReference(DefaultCompanyId.ToString());
                    if (_cloudBlobContainer == null)
                    {
                        throw new ApplicationException("Blob container not exist");
                    }
                });
                TestServer     = new TestServer(webHostBuild);
                CableDbContext = TestServer.Host.Services.GetRequiredService <CablePortalAppDataContext>();
                DbContext      = TestServer.Host.Services.GetRequiredService <AppDataContext>();
                TestSeed       = TestServer.Host.Services.GetRequiredService <TestSeed>();
                HttpClient     = TestServer.CreateClient();
                Fixture        = new Fixture();
                Fixture.Customizations.Add(new IgnoreVirtualMembers());

                _userLogin      = TestServer.Host.Services.GetRequiredService <IOptions <UserLoginOption> >()?.Value;
                HttpServiceTest = TestServer.Host.Services.GetRequiredService <IHttpServiceTest>();
            }
            AdminToken = await HttpServiceTest.GetAuthorizationToken(_userLogin);

            AdminProfile = await HttpServiceTest.GetUserProfile(AdminToken);
        }