Skip to content

Instantly share code, notes, and snippets.

@scottsauber
scottsauber / ApplicationUsersController.cs
Last active October 16, 2017 15:52
Full TestServer and InMemory DB Test
public class ApplicationUsersControllerGetApplicationUser
{
private readonly ApplicationDbContext _context;
private readonly HttpClient _client;
public ApplicationUsersControllerGetApplicationUser()
{
var builder = new WebHostBuilder()
.UseEnvironment("Testing")
.UseStartup<Startup>();
[Fact]
public async Task DoesReturnNotFound_GivenUserDoesNotExist()
{
// Act
var response = await _client.GetAsync($"/api/ApplicationUsers/abc"); // No users with ID abc
// Assert
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}
public class ApplicationUsersControllerGetApplicationUser
{
private readonly ApplicationDbContext _context;
private readonly HttpClient _client;
public ApplicationUsersControllerGetApplicationUser()
{
var builder = new WebHostBuilder()
.UseEnvironment("Testing")
.UseStartup<Startup>();
public class PostConfig : IEntityTypeConfiguration<Post>
{
public void Configure(EntityTypeBuilder<Post> builder)
{
builder.HasOne(p => p.Blog)
.WithOne(b => b.Posts)
.HasForeignKey(p => p.BlogId)
.HasConstraintName("ForeignKey_Post_Blog");
}
}
public class FakeUrlHelper : IUrlHelper
{
public string Action(UrlActionContext actionContext)
{
return "";
}
public string Content(string contentPath)
{
return "";
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
{
ReturnUrl = returnUrl;
if (!ModelState.IsValid)
return Page();
var user = new ApplicationUser { UserName = Input.Email, Email = Input.Email };
var result = await _userManager.CreateAsync(user, Input.Password);
"minify": {
"enabled": true,
"renameLocals": true
},
"sourceMap": false
@scottsauber
scottsauber / bundleconfig.json
Created January 17, 2018 16:02
bundleconfig.json Default Template Before
[
{
"outputFileName": "wwwroot/js/site.min.js",
"inputFiles": [
"wwwroot/js/site.js"
],
"minify": {
"enabled": true,
"renameLocals": true
},
@scottsauber
scottsauber / bundleconfig.json
Created January 17, 2018 16:03
bundleconfig.json Using Defaults
[
{
"outputFileName": "wwwroot/js/site.min.js",
"inputFiles": [
"wwwroot/js/site.js"
]
}
]
public void ConfigureServices(IServiceCollection services)
{
services.Configure<PasswordHasherOptions>(options => options.IterationCount = 100_000);
// Note: the number 100,000 is not a formal recommendation. Test the performance of your login page before changing this.
// Do what makes sense for your application, the hardware it runs on, and the hardware climate at the time when you read this.
// Other entries remove for brevity.
}