Adding Tests and Refactoring
Functional Tests for RazorPages added
This commit is contained in:
@@ -69,28 +69,5 @@ namespace Microsoft.eShopWeb.Controllers
|
||||
};
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
private OrderViewModel GetOrder()
|
||||
{
|
||||
var order = new OrderViewModel()
|
||||
{
|
||||
OrderDate = DateTimeOffset.Now.AddDays(-1),
|
||||
OrderNumber = 12354,
|
||||
Status = "Submitted",
|
||||
Total = 123.45m,
|
||||
ShippingAddress = new Address("123 Main St.", "Kent", "OH", "United States", "44240")
|
||||
};
|
||||
|
||||
order.OrderItems.Add(new OrderItemViewModel()
|
||||
{
|
||||
ProductId = 1,
|
||||
PictureUrl = "",
|
||||
ProductName = "Something",
|
||||
UnitPrice = 5.05m,
|
||||
Units = 2
|
||||
});
|
||||
|
||||
return order;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,13 +31,15 @@ namespace Microsoft.eShopWeb
|
||||
public void ConfigureDevelopmentServices(IServiceCollection services)
|
||||
{
|
||||
// use in-memory database
|
||||
ConfigureTestingServices(services);
|
||||
ConfigureInMemoryDatabases(services);
|
||||
|
||||
// use real database
|
||||
// ConfigureProductionServices(services);
|
||||
|
||||
ConfigureServices(services);
|
||||
}
|
||||
public void ConfigureTestingServices(IServiceCollection services)
|
||||
|
||||
private void ConfigureInMemoryDatabases(IServiceCollection services)
|
||||
{
|
||||
// use in-memory database
|
||||
services.AddDbContext<CatalogContext>(c =>
|
||||
@@ -46,8 +48,6 @@ namespace Microsoft.eShopWeb
|
||||
// Add Identity DbContext
|
||||
services.AddDbContext<AppIdentityDbContext>(options =>
|
||||
options.UseInMemoryDatabase("Identity"));
|
||||
|
||||
ConfigureServices(services);
|
||||
}
|
||||
|
||||
public void ConfigureProductionServices(IServiceCollection services)
|
||||
@@ -86,6 +86,10 @@ namespace Microsoft.eShopWeb
|
||||
options.ExpireTimeSpan = TimeSpan.FromHours(1);
|
||||
options.LoginPath = "/Account/Signin";
|
||||
options.LogoutPath = "/Account/Signout";
|
||||
options.Cookie = new CookieBuilder
|
||||
{
|
||||
IsEssential = true // required for auth to work without explicit user consent; adjust to suit your privacy policy
|
||||
};
|
||||
});
|
||||
|
||||
services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));
|
||||
|
||||
Reference in New Issue
Block a user