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
110 changes: 55 additions & 55 deletions Chess/ChessProblem_Test.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
using System;
using System.IO;
using NUnit.Framework;

namespace Chess
{
[TestFixture]
public class ChessProblem_Test
{
private static void TestOnFile(string filename)
{
var board = File.ReadAllLines(filename);
ChessProblem.LoadFrom(board);
var expectedAnswer = File.ReadAllText(Path.ChangeExtension(filename, ".ans")).Trim();
ChessProblem.CalculateChessStatus();
Assert.AreEqual(expectedAnswer, ChessProblem.ChessStatus.ToString().ToLower(), "Failed test " + filename);
}

[Test]
public void RepeatedMethodCallDoNotChangeBehaviour()
{
var board = new[]
{
" ",
" ",
" ",
" q ",
" K ",
" Q ",
" ",
" ",
};
ChessProblem.LoadFrom(board);
ChessProblem.CalculateChessStatus();
Assert.AreEqual(ChessStatus.Check, ChessProblem.ChessStatus);
// Now check that internal board modifictions during the first call do not change answer
ChessProblem.CalculateChessStatus();
Assert.AreEqual(ChessStatus.Check, ChessProblem.ChessStatus);
}

[Test]
public void FullTests()
{
var dir = TestContext.CurrentContext.TestDirectory;
var testsCount = 0;
foreach (var filename in Directory.GetFiles(Path.Combine(dir, "ChessTests"), "*.in"))
{
TestOnFile(filename);
testsCount++;
}
Console.WriteLine("Tests passed: " + testsCount);
}
}
}
//using System;
//using System.IO;
//using NUnit.Framework;
//
//namespace Chess
//{
// [TestFixture]
// public class ChessProblem_Test
// {
// private static void TestOnFile(string filename)
// {
// var board = File.ReadAllLines(filename);
// ChessProblem.LoadFrom(board);
// var expectedAnswer = File.ReadAllText(Path.ChangeExtension(filename, ".ans")).Trim();
// ChessProblem.CalculateChessStatus();
// Assert.AreEqual(expectedAnswer, ChessProblem.ChessStatus.ToString().ToLower(), "Failed test " + filename);
// }
//
// [Test]
// public void RepeatedMethodCallDoNotChangeBehaviour()
// {
// var board = new[]
// {
// " ",
// " ",
// " ",
// " q ",
// " K ",
// " Q ",
// " ",
// " ",
// };
// ChessProblem.LoadFrom(board);
// ChessProblem.CalculateChessStatus();
// Assert.AreEqual(ChessStatus.Check, ChessProblem.ChessStatus);
//
// // Now check that internal board modifictions during the first call do not change answer
// ChessProblem.CalculateChessStatus();
// Assert.AreEqual(ChessStatus.Check, ChessProblem.ChessStatus);
// }
//
// [Test]
// public void FullTests()
// {
// var dir = TestContext.CurrentContext.TestDirectory;
// var testsCount = 0;
// foreach (var filename in Directory.GetFiles(Path.Combine(dir, "ChessTests"), "*.in"))
// {
// TestOnFile(filename);
// testsCount++;
// }
// Console.WriteLine("Tests passed: " + testsCount);
// }
// }
//}
82 changes: 41 additions & 41 deletions ControlDigit/ControlDigitExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,45 @@ public static int ControlDigit2(this long number)
}
}

[TestFixture]
public class ControlDigitExtensions_Tests
{
[TestCase(0, ExpectedResult = 0)]
[TestCase(1, ExpectedResult = 1)]
[TestCase(2, ExpectedResult = 2)]
[TestCase(9, ExpectedResult = 9)]
[TestCase(10, ExpectedResult = 3)]
[TestCase(15, ExpectedResult = 8)]
[TestCase(17, ExpectedResult = 1)]
[TestCase(18, ExpectedResult = 0)]
public int TestControlDigit(long x)
{
return x.ControlDigit();
}

[Test]
public void CompareImplementations()
{
for (long i = 0; i < 100000; i++)
Assert.AreEqual(i.ControlDigit(), i.ControlDigit2());
}
}

[TestFixture]
public class ControlDigit_PerformanceTests
{
[Test]
public void TestControlDigitSpeed()
{
var count = 10000000;
var sw = Stopwatch.StartNew();
for (int i = 0; i < count; i++)
12345678L.ControlDigit();
Console.WriteLine("Old " + sw.Elapsed);
sw.Restart();
for (int i = 0; i < count; i++)
12345678L.ControlDigit2();
Console.WriteLine("New " + sw.Elapsed);
}
}
// [TestFixture]
// public class ControlDigitExtensions_Tests
// {
// [TestCase(0, ExpectedResult = 0)]
// [TestCase(1, ExpectedResult = 1)]
// [TestCase(2, ExpectedResult = 2)]
// [TestCase(9, ExpectedResult = 9)]
// [TestCase(10, ExpectedResult = 3)]
// [TestCase(15, ExpectedResult = 8)]
// [TestCase(17, ExpectedResult = 1)]
// [TestCase(18, ExpectedResult = 0)]
// public int TestControlDigit(long x)
// {
// return x.ControlDigit();
// }
//
// [Test]
// public void CompareImplementations()
// {
// for (long i = 0; i < 100000; i++)
// Assert.AreEqual(i.ControlDigit(), i.ControlDigit2());
// }
// }
//
// [TestFixture]
// public class ControlDigit_PerformanceTests
// {
// [Test]
// public void TestControlDigitSpeed()
// {
// var count = 10000000;
// var sw = Stopwatch.StartNew();
// for (int i = 0; i < count; i++)
// 12345678L.ControlDigit();
// Console.WriteLine("Old " + sw.Elapsed);
// sw.Restart();
// for (int i = 0; i < count; i++)
// 12345678L.ControlDigit2();
// Console.WriteLine("New " + sw.Elapsed);
// }
// }
}
14 changes: 14 additions & 0 deletions Markdown/CssClassInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Markdown
{
public class CssClassInfo
{
public readonly string ClassName;
public readonly string Description;

public CssClassInfo(string className, string description)
{
Description = description;
ClassName = className;
}
}
}
41 changes: 0 additions & 41 deletions Markdown/HtmlToken.cs

This file was deleted.

10 changes: 10 additions & 0 deletions Markdown/LineType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Markdown
{
public enum LineType
{
Header,
CodeBlock,
OrderedList,
Simple
}
}
20 changes: 18 additions & 2 deletions Markdown/Markdown.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Markdown</RootNamespace>
<AssemblyName>Markdown</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -39,6 +40,9 @@
<Reference Include="FluentAssertions.Core, Version=4.16.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a">
<HintPath>..\packages\FluentAssertions.4.16.0\lib\net45\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>..\..\..\..\..\Library\Frameworks\Mono.framework\Versions\4.8.0\lib\mono\4.5-api\Microsoft.CSharp.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb">
<HintPath>..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
Expand All @@ -50,10 +54,22 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CssClassInfo.cs" />
<Compile Include="LineType.cs" />
<Compile Include="Md.cs" />
<Compile Include="HtmlToken.cs" />
<Compile Include="MdParserException.cs" />
<Compile Include="Program.cs" />
<Compile Include="Tag.cs" />
<Compile Include="Tokens\AHtmlToken.cs" />
<Compile Include="Tokens\CodeHtmlToken.cs" />
<Compile Include="Tokens\EmHtmlToken.cs" />
<Compile Include="Tokens\EmptyHtmlToken.cs" />
<Compile Include="Tokens\HHtmlToken.cs" />
<Compile Include="Tokens\HtmlToken.cs" />
<Compile Include="Tokens\ListItemHtmlToken.cs" />
<Compile Include="Tokens\OrderedListHtmlToken.cs" />
<Compile Include="Tokens\PHtmlToken.cs" />
<Compile Include="Tokens\StrongHtmlToken.cs" />
<Compile Include="Test\HtmlToken_Should.cs" />
<Compile Include="Test\MD_Should.cs" />
</ItemGroup>
Expand Down
Loading