ci: 💚 Fix file structure
All checks were successful
Tests / Unit Testing1 (push) Successful in 1m1s

This commit is contained in:
Louis Gallet 2023-11-02 16:29:02 +01:00
parent 6e27660234
commit a42e51b609
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY
8 changed files with 127 additions and 2 deletions

View File

@ -0,0 +1,20 @@
name: Tests
on: push
jobs:
tests:
name: Unit Testing1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# The repo is on a custom server https://gitea.louisgallet.fr/EPITA-TP-PROG/RiderAndUnitTest.git
repository: "EPITA-TP-PROG/B2B-Training"
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
- name: "🏗️ Build"
run: dotnet build
- name: "✅ Test"
run: dotnet test

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

6
.idea/.idea.B2BEpita/.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -2,6 +2,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iteration", "Iteration\Iteration.csproj", "{57C97023-347E-42B2-B314-9509F78E84B3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{A838FD78-1D97-4191-91BF-FF439C9FB918}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -12,5 +14,9 @@ Global
{57C97023-347E-42B2-B314-9509F78E84B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57C97023-347E-42B2-B314-9509F78E84B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57C97023-347E-42B2-B314-9509F78E84B3}.Release|Any CPU.Build.0 = Release|Any CPU
{A838FD78-1D97-4191-91BF-FF439C9FB918}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A838FD78-1D97-4191-91BF-FF439C9FB918}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A838FD78-1D97-4191-91BF-FF439C9FB918}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A838FD78-1D97-4191-91BF-FF439C9FB918}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -2,5 +2,64 @@ namespace Iteration;
public class Iterations
{
public static int Reverseint(int n)
{
int result = 0;
if (n > 4)
{
for (int i = 0; i <= n; i++)
{
result = result * 10 + n % 10;
n /= 10;
}
if (n == 1)
{
return result * 10 + n;
}
}
else if (n < 4)
{
for (int i = 0; i >= n; i--)
{
result = result * 10 + n % 10;
n /= 10;
}
if (n == -1)
{
return result * 10 + n;
}
}
else
{
return n;
}
return result;
}
public static bool FindSub(string s, string sub)
{
if (sub == "")
{
throw new ArgumentException("sub cannot be empty");
}
string phrase = s;
string[] word = s.Split(' ');
foreach (var mot in word)
{
if (mot == sub)
{
return true;
}
}
return false;
}
public static bool FirstUpper(string s, string sub)
{
return true;
}
}

View File

@ -1,3 +1,3 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
Console.WriteLine();

View File

@ -2,5 +2,27 @@ namespace Tests.Interatif;
public class IterationTests
{
[Theory]
[InlineData(123, 321)]
[InlineData(1234, 4321)]
[InlineData(4, 4)]
[InlineData(-4, -4)]
[InlineData(24, 42)]
[InlineData(-123456, -654321)]
public void ReverseintTest(int n, int expected)
{
int actual = Iteration.Iterations.Reverseint(n);
Assert.Equal(expected, actual);
}
[Theory]
[InlineData("Clement est le plus beau", "moche", false)]
[InlineData("Clement est le plus beau", "beau", true)]
public void FindSubTest(string s, string sub, bool expected)
{
bool actual = Iteration.Iterations.FindSub(s, sub);
Assert.Equal(expected, actual);
}
}

View File

@ -22,4 +22,8 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Iteration\Iteration.csproj" />
</ItemGroup>
</Project>