diff --git a/src/Squire/ConsoleKihon.cs b/src/Squire/ConsoleKihon.cs new file mode 100644 index 0000000..9767595 --- /dev/null +++ b/src/Squire/ConsoleKihon.cs @@ -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(); + } + } +} diff --git a/src/Squire/Framework/Abstractions/IConsoleWrapper.cs b/src/Squire/Framework/Abstractions/IConsoleWrapper.cs new file mode 100644 index 0000000..3afab18 --- /dev/null +++ b/src/Squire/Framework/Abstractions/IConsoleWrapper.cs @@ -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(); + } +} \ No newline at end of file diff --git a/src/Squire/Framework/BaseKihon.cs b/src/Squire/Framework/BaseKihon.cs index fee2c04..712c06b 100644 --- a/src/Squire/Framework/BaseKihon.cs +++ b/src/Squire/Framework/BaseKihon.cs @@ -12,6 +12,7 @@ public abstract class BaseKihon [TestInitialize] public void Initialize() { + container = new WindsorContainer(); RegisterComponents(container); BeforeEachTest(); } diff --git a/src/Squire/Framework/ConsoleKihonStructure.cs b/src/Squire/Framework/ConsoleKihonStructure.cs new file mode 100644 index 0000000..efd1b06 --- /dev/null +++ b/src/Squire/Framework/ConsoleKihonStructure.cs @@ -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(); + } + [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); + } +} diff --git a/src/Squire/Squire.csproj b/src/Squire/Squire.csproj index d22274a..3fe3716 100644 --- a/src/Squire/Squire.csproj +++ b/src/Squire/Squire.csproj @@ -54,7 +54,10 @@ + + +