-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters