This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> | |
{ | |
public DbSet<OrderItem> Orders { get; set; } | |
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } | |
protected override void OnModelCreating(ModelBuilder builder) | |
{ | |
base.OnModelCreating(builder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFrameworks>net461;netstandard20</TargetFrameworks> | |
<PackageVersion>1.0.0</PackageVersion> | |
<PackageId>Package Name</PackageId> | |
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> | |
</PropertyGroup> | |
<ItemGroup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
public IConfiguration Configuration { get; } | |
public IHostingEnvironment CurrentEnvironment { get; } | |
public Startup(IConfiguration configuration, IHostingEnvironment currentEnvironment) | |
{ | |
Configuration = configuration; | |
CurrentEnvironment = currentEnvironment; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApplicationUsersControllerGetApplicationUser | |
{ | |
private readonly ApplicationDbContext _context; | |
private readonly HttpClient _client; | |
public ApplicationUsersControllerGetApplicationUser() | |
{ | |
var builder = new WebHostBuilder() | |
.UseEnvironment("Testing") | |
.UseStartup<Startup>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Produces("application/json")] | |
[Route("api/ApplicationUsers")] | |
public class ApplicationUsersController : Controller | |
{ | |
private readonly ApplicationDbContext _context; | |
public ApplicationUsersController(ApplicationDbContext context) | |
{ | |
_context = context; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public async Task DoesReturnOk_GivenUserExists() | |
{ | |
// Arrange | |
var user = new ApplicationUser | |
{ | |
Id = "123", | |
Email = "test@test.com" | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApplicationUsersControllerGetApplicationUser | |
{ | |
private readonly ApplicationDbContext _context; | |
private readonly HttpClient _client; | |
public ApplicationUsersControllerGetApplicationUser() | |
{ | |
var builder = new WebHostBuilder() | |
.UseEnvironment("Testing") | |
.UseStartup<Startup>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApplicationUsersControllerGetApplicationUser | |
{ | |
private readonly ApplicationDbContext _context; | |
private readonly HttpClient _client; | |
public ApplicationUsersControllerGetApplicationUser() | |
{ | |
var builder = new WebHostBuilder() | |
.UseEnvironment("Testing") | |
.UseStartup<Startup>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> | |
{ | |
public DbSet<OrderItem> OrderItems { get; set; } | |
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } | |
protected override void OnModelCreating(ModelBuilder builder) | |
{ | |
base.OnModelCreating(builder); | |