Skip to content

Commit

Permalink
Added ConsoleKihon
Browse files Browse the repository at this point in the history
  • Loading branch information
trayburn committed Jan 19, 2011
1 parent 3a54c80 commit 49c4d06
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Squire/ConsoleKihon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Squire.Framework;

namespace Squire
{
[TestClass]
public class ConsoleKihon : ConsoleKihonStructure
{
protected override void Write_FooBar_To_The_Console(Framework.Abstractions.IConsoleWrapper console)
{
throw new NotImplementedException();
}

protected override void WriteLine_FooBar_To_The_Console(Framework.Abstractions.IConsoleWrapper console)
{
throw new NotImplementedException();
}

protected override void Write_Foo_In_Blue_To_The_Console(Framework.Abstractions.IConsoleWrapper console)
{
throw new NotImplementedException();
}

protected override object Read_Line_From_Console_And_Return_Value(Framework.Abstractions.IConsoleWrapper console)
{
throw new NotImplementedException();
}
}
}
41 changes: 41 additions & 0 deletions src/Squire/Framework/Abstractions/IConsoleWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;

namespace Squire.Framework.Abstractions
{
public interface IConsoleWrapper
{
ConsoleColor ForegroundColor { get; set; }
ConsoleColor BackgroundColor { get; set; }
void Write(bool value);
void Write(char value);
void Write(char[] value);
void Write(decimal value);
void Write(double value);
void Write(int value);
void Write(long value);
void Write(object value);
void Write(float value);
void Write(string value);
void Write(string format, object value);
void Write(string format, params object[] args);
void Write(char[] buffer, int index, int count);
void WriteLine(bool value);
void WriteLine(char value);
void WriteLine(char[] value);
void WriteLine(decimal value);
void WriteLine(double value);
void WriteLine(int value);
void WriteLine(long value);
void WriteLine(object value);
void WriteLine(float value);
void WriteLine(string value);
void WriteLine(string format, object value);
void WriteLine(string format, params object[] args);
void WriteLine(char[] buffer, int index, int count);
int Read();
string ReadLine();
ConsoleKeyInfo ReadKey();
ConsoleKeyInfo ReadKey(bool intercept);
void ResetColor();
}
}
1 change: 1 addition & 0 deletions src/Squire/Framework/BaseKihon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public abstract class BaseKihon
[TestInitialize]
public void Initialize()
{
container = new WindsorContainer();
RegisterComponents(container);
BeforeEachTest();
}
Expand Down
77 changes: 77 additions & 0 deletions src/Squire/Framework/ConsoleKihonStructure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Squire.Framework.Abstractions;
using Rhino.Mocks;

namespace Squire.Framework
{
[TestClass]
public abstract class ConsoleKihonStructure : BaseKihon
{
private IConsoleWrapper console;

protected override void BeforeEachTest()
{
base.BeforeEachTest();
console = MockRepository.GenerateMock<IConsoleWrapper>();
}
[TestMethod]
public void Write_FooBar_To_The_Console()
{
// Arrange


// Act
Write_FooBar_To_The_Console(console);

// Assert
console.AssertWasCalled(c => c.Write("FooBar"));
}

[TestMethod]
public void WriteLine_FooBar_To_The_Console()
{
// Arrange


// Act
WriteLine_FooBar_To_The_Console(console);

// Assert
console.AssertWasCalled(c => c.Write("FooBar"));
}

[TestMethod]
public void Write_Foo_In_Blue_To_The_Console()
{
// Arrange


// Act
Write_Foo_In_Blue_To_The_Console(console);

// Assert
console.AssertWasCalled(c => c.ForegroundColor = ConsoleColor.Blue);
console.AssertWasCalled(c => c.Write("Foo"));
}

[TestMethod]
public void Read_Line_From_Console_And_Return_Value()
{
// Arrange
string expected = "This is a test";
console.Stub(c => c.ReadLine()).Return(expected);

// Act
var actual = Read_Line_From_Console_And_Return_Value(console);

// Assert
Assert.AreEqual(expected, actual);
}

protected abstract void Write_FooBar_To_The_Console(IConsoleWrapper console);
protected abstract void WriteLine_FooBar_To_The_Console(IConsoleWrapper console);
protected abstract void Write_Foo_In_Blue_To_The_Console(IConsoleWrapper console);
protected abstract object Read_Line_From_Console_And_Return_Value(IConsoleWrapper console);
}
}
3 changes: 3 additions & 0 deletions src/Squire/Squire.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
<Compile Include="ConsoleKihon.cs" />
<Compile Include="Framework\Abstractions\IConsoleWrapper.cs" />
<Compile Include="Framework\BaseKihon.cs" />
<Compile Include="Framework\ConsoleKihonStructure.cs" />
<Compile Include="Framework\StringKihonStructure.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StringKihon.cs" />
Expand Down

0 comments on commit 49c4d06

Please sign in to comment.