This commit is contained in:
parent
6e27660234
commit
a42e51b609
@ -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
|
8
.idea/.idea.B2BEpita/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.B2BEpita/.idea/indexLayout.xml
generated
Normal 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
6
.idea/.idea.B2BEpita/.idea/vcs.xml
generated
Normal 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>
|
@ -2,6 +2,8 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iteration", "Iteration\Iteration.csproj", "{57C97023-347E-42B2-B314-9509F78E84B3}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iteration", "Iteration\Iteration.csproj", "{57C97023-347E-42B2-B314-9509F78E84B3}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{A838FD78-1D97-4191-91BF-FF439C9FB918}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{57C97023-347E-42B2-B314-9509F78E84B3}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@ -2,5 +2,64 @@ namespace Iteration;
|
|||||||
|
|
||||||
public class Iterations
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,3 +1,3 @@
|
|||||||
// See https://aka.ms/new-console-template for more information
|
// See https://aka.ms/new-console-template for more information
|
||||||
|
|
||||||
Console.WriteLine("Hello, World!");
|
Console.WriteLine();
|
@ -2,5 +2,27 @@ namespace Tests.Interatif;
|
|||||||
|
|
||||||
public class IterationTests
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
@ -22,4 +22,8 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Iteration\Iteration.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user