Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
49f5158
Update
PollyFFF Feb 8, 2022
8d6d0bd
Create Bubble_Sort
PollyFFF Jun 3, 2022
89aba82
Create InversionCount
PollyFFF Jun 3, 2022
15efc3c
Create MergeSort
PollyFFF Jun 3, 2022
89e4bf0
Create NumberDif
PollyFFF Jun 3, 2022
a56d219
Create PairSort
PollyFFF Jun 3, 2022
69035ec
Create RadixSort
PollyFFF Jun 3, 2022
502e92b
Create Warehouse
PollyFFF Jun 3, 2022
a014699
Create AplusB
PollyFFF Jun 3, 2022
5e27521
Create №1
PollyFFF Jun 3, 2022
47d58f5
Create №2
PollyFFF Jun 3, 2022
644b5cd
Create №3
PollyFFF Jun 3, 2022
f2b1621
Create №4
PollyFFF Jun 3, 2022
09f2299
Create Psp
PollyFFF Jun 3, 2022
a0729a5
Create SORT
PollyFFF Jun 3, 2022
0a2d839
Create NearSmall
PollyFFF Jun 3, 2022
f4aeb0f
Create MinSeg
PollyFFF Jun 3, 2022
5fdf311
Update and rename №1 to CircularStr
PollyFFF Jun 4, 2022
32f23a7
Update and rename №2 to CyclicShift
PollyFFF Jun 4, 2022
39caecb
Update and rename №3 to FindSubstr
PollyFFF Jun 4, 2022
b45969c
Update and rename №4 to PeriodStr
PollyFFF Jun 4, 2022
e7aab56
Update MinSeg
PollyFFF Jun 4, 2022
2a662d0
Update NearSmall
PollyFFF Jun 4, 2022
213c25a
Update Psp
PollyFFF Jun 4, 2022
5fd8480
Update SORT
PollyFFF Jun 4, 2022
9c810e5
Create BinarTreeBranch
PollyFFF Jun 4, 2022
ec6f07d
Create IsTreeBalanced
PollyFFF Jun 4, 2022
cc8bff6
Create Node
PollyFFF Jun 4, 2022
a38ac24
Create AplusBTest
PollyFFF Jun 4, 2022
d08a11c
Create BubbleSortTest
PollyFFF Jun 4, 2022
6e9982d
Create InversionCountTest
PollyFFF Jun 4, 2022
7b96ba9
Create MergeSortTest
PollyFFF Jun 4, 2022
53a2116
Create NumberDifTest
PollyFFF Jun 4, 2022
5c7cae6
Create PairSortTest
PollyFFF Jun 4, 2022
9656be2
Create RadixSortTest
PollyFFF Jun 4, 2022
ec6dc79
Create WarehouseTest
PollyFFF Jun 4, 2022
e24f6fe
Create CircularStrTest
PollyFFF Jun 4, 2022
fd8cb01
Create CyclingShiftTest
PollyFFF Jun 4, 2022
e2c14cd
Create FindSubstrTest
PollyFFF Jun 4, 2022
ae0fae7
Create PeriodStrTest
PollyFFF Jun 4, 2022
f28471b
Create MinSegTest
PollyFFF Jun 4, 2022
ba71e6c
Create NearSmallTest
PollyFFF Jun 4, 2022
7a9b254
Create PspTest
PollyFFF Jun 4, 2022
24ce8e8
Create SortTest
PollyFFF Jun 4, 2022
294a84a
Create BinarTreeBranchTest
PollyFFF Jun 4, 2022
ae61f1a
Create IsTreeBalancedTest
PollyFFF Jun 4, 2022
c24cec6
Delete Node
PollyFFF Jun 4, 2022
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
41 changes: 41 additions & 0 deletions CourseApp.Tests/Module_1/AplusBTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.IO;
using Xunit;
using CourseApp.Module1;

namespace CourseApp.Tests.Module1
{
[Collection("Sequential")]
public class AplusBTest : IDisposable
{
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("10 12", "22")]
[InlineData("1 1", "2")]
[InlineData("10000 10000", "20000")]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);

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

// act
AplusB.Calculate();

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
Assert.Equal($"{expected}", output[0]);
var standardOutput = new StreamWriter(Console.OpenStandardOutput());
}
}
}
50 changes: 50 additions & 0 deletions CourseApp.Tests/Module_2/BubbleSortTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
namespace CourseApp.Tests.Module2
{
using System;
using System.IO;
using CourseApp.Module2;
using Xunit;

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

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()
{
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
BubbleSort.BubbleSortMethod();

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

Assert.Equal($"{expected}", result);
}
}
}
53 changes: 53 additions & 0 deletions CourseApp.Tests/Module_2/InversionCountTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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/Module_2/MergeSortTest
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);
}
}
}
47 changes: 47 additions & 0 deletions CourseApp.Tests/Module_2/NumberDifTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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);
}
}
}

61 changes: 61 additions & 0 deletions CourseApp.Tests/Module_2/PairSortTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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