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
private Controller CreateSubject( | |
string[] names = null, | |
IDataSource dataSource = null) | |
{ | |
names = names ?? new[] { "Alice", "Bob", "Alfred" }; | |
if (dataSource == null) | |
{ | |
var mock = new Mock<IDataSource>(); | |
mock.Setup(x => x.GetNames()).Returns(names); | |
dataSource = mock.Object; |
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
internal class ControllerBuilder | |
{ | |
private IDataSource _dataSource; | |
private IEnumerable<string> _names = new[] {"Alice", "Bob", "Alfred"}; | |
public ControllerBuilder WithDataSource(IDataSource dataSource) | |
{ | |
_dataSource = dataSource; | |
return this; | |
} |
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
[Fact] | |
public void Sort_by_first_letter() | |
{ | |
// Arrange | |
var dataSource = new Mock<IDataSource>(); | |
dataSource.Setup(x => x.GetNames()).Returns(new[] {"Alice", "Bob", "Alfred"}); | |
var subject = new Controller(dataSource.Object); | |
// Act | |
subject.Filter("a"); |
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; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace GreenIcicle | |
{ | |
public class ByteArray : IEnumerable<byte> | |
{ | |
private readonly IEnumerable<byte> bytes; |
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
// Moves a directory up some levels. | |
// Can/should be changed to an extension method on DirectoryInfo. | |
private DirectoryInfo Up(DirectoryInfo directory, int levels) | |
{ | |
while (levels > 0 && directory != null) | |
{ | |
directory = directory.Parent; | |
levels--; | |
} |