示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IWebHostEnvironment env,
            BudgetDataDbContext budgetDataDbContext,
            ComprehensiveDataDbContext comprehensiveDataDbContext)
        {
            // creates or apply migrations to the databases
            // remove this if there is an alternative migration strategy
            budgetDataDbContext.Database.Migrate();
            comprehensiveDataDbContext.Database.Migrate();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
        public async Task CanReadExternalPartyRequestByOrderIdAndRequestId()
        {
            string orderId   = "2";
            Guid   requestId = Guid.NewGuid();

            using (var addingContext = new BudgetDataDbContext(DbContextOptions))
            {
                addingContext.ExternalPartyRequest.Add(new ExternalPartyRequest(
                                                           orderId,
                                                           request: "{}")
                {
                    Operation = WarrantyCaseOperation.Verify,
                    RequestId = requestId
                });
                await addingContext.SaveChangesAsync();
            }
            using (var readingContext = new BudgetDataDbContext(DbContextOptions))
            {
                var actual = await readingContext.ExternalPartyRequest
                             .Where(req => req.OrderId == orderId)
                             .Where(req => req.RequestId == requestId)
                             .FirstOrDefaultAsync();

                Assert.Equal(orderId, actual.OrderId);
                Assert.Equal(requestId, actual.RequestId);
                Assert.Equal(WarrantyCaseOperation.Verify, actual.Operation);
                Assert.Equal(DateTimeKind.Utc, actual.DateTime.Kind);
            }
        }
示例#3
0
        public async Task InitializeAsync()
        {
            using var context = new BudgetDataDbContext(DbContextOptions);
            await context.Database.EnsureDeletedAsync();

            await context.Database.MigrateAsync();
        }
 public async Task CanAddExternalPartyResponse()
 {
     using var context = new BudgetDataDbContext(DbContextOptions);
     context.ExternalPartyResponse.Add(new ExternalPartyResponse(
                                           orderId: "1",
                                           response: "{}")
     {
         Operation = WarrantyCaseOperation.Create,
         RequestId = Guid.NewGuid()
     });
     await context.SaveChangesAsync();
 }
 public async Task CanCountExternalPartyResponse()
 {
     using var context = new BudgetDataDbContext(DbContextOptions);
     var count = await context.ExternalPartyResponse.CountAsync();
 }
 public void CanCreateAndDropDatabase()
 {
     using var context = new BudgetDataDbContext(DbContextOptions);
 }
示例#7
0
 public async Task DisposeAsync()
 {
     using var context = new BudgetDataDbContext(DbContextOptions);
     await context.Database.EnsureDeletedAsync();
 }
示例#8
0
 public BudgetDataWrapper(
     BudgetDataDbContext budgetDataDbContext)
 {
     BudgetDataDbContext = budgetDataDbContext;
 }