Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aleksandr shkarpitskij #43

Open
wants to merge 22 commits into
base: Aleksandr_Shkarpitskij
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CourseApp.Tests/CourseApp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp6</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1573,1591,1701;1702;1705</NoWarn>
<IsPackable>false</IsPackable>
Expand Down
33 changes: 19 additions & 14 deletions CourseApp.Tests/Module2/BubbleSortTest.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
using System;
using System.IO;
using Xunit;
using CourseApp.Module2;

namespace CourseApp.Tests.Module2
namespace CourseApp.Tests.Module2
{
using System;
using System.IO;
using CourseApp.Module2;
using Xunit;

[Collection("Sequential")]
public class BubbleSortTest : IDisposable
{
private const string Inp1 = @"7
5 1 7 3 9 4 1";
private const string Inp1 = @"4
4 3 2 1";

private const string Inp2 = @"3
-10 7 2";
private const string Out1 = @"3 4 2 1
3 2 4 1
3 2 1 4
2 3 1 4
2 1 3 4
1 2 3 4";

public void Dispose()
{
Expand All @@ -24,8 +28,7 @@ public void Dispose()
}

[Theory]
[InlineData(Inp1, "1 1 3 4 5 7 9")]
[InlineData(Inp2, "-10 2 7")]
[InlineData(Inp1, Out1)]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Expand All @@ -39,7 +42,9 @@ public void Test1(string input, string expected)

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
Assert.Equal($"{expected}", output[0]);
var result = string.Join(Environment.NewLine, output);

Assert.Equal($"{expected}", result);
}
}
}
}
25 changes: 25 additions & 0 deletions CourseApp.Tests/Module2/BubleTest/BubleTest.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BubleTest", "BubleTest\BubleTest.csproj", "{B4D38834-5CE0-40AE-8E5F-FB02E3015602}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B4D38834-5CE0-40AE-8E5F-FB02E3015602}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B4D38834-5CE0-40AE-8E5F-FB02E3015602}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4D38834-5CE0-40AE-8E5F-FB02E3015602}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4D38834-5CE0-40AE-8E5F-FB02E3015602}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F9C25243-48C8-4F6D-936E-F81DE436D4BC}
EndGlobalSection
EndGlobal
17 changes: 17 additions & 0 deletions CourseApp.Tests/Module2/BubleTest/BubleTest/BubleTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions CourseApp.Tests/Module2/BubleTest/BubleTest/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BubleTest
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
}
52 changes: 52 additions & 0 deletions CourseApp.Tests/Module2/InversionCountTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace CourseApp.Tests.Module2
{
using System;
using System.Collections.Generic;
using System.IO;
using CourseApp.Module2;
using Xunit;

[Collection("Sequential")]
public class InversionCountTest : IDisposable
{
private const string Inp1 = @"1
1";

private const string Out1 = @"0";

private const string Inp2 = @"5
5 4 3 2 1";

private const string Out2 = @"10";

public void Dispose()
{
var standardOut = new StreamWriter(Console.OpenStandardOutput());
standardOut.AutoFlush = true;
var standardIn = new StreamReader(Console.OpenStandardInput());
Console.SetOut(standardOut);
Console.SetIn(standardIn);
}

[Theory]
[InlineData(Inp1, Out1)]
[InlineData(Inp2, Out2)]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);

var stringReader = new StringReader(input);
Console.SetIn(stringReader);

// act
InversionCount.Start();

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
var result = string.Join(Environment.NewLine, output);

Assert.Equal($"{expected}", result);
}
}
}
63 changes: 63 additions & 0 deletions CourseApp.Tests/Module2/MergeTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
namespace CourseApp.Tests.Module2
{
using System;
using System.Collections.Generic;
using System.IO;
using CourseApp.Module2;
using Xunit;

[Collection("Sequential")]
public class MergeSortTest : IDisposable
{
private const string Inp1 = @"5
5 4 3 2 1";

private const string Out1 = @"1 2 4 5
4 5 1 2
3 5 1 3
1 5 1 5
1 2 3 4 5";

private const string Inp2 = @"1
1";

private const string Out2 = @"1";

private const string Inp3 = @"2
3 1";

private const string Out3 = @"1 2 1 3
1 3";

public void Dispose()
{
var standardOut = new StreamWriter(Console.OpenStandardOutput());
standardOut.AutoFlush = true;
var standardIn = new StreamReader(Console.OpenStandardInput());
Console.SetOut(standardOut);
Console.SetIn(standardIn);
}

[Theory]
[InlineData(Inp1, Out1)]
[InlineData(Inp2, Out2)]
[InlineData(Inp3, Out3)]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);

var stringReader = new StringReader(input);
Console.SetIn(stringReader);

// act
MergeSort.MergeSortMethod();

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
var result = string.Join(Environment.NewLine, output);

Assert.Equal($"{expected}", result);
}
}
}
46 changes: 46 additions & 0 deletions CourseApp.Tests/Module2/NumberDifTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace CourseApp.Tests.Module2
{
using System;
using System.Collections.Generic;
using System.IO;
using CourseApp.Module2;
using Xunit;

[Collection("Sequential")]
public class NumberDifTest : IDisposable
{
private const string Inp1 = @"5
1 0 1 2 0";

private const string Out1 = @"3";

public void Dispose()
{
var standardOut = new StreamWriter(Console.OpenStandardOutput());
standardOut.AutoFlush = true;
var standardIn = new StreamReader(Console.OpenStandardInput());
Console.SetOut(standardOut);
Console.SetIn(standardIn);
}

[Theory]
[InlineData(Inp1, Out1)]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);

var stringReader = new StringReader(input);
Console.SetIn(stringReader);

// act
NumberDif.Count_Diff_Method();

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
var result = string.Join(Environment.NewLine, output);

Assert.Equal($"{expected}", result);
}
}
}
60 changes: 60 additions & 0 deletions CourseApp.Tests/Module2/PairSortTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
namespace CourseApp.Tests.Module2
{
using System;
using System.Collections.Generic;
using System.IO;
using CourseApp.Module2;
using Xunit;

[Collection("Sequential")]
public class PairSortTest : IDisposable
{
private const string Inp1 = @"3
20 80
30 90
25 90";

private const string Out1 = @"25 90
30 90
20 80";

private const string Inp2 = @"3
101 80
305 90
200 14";

private const string Out2 = @"305 90
101 80
200 14";

public void Dispose()
{
var standardOut = new StreamWriter(Console.OpenStandardOutput());
standardOut.AutoFlush = true;
var standardIn = new StreamReader(Console.OpenStandardInput());
Console.SetOut(standardOut);
Console.SetIn(standardIn);
}

[Theory]
[InlineData(Inp1, Out1)]
[InlineData(Inp2, Out2)]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);

var stringReader = new StringReader(input);
Console.SetIn(stringReader);

// act
PairSort.PairSortMethod();

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
var result = string.Join(Environment.NewLine, output);

Assert.Equal($"{expected}", result);
}
}
}
Loading