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
using System.Collections.Generic; | |
using System.IO; | |
using Moq; | |
using NUnit.Framework; | |
using Tdd.FrameworkWrappers.Lib.FrameworkWrappers; | |
namespace Tdd.FrameworkWrappers.Lib.Tests | |
{ | |
[TestFixture] | |
public class FileReaderTests |
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
using System.IO; | |
namespace Tdd.FrameworkWrappers.Lib.FrameworkWrappers | |
{ | |
public class FileImpl : IFile | |
{ | |
public string ReadAllText(string filePath) | |
{ | |
return File.ReadAllText(filePath); | |
} |
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
namespace Tdd.FrameworkWrappers.Lib.FrameworkWrappers | |
{ | |
public interface IFile | |
{ | |
string ReadAllText(string filePath); | |
} | |
} |
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
using System; | |
using Tdd.FrameworkWrappers.Lib.FrameworkWrappers; | |
namespace Tdd.FrameworkWrappers.Lib | |
{ | |
public class FileReader | |
{ | |
private readonly IFile file; | |
private readonly ILogger logger; |
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
using System.IO; | |
using NUnit.Framework; | |
namespace Tdd.FrameworkWrappers.Lib.Tests | |
{ | |
[TestFixture] | |
public class FileReaderTests | |
{ | |
[SetUp] | |
public void SetUp() |
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
using System.IO; | |
using System.Net; | |
namespace Tdd.FrameworkWrappers.Lib | |
{ | |
public class FileReader | |
{ | |
public string ReadText(string filePath) | |
{ | |
return File.ReadAllText(filePath); |
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
// Tree traversal using recursion in C# | |
// | |
// We want to traverse the following tree, which may be arbitrarily | |
// deep/wide. These parameters are not known until runtime. | |
// | |
// root | |
// - branch1 | |
// - leaf1 | |
// - leaf2 | |
// - branch2 |
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
bool showDebugOutput = true; | |
void Main() | |
{ | |
var data = new string[] { "A", "R", "L", "S", "T", "N", "E" }; | |
// Tell the user what's going on | |
Console.WriteLine("Unsorted Data:"); | |
DumpData(data); | |
Console.WriteLine("Sorting Data..."); |
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 code implements a wrapper around the static Path class. | |
// The interface allows us to inject a mock IPath instance at | |
// test time (for example when testing the MuchEasierToTest class). | |
public interface IPath{ | |
string GetFileName(string fileName); | |
} | |
public class PathImpl : IPath { | |
public string GetFileName(string fileName){ |