Add test API & Update EFManager
continuous-integration/drone/push Build is failing Details

master
Louwar 2 years ago
parent 4fcaec1f44
commit d4f6fdad0e

@ -1,6 +1,6 @@
using EFlib; using EFlib;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens; using System.Linq;
using Model; using Model;
namespace EFManager namespace EFManager
@ -19,101 +19,44 @@ namespace EFManager
return item; return item;
} }
public Task<bool> DeleteItem(Champion? item) public async Task<bool> DeleteItem(Champion? item)
{ {
if (item == null) if (item == null)
return false; return false;
await context.Remove(item.toEF()); context.Remove(item.toEF());
await context.SaveChangesAsync(); await context.SaveChangesAsync();
return true; return true;
} }
public Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) public Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
IQueryable<Champion> query = Champions.Skip(index).Take(count); throw new NotImplementedException();
if (!string.IsNullOrEmpty(orderingPropertyName))
{
query = descending ?
query.OrderByDescending(c => EF.Property<object>(c, orderingPropertyName)) :
query.OrderBy(c => EF.Property<object>(c, orderingPropertyName));
}
return await query.ToListAsync();
} }
public Task<IEnumerable<Champion?>> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false) public Task<IEnumerable<Champion?>> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
IQueryable<Champion> query = Champions throw new NotImplementedException();
.Where(c => c.Characteristics.ContainsKey(charName))
.Skip(index)
.Take(count);
if (!string.IsNullOrEmpty(orderingPropertyName))
{
query = descending ?
query.OrderByDescending(c => EF.Property<object>(c, orderingPropertyName)) :
query.OrderBy(c => EF.Property<object>(c, orderingPropertyName));
}
return await query.ToListAsync();
} }
public Task<IEnumerable<Champion?>> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false) public Task<IEnumerable<Champion?>> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
IQueryable<Champion> query = Champions throw new NotImplementedException();
.Where(c => c.Class == championClass)
.Skip(index)
.Take(count);
if (!string.IsNullOrEmpty(orderingPropertyName))
{
query = descending ?
query.OrderByDescending(c => EF.Property<object>(c, orderingPropertyName)) :
query.OrderBy(c => EF.Property<object>(c, orderingPropertyName));
}
return await query.ToListAsync();
} }
public Task<IEnumerable<Champion?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) public Task<IEnumerable<Champion?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
IQueryable<Champion> query = Champions throw new NotImplementedException();
.Where(c => c.Name.Contains(substring))
.Skip(index)
.Take(count);
if (!string.IsNullOrEmpty(orderingPropertyName))
{
query = descending ?
query.OrderByDescending(c => EF.Property<object>(c, orderingPropertyName)) :
query.OrderBy(c => EF.Property<object>(c, orderingPropertyName));
}
return await query.ToListAsync();
} }
public Task<IEnumerable<Champion?>> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false) public Task<IEnumerable<Champion?>> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
IQueryable<Champion> query = Champions; throw new NotImplementedException();
if (runePage != null)
{
query = query.Where(c => c.RunePageId == runePage.Id);
}
query = query.Skip(index).Take(count);
if (!string.IsNullOrEmpty(orderingPropertyName))
{
query = descending ?
query.OrderByDescending(c => EF.Property<object>(c, orderingPropertyName)) :
query.OrderBy(c => EF.Property<object>(c, orderingPropertyName));
}
return await query.ToListAsync();
} }
public Task<IEnumerable<Champion?>> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false) public Task<IEnumerable<Champion?>> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
@ -131,9 +74,9 @@ namespace EFManager
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<int> GetNbItemsByCharacteristic(string charName) public async Task<int> GetNbItemsByCharacteristic(string charName)
{ {
return await context.Where(c => c.Characteristics.Any(ch => ch.Name == charName)).CountAsync(); throw new NotImplementedException();
} }
public Task<int> GetNbItemsByClass(ChampionClass championClass) public Task<int> GetNbItemsByClass(ChampionClass championClass)

@ -33,6 +33,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFManager", "EFManager\EFMa
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestManagerEF", "Tests\TestManagerEF\TestManagerEF.csproj", "{ECD6BA04-7338-4AFA-AC4B-D5C60C440D4D}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestManagerEF", "Tests\TestManagerEF\TestManagerEF.csproj", "{ECD6BA04-7338-4AFA-AC4B-D5C60C440D4D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAPI", "TestAPI\TestAPI.csproj", "{F7B6A3D6-6C70-49DC-9D1D-4B70071EEF25}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -87,6 +89,10 @@ Global
{ECD6BA04-7338-4AFA-AC4B-D5C60C440D4D}.Debug|Any CPU.Build.0 = Debug|Any CPU {ECD6BA04-7338-4AFA-AC4B-D5C60C440D4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECD6BA04-7338-4AFA-AC4B-D5C60C440D4D}.Release|Any CPU.ActiveCfg = Release|Any CPU {ECD6BA04-7338-4AFA-AC4B-D5C60C440D4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECD6BA04-7338-4AFA-AC4B-D5C60C440D4D}.Release|Any CPU.Build.0 = Release|Any CPU {ECD6BA04-7338-4AFA-AC4B-D5C60C440D4D}.Release|Any CPU.Build.0 = Release|Any CPU
{F7B6A3D6-6C70-49DC-9D1D-4B70071EEF25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7B6A3D6-6C70-49DC-9D1D-4B70071EEF25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7B6A3D6-6C70-49DC-9D1D-4B70071EEF25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7B6A3D6-6C70-49DC-9D1D-4B70071EEF25}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -99,6 +105,7 @@ Global
{9807CE1D-F1CF-4CAE-9D03-CDCE14BC36F2} = {F4404CFB-A33D-448E-891C-2C8113B014E4} {9807CE1D-F1CF-4CAE-9D03-CDCE14BC36F2} = {F4404CFB-A33D-448E-891C-2C8113B014E4}
{17BA906E-798E-4E75-9D8F-D4CD8EDD7FAE} = {F4404CFB-A33D-448E-891C-2C8113B014E4} {17BA906E-798E-4E75-9D8F-D4CD8EDD7FAE} = {F4404CFB-A33D-448E-891C-2C8113B014E4}
{ECD6BA04-7338-4AFA-AC4B-D5C60C440D4D} = {3EADD82A-15CF-40CC-BF4F-82F5385676A5} {ECD6BA04-7338-4AFA-AC4B-D5C60C440D4D} = {3EADD82A-15CF-40CC-BF4F-82F5385676A5}
{F7B6A3D6-6C70-49DC-9D1D-4B70071EEF25} = {3EADD82A-15CF-40CC-BF4F-82F5385676A5}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9} SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9}

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

@ -0,0 +1,11 @@
namespace TestAPI
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
}

@ -0,0 +1 @@
global using Xunit;
Loading…
Cancel
Save