MSTest is functioning , all tests green

This commit is contained in:
2019-12-19 23:07:09 +01:00
parent 583f57f062
commit f6d7c0a278
5 changed files with 14 additions and 12 deletions

View File

@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -24,33 +24,33 @@ namespace H_Plus_Sports.Repositories
public async Task<Order> Add(Order order)
{
await _context.Order.AddAsync(order);
await _context.SaveChangesAsync();
await _context.SaveChangesAsync().ConfigureAwait(true);
return order;
}
public async Task<Order> Find(int id)
{
return await _context.Order.Include(order => order.OrderItem).Include(order => order.Customer).SingleOrDefaultAsync(a => a.OrderId == id);
return await _context.Order.Include(order => order.OrderItem).Include(order => order.Customer).SingleOrDefaultAsync(a => a.OrderId == id).ConfigureAwait(true);
}
public async Task<Order> Remove(int id)
{
var order = _context.Order.Single(a => a.OrderId == id);
_context.Order.Remove(order);
await _context.SaveChangesAsync();
await _context.SaveChangesAsync().ConfigureAwait(true);
return order;
}
public async Task<Order> Update(Order order)
{
_context.Order.Update(order);
await _context.SaveChangesAsync();
await _context.SaveChangesAsync().ConfigureAwait(true);
return order;
}
public async Task<bool> Exists(int id)
{
return await _context.Order.AnyAsync(e => e.OrderId == id);
return await _context.Order.AnyAsync(e => e.OrderId == id).ConfigureAwait(true);
}
}
}

View File

@ -14,6 +14,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace H_Plus_Sports
{
@ -35,7 +36,10 @@ namespace H_Plus_Sports
services.AddScoped<IProductRepository, ProductRepository>();
services.AddScoped<ISalespersonRepository, SalespersonRepository>();
services.AddMvc();
services.AddMvc(option => option.EnableEndpointRouting = false)
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddNewtonsoftJson(opt => opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);
services.AddControllers();
var connection = "Server=tcp:hsportsoeman.database.windows.net,1433;Initial Catalog=H_Plus_Sports;Persist Security Info=False;User ID=saTfoman;Password=Jes@lin78;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
services.AddDbContext<H_Plus_SportsContext>(options => options.UseSqlServer(connection));