Skip to content

Commit e5fd342

Browse files
committed
Add tests
1 parent 12d0dfb commit e5fd342

File tree

6 files changed

+208
-20
lines changed

6 files changed

+208
-20
lines changed

Diff for: TerminalControlTests/DequeTests.cs

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace npcook.Terminal.Controls.Tests
6+
{
7+
[TestClass]
8+
public class DequeTests
9+
{
10+
[TestMethod]
11+
public void TestInsert()
12+
{
13+
Deque<int> test = new Deque<int>(10);
14+
test.Add(0);
15+
test.Add(1);
16+
test.Add(2);
17+
test.Add(3);
18+
test.Add(4);
19+
test.Add(5);
20+
test.Add(6);
21+
test.Insert(3, 7);
22+
test.Insert(3, 8);
23+
24+
CollectionAssert.AreEqual(test.ToArray(), new int[] { 0, 1, 2, 8, 7, 3, 4, 5, 6 });
25+
Assert.AreEqual(test.Count, 9);
26+
}
27+
28+
[TestMethod]
29+
public void TestRemoveAt()
30+
{
31+
Deque<int> test = new Deque<int>(10);
32+
test.Add(0);
33+
test.Add(1);
34+
test.Add(2);
35+
test.Add(3);
36+
test.Add(4);
37+
test.Add(5);
38+
test.Add(6);
39+
40+
test.RemoveAt(2);
41+
42+
CollectionAssert.AreEqual(test.ToArray(), new int[] { 0, 1, 3, 4, 5, 6 });
43+
Assert.AreEqual(test.Count, 6);
44+
}
45+
}
46+
}

Diff for: TerminalControlTests/Properties/AssemblyInfo.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("TerminalControlTests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("TerminalControlTests")]
13+
[assembly: AssemblyCopyright("Copyright © 2015")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("224bde3e-614a-4da4-8dac-3460f6ba781e")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

Diff for: TerminalControlTests/TerminalControlTests.csproj

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{224BDE3E-614A-4DA4-8DAC-3460F6BA781E}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>TerminalControlTests</RootNamespace>
10+
<AssemblyName>TerminalControlTests</AssemblyName>
11+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
15+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
17+
<IsCodedUITest>False</IsCodedUITest>
18+
<TestProjectType>UnitTest</TestProjectType>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="System" />
39+
</ItemGroup>
40+
<Choose>
41+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
42+
<ItemGroup>
43+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
44+
</ItemGroup>
45+
</When>
46+
<Otherwise>
47+
<ItemGroup>
48+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
49+
<Private>False</Private>
50+
</Reference>
51+
</ItemGroup>
52+
</Otherwise>
53+
</Choose>
54+
<ItemGroup>
55+
<Compile Include="DequeTests.cs" />
56+
<Compile Include="Properties\AssemblyInfo.cs" />
57+
</ItemGroup>
58+
<ItemGroup>
59+
<ProjectReference Include="..\TerminalControl\TerminalControl.csproj">
60+
<Project>{7ad4fe4f-3530-4f84-88d9-d122bf6fc7c5}</Project>
61+
<Name>TerminalControl</Name>
62+
</ProjectReference>
63+
</ItemGroup>
64+
<Choose>
65+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
66+
<ItemGroup>
67+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
68+
<Private>False</Private>
69+
</Reference>
70+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
71+
<Private>False</Private>
72+
</Reference>
73+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
74+
<Private>False</Private>
75+
</Reference>
76+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
77+
<Private>False</Private>
78+
</Reference>
79+
</ItemGroup>
80+
</When>
81+
</Choose>
82+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
83+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
84+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
85+
Other similar extension points exist, see Microsoft.Common.targets.
86+
<Target Name="BeforeBuild">
87+
</Target>
88+
<Target Name="AfterBuild">
89+
</Target>
90+
-->
91+
</Project>

Diff for: TerminalTest/TerminalLineTests.cs

+17-5
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,32 @@ namespace npcook.Terminal.Tests
1111
[TestClass()]
1212
public class TerminalLineTests
1313
{
14+
void AssertAreEqual(TerminalRun run1, TerminalRun run2)
15+
{
16+
Assert.AreEqual(run1.Text, run2.Text);
17+
Assert.AreEqual(run1.Font, run2.Font);
18+
}
19+
1420
[TestMethod()]
1521
public void DeleteCharactersTest()
1622
{
1723
TerminalLine line = new TerminalLine();
18-
line.SetCharacters(0, new string('a', 160), new TerminalFont() { Bold = true });
19-
line.DeleteCharacters(70, 20);
24+
line.SetCharacters(0, new string('0', 4), new TerminalFont() { Foreground = Color.FromRgb(0, 0, 0) });
25+
line.SetCharacters(4, new string('1', 4), new TerminalFont() { Foreground = Color.FromRgb(1, 1, 1) });
26+
line.SetCharacters(8, new string('2', 4), new TerminalFont() { Foreground = Color.FromRgb(2, 2, 2) });
27+
line.SetCharacters(12, new string('3', 4), new TerminalFont() { Foreground = Color.FromRgb(3, 3, 3) });
28+
line.DeleteCharacters(7, 6);
2029

2130
TerminalRun[] expectedRuns = new[]
2231
{
23-
new TerminalRun(new string('a', 70), new TerminalFont() {Bold = true }),
24-
new TerminalRun(new string('a', 70), new TerminalFont() {Bold = true }),
32+
new TerminalRun(new string('0', 4), new TerminalFont() { Foreground = Color.FromRgb(0, 0, 0) }),
33+
new TerminalRun(new string('1', 3), new TerminalFont() { Foreground = Color.FromRgb(1, 1, 1) }),
34+
new TerminalRun(new string('3', 3), new TerminalFont() { Foreground = Color.FromRgb(3, 3, 3) }),
2535
};
2636

27-
Assert.Fail();
37+
AssertAreEqual(line.Runs[0], expectedRuns[0]);
38+
AssertAreEqual(line.Runs[1], expectedRuns[1]);
39+
AssertAreEqual(line.Runs[2], expectedRuns[2]);
2840
}
2941
}
3042
}

Diff for: TerminalTest/TerminalTest.csproj

+18-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,24 @@
5252
<ErrorReport>prompt</ErrorReport>
5353
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
5454
</PropertyGroup>
55+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
56+
<DebugSymbols>true</DebugSymbols>
57+
<OutputPath>bin\x86\Debug\</OutputPath>
58+
<DefineConstants>DEBUG;TRACE</DefineConstants>
59+
<DebugType>full</DebugType>
60+
<PlatformTarget>x86</PlatformTarget>
61+
<ErrorReport>prompt</ErrorReport>
62+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
63+
</PropertyGroup>
64+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
65+
<OutputPath>bin\x86\Release\</OutputPath>
66+
<DefineConstants>TRACE</DefineConstants>
67+
<Optimize>true</Optimize>
68+
<DebugType>pdbonly</DebugType>
69+
<PlatformTarget>x86</PlatformTarget>
70+
<ErrorReport>prompt</ErrorReport>
71+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
72+
</PropertyGroup>
5573
<ItemGroup>
5674
<Reference Include="System" />
5775
</ItemGroup>
@@ -69,7 +87,6 @@
6987
</Choose>
7088
<ItemGroup>
7189
<Compile Include="TerminalLineTests.cs" />
72-
<Compile Include="UnitTest1.cs" />
7390
<Compile Include="Properties\AssemblyInfo.cs" />
7491
</ItemGroup>
7592
<ItemGroup>

Diff for: TerminalTest/UnitTest1.cs

-14
This file was deleted.

0 commit comments

Comments
 (0)