Skip to content
Open

PR #1

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;
}
}
}
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
}
}
89 changes: 89 additions & 0 deletions Markdown/Markdown.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E6825F19-EE20-40A7-AE68-22051E2AF040}</ProjectGuid>
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Markdown</RootNamespace>
<AssemblyName>Markdown</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssertions, Version=4.16.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a">
<HintPath>..\packages\FluentAssertions.4.16.0\lib\net45\FluentAssertions.dll</HintPath>
</Reference>
<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>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CssClassInfo.cs" />
<Compile Include="LineType.cs" />
<Compile Include="Md.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>
<ItemGroup>
<Content Include="packages.config" />
<Content Include="README.md" />
<Content Include="Spec.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading