MSTest is functioning , all tests green
This commit is contained in:
@ -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>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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));
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
|
||||
namespace H_Plus_Sports.Tests
|
||||
{
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
namespace H_Plus_Sports.Tests
|
||||
{
|
||||
[TestClass]
|
||||
|
||||
Reference in New Issue
Block a user