Skip to content
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
6 changes: 6 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
image: Visual Studio 2019

build_script:
- For /R %%I in (*.sln) do dotnet test %%I

test: off
187 changes: 187 additions & 0 deletions hw3B-tree/hw3B-tree.Test/TestB-tree.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
using NUnit.Framework;

namespace Hw3B_tree.Test
{
public class Tests
{
private BTree tree;

public BTree Setup(int minimumDegreeOfTree)
{
tree = new BTree(minimumDegreeOfTree);
for (int i = 1; i < 19; ++i)
{
tree.Insert(i.ToString(), i.ToString());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно было через интерполяцию строк, tree.Insert($"{i}", $"{i}");, но дело вкуса

}
return tree;
}

[TestCase]
public void CheckInsert()
{
var tree = Setup(2);
for (int i = 1; i <= 18; ++i)
{
Assert.IsTrue(tree.Exists(i.ToString()));
}
}

[TestCase]
public void CheckGetValue()
{
var tree = Setup(2);
for (int i = 1; i <= 18; ++i)
{
Assert.AreEqual(i.ToString(), tree.GetValue(i.ToString()));
}
}

[TestCase]
public void CheckChangeValueByKey()
{
var tree = Setup(2);
tree.ChangeValueByKey("5", "ololo");
Assert.AreEqual("ololo", tree.GetValue("5"));
}

[TestCase]
public void CheckDeleteFromRoot()
{
var tree = Setup(2);
tree.Delete("8");
for (int i = 1; i <= 18; ++i)
{
if (i == 8)
{
Assert.IsFalse(tree.Exists(i.ToString()));
continue;
}
Assert.IsTrue(tree.Exists(i.ToString()));
}
}

[TestCase]
public void CheckDeleteFromLeaf()
{
var tree = Setup(2);
tree.Delete("5");
for (int i = 1; i <= 18; ++i)
{
if (i == 5)
{
Assert.IsFalse(tree.Exists(i.ToString()));
continue;
}
Assert.IsTrue(tree.Exists(i.ToString()));
}
}

[TestCase]
public void CheckDeleteFromNotLeafWithChangeRoot()
{
var tree = Setup(2);
tree.Delete("6");
for (int i = 1; i <= 18; ++i)
{
if (i == 6)
{
Assert.IsFalse(tree.Exists(i.ToString()));
continue;
}
Assert.IsTrue(tree.Exists(i.ToString()));
}
}

[TestCase]
public void CheckDeleteFromLeafWithChangeValueInLeafs()
{
var tree = Setup(2);
tree.Delete("15");
for (int i = 1; i <= 18; ++i)
{
if (i == 15)
{
Assert.IsFalse(tree.Exists(i.ToString()));
continue;
}
Assert.IsTrue(tree.Exists(i.ToString()));
}
}

[TestCase]
public void CheckInsertWithAnotherDegree()
{
var tree = Setup(4);
for (int i = 1; i <= 18; ++i)
{
Assert.IsTrue(tree.Exists(i.ToString()));
}
}

[TestCase]
public void CheckGetValueWithAnotherDegree()
{
var tree = Setup(4);
for (int i = 1; i <= 18; ++i)
{
Assert.AreEqual(i.ToString(), tree.GetValue(i.ToString()));
}
}

[TestCase]
public void CheckChangeValueByKeyWithAnotherDegree()
{
var tree = Setup(4);
tree.ChangeValueByKey("5", "ololo");
Assert.AreEqual("ololo", tree.GetValue("5"));
}

[TestCase]
public void CheckDeleteFromRootWithAnotherDegree()
{
var tree = Setup(4);
tree.Delete("8");
for (int i = 1; i <= 18; ++i)
{
if (i == 8)
{
Assert.IsFalse(tree.Exists(i.ToString()));
continue;
}
Assert.IsTrue(tree.Exists(i.ToString()));
}
}

[TestCase]
public void CheckDeleteFromLeafWithMergeLefsWithAnotherDegree()
{
var tree = Setup(4);
tree.Delete("2");
for (int i = 1; i <= 18; ++i)
{
if (i == 2)
{
Assert.IsFalse(tree.Exists(i.ToString()));
continue;
}
Assert.IsTrue(tree.Exists(i.ToString()));
}
}

This comment was marked as resolved.

[TestCase]
public void CheckDeleteFromLeafWithChangeValueInLeafsWithAnotherDegree()
{
var tree = Setup(4);
tree.Delete("10");
for (int i = 1; i <= 18; ++i)
{
if (i == 10)
{
Assert.IsFalse(tree.Exists(i.ToString()));
continue;
}
Assert.IsTrue(tree.Exists(i.ToString()));
}
}
}
}
20 changes: 20 additions & 0 deletions hw3B-tree/hw3B-tree.Test/hw3B-tree.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>hw3B_tree.Test</RootNamespace>

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

<ItemGroup>
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\hw3B-tree\Hw3B-tree.csproj" />
</ItemGroup>

</Project>
31 changes: 31 additions & 0 deletions hw3B-tree/hw3B-tree.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hw3B-tree", "hw3B-tree\Hw3B-tree.csproj", "{53642C16-3AA3-4A57-8380-46B9C2E9651E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "hw3B-tree.Test", "hw3B-tree.Test\hw3B-tree.Test.csproj", "{A2EE96D2-650B-457E-87E5-A6410F6DF06D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{53642C16-3AA3-4A57-8380-46B9C2E9651E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53642C16-3AA3-4A57-8380-46B9C2E9651E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53642C16-3AA3-4A57-8380-46B9C2E9651E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53642C16-3AA3-4A57-8380-46B9C2E9651E}.Release|Any CPU.Build.0 = Release|Any CPU
{A2EE96D2-650B-457E-87E5-A6410F6DF06D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2EE96D2-650B-457E-87E5-A6410F6DF06D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2EE96D2-650B-457E-87E5-A6410F6DF06D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2EE96D2-650B-457E-87E5-A6410F6DF06D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A28793F3-951B-4D93-BC1D-F351834FA2F5}
EndGlobalSection
EndGlobal
Loading