mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add agent tests
This commit is contained in:
parent
2ceab1dc56
commit
07cfffbda2
6 changed files with 205 additions and 0 deletions
|
|
@ -40,6 +40,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{041F9CFA
|
|||
EndProject
|
||||
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{B94A5BCD-3BE3-4FE4-AE48-ADCF904A22A4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilterLists.Agent.Tests", "tests\FilterLists.Agent.Tests\FilterLists.Agent.Tests.csproj", "{CF6574D2-E056-496F-BB35-C79C324B0075}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -78,6 +80,10 @@ Global
|
|||
{B94A5BCD-3BE3-4FE4-AE48-ADCF904A22A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B94A5BCD-3BE3-4FE4-AE48-ADCF904A22A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B94A5BCD-3BE3-4FE4-AE48-ADCF904A22A4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CF6574D2-E056-496F-BB35-C79C324B0075}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CF6574D2-E056-496F-BB35-C79C324B0075}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CF6574D2-E056-496F-BB35-C79C324B0075}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CF6574D2-E056-496F-BB35-C79C324B0075}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -90,6 +96,7 @@ Global
|
|||
{4F39D132-498D-4A93-9F6C-1C604718300D} = {CE4AB25B-5501-42E9-B8B4-87B9C20472AC}
|
||||
{7D9F0D85-E906-401A-BDAD-724440B34567} = {041F9CFA-B6F7-4DEB-9441-829DE697B1BB}
|
||||
{DA34DED7-B352-4855-9C7B-9E3D983DBE2E} = {041F9CFA-B6F7-4DEB-9441-829DE697B1BB}
|
||||
{CF6574D2-E056-496F-BB35-C79C324B0075} = {041F9CFA-B6F7-4DEB-9441-829DE697B1BB}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8A31B449-52DD-4445-A9C4-033A24E25308}
|
||||
|
|
|
|||
20
docker-compose.agent.tests.yml
Normal file
20
docker-compose.agent.tests.yml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
version: "3.7"
|
||||
|
||||
services:
|
||||
api:
|
||||
image: collinbarrett/filterlists.agent:test-agent
|
||||
build:
|
||||
context: .
|
||||
dockerfile: src/FilterLists.Agent/Dockerfile
|
||||
target: test-agent
|
||||
networks:
|
||||
- test-agent
|
||||
volumes:
|
||||
- test-agent-results:/app/tests/FilterLists.Agent.Tests/TestResults
|
||||
|
||||
networks:
|
||||
test-agent:
|
||||
|
||||
volumes:
|
||||
test-agent-results:
|
||||
external: true
|
||||
|
|
@ -18,6 +18,19 @@ RUN dotnet restore
|
|||
COPY src/FilterLists.Agent/. .
|
||||
RUN dotnet build -c Release --no-restore
|
||||
|
||||
# init Agent.Tests
|
||||
FROM build AS test-agent
|
||||
ENTRYPOINT ["dotnet", "test", "--logger:trx"]
|
||||
|
||||
# restore Agent.Tests
|
||||
WORKDIR /app/tests/FilterLists.Agent.Tests
|
||||
COPY tests/FilterLists.Agent.Tests/FilterLists.Agent.Tests.csproj .
|
||||
RUN dotnet restore
|
||||
|
||||
# build Agent.Tests
|
||||
COPY tests/FilterLists.Agent.Tests/. .
|
||||
RUN dotnet build -c Release --no-restore
|
||||
|
||||
# publish
|
||||
FROM build AS publish
|
||||
RUN dotnet publish -c Release -o out --no-restore --no-build
|
||||
|
|
|
|||
49
tests/FilterLists.Agent.Tests/FilterLists.Agent.Tests.csproj
Normal file
49
tests/FilterLists.Agent.Tests/FilterLists.Agent.Tests.csproj
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Authors>Collin M. Barrett</Authors>
|
||||
<Company>Collin M. Barrett</Company>
|
||||
<Product>FilterLists</Product>
|
||||
<Description>The independent, comprehensive directory of filter and host lists for advertisements, trackers, malware, and annoyances.</Description>
|
||||
<Copyright>Copyright (c) 2019 Collin M. Barrett</Copyright>
|
||||
<PackageLicenseUrl>https://github.com/collinbarrett/FilterLists/blob/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://filterlists.com/</PackageProjectUrl>
|
||||
<PackageIconUrl>https://github.com/collinbarrett/FilterLists/raw/master/imgs/icon_filterlists.png</PackageIconUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://github.com/collinbarrett/FilterLists</RepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<CodeAnalysisRuleSet>FilterLists.Agent.Tests.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<CodeAnalysisRuleSet>FilterLists.Agent.Tests.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
|
||||
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\FilterLists.Agent\FilterLists.Agent.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RuleSet Name="Microsoft Managed Recommended Rules" Description="These rules focus on the most critical problems in your code, including potential security holes, application crashes, and other important logic and design errors. It is recommended to include this rule set in any custom rule set you create for your projects." ToolsVersion="10.0">
|
||||
<Localization ResourceAssembly="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.dll" ResourceBaseName="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.Localized">
|
||||
<Name Resource="MinimumRecommendedRules_Name" />
|
||||
<Description Resource="MinimumRecommendedRules_Description" />
|
||||
</Localization>
|
||||
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
|
||||
<Rule Id="CA1001" Action="Warning" />
|
||||
<Rule Id="CA1009" Action="Warning" />
|
||||
<Rule Id="CA1016" Action="Warning" />
|
||||
<Rule Id="CA1033" Action="Warning" />
|
||||
<Rule Id="CA1049" Action="Warning" />
|
||||
<Rule Id="CA1060" Action="Warning" />
|
||||
<Rule Id="CA1061" Action="Warning" />
|
||||
<Rule Id="CA1063" Action="Warning" />
|
||||
<Rule Id="CA1065" Action="Warning" />
|
||||
<Rule Id="CA1301" Action="Warning" />
|
||||
<Rule Id="CA1400" Action="Warning" />
|
||||
<Rule Id="CA1401" Action="Warning" />
|
||||
<Rule Id="CA1403" Action="Warning" />
|
||||
<Rule Id="CA1404" Action="Warning" />
|
||||
<Rule Id="CA1405" Action="Warning" />
|
||||
<Rule Id="CA1410" Action="Warning" />
|
||||
<Rule Id="CA1415" Action="Warning" />
|
||||
<Rule Id="CA1821" Action="Warning" />
|
||||
<Rule Id="CA1900" Action="Warning" />
|
||||
<Rule Id="CA1901" Action="Warning" />
|
||||
<Rule Id="CA2002" Action="Warning" />
|
||||
<Rule Id="CA2100" Action="Warning" />
|
||||
<Rule Id="CA2101" Action="Warning" />
|
||||
<Rule Id="CA2108" Action="Warning" />
|
||||
<Rule Id="CA2111" Action="Warning" />
|
||||
<Rule Id="CA2112" Action="Warning" />
|
||||
<Rule Id="CA2114" Action="Warning" />
|
||||
<Rule Id="CA2116" Action="Warning" />
|
||||
<Rule Id="CA2117" Action="Warning" />
|
||||
<Rule Id="CA2122" Action="Warning" />
|
||||
<Rule Id="CA2123" Action="Warning" />
|
||||
<Rule Id="CA2124" Action="Warning" />
|
||||
<Rule Id="CA2126" Action="Warning" />
|
||||
<Rule Id="CA2131" Action="Warning" />
|
||||
<Rule Id="CA2132" Action="Warning" />
|
||||
<Rule Id="CA2133" Action="Warning" />
|
||||
<Rule Id="CA2134" Action="Warning" />
|
||||
<Rule Id="CA2137" Action="Warning" />
|
||||
<Rule Id="CA2138" Action="Warning" />
|
||||
<Rule Id="CA2140" Action="Warning" />
|
||||
<Rule Id="CA2141" Action="Warning" />
|
||||
<Rule Id="CA2146" Action="Warning" />
|
||||
<Rule Id="CA2147" Action="Warning" />
|
||||
<Rule Id="CA2149" Action="Warning" />
|
||||
<Rule Id="CA2200" Action="Warning" />
|
||||
<Rule Id="CA2202" Action="Warning" />
|
||||
<Rule Id="CA2207" Action="Warning" />
|
||||
<Rule Id="CA2212" Action="Warning" />
|
||||
<Rule Id="CA2213" Action="Warning" />
|
||||
<Rule Id="CA2214" Action="Warning" />
|
||||
<Rule Id="CA2216" Action="Warning" />
|
||||
<Rule Id="CA2220" Action="Warning" />
|
||||
<Rule Id="CA2229" Action="Warning" />
|
||||
<Rule Id="CA2231" Action="Warning" />
|
||||
<Rule Id="CA2232" Action="Warning" />
|
||||
<Rule Id="CA2235" Action="Warning" />
|
||||
<Rule Id="CA2236" Action="Warning" />
|
||||
<Rule Id="CA2237" Action="Warning" />
|
||||
<Rule Id="CA2238" Action="Warning" />
|
||||
<Rule Id="CA2240" Action="Warning" />
|
||||
<Rule Id="CA2241" Action="Warning" />
|
||||
<Rule Id="CA2242" Action="Warning" />
|
||||
</Rules>
|
||||
<Rules AnalyzerId="Microsoft.CodeQuality.Analyzers" RuleNamespace="Microsoft.CodeQuality.Analyzers">
|
||||
<Rule Id="CA2007" Action="None" />
|
||||
<Rule Id="CA1707" Action="None" />
|
||||
</Rules>
|
||||
</RuleSet>
|
||||
41
tests/FilterLists.Agent.Tests/ReadOnlyListExtensionsTests.cs
Normal file
41
tests/FilterLists.Agent.Tests/ReadOnlyListExtensionsTests.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FilterLists.Agent.Extensions;
|
||||
using Xunit;
|
||||
|
||||
namespace FilterLists.Agent.Tests
|
||||
{
|
||||
public class ReadOnlyListExtensionsTests
|
||||
{
|
||||
[Fact]
|
||||
public void FirstOrDefault_WithEmptyList_ReturnsDefault()
|
||||
{
|
||||
var list = (IReadOnlyList<int>)new List<int>();
|
||||
var sut = list.FirstOrDefault();
|
||||
Assert.Equal(default, sut);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FirstOrDefault_WithMoreThanOneListElement_ReturnsFirstListElement()
|
||||
{
|
||||
var list = (IReadOnlyList<int>)new List<int> {1, 2, 3};
|
||||
var sut = list.FirstOrDefault();
|
||||
Assert.Equal(1, sut);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FirstOrDefault_WithNullParameter_ThrowsArgumentNullException()
|
||||
{
|
||||
var list = (IReadOnlyList<int>)null;
|
||||
Assert.Throws<ArgumentNullException>(() => list.FirstOrDefault());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FirstOrDefault_WithOneListElement_ReturnsFirstListElement()
|
||||
{
|
||||
var list = (IReadOnlyList<int>)new List<int> {0};
|
||||
var sut = list.FirstOrDefault();
|
||||
Assert.Equal(0, sut);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue