Skip to content

Instantly share code, notes, and snippets.

@claq2
Created July 9, 2017 03:37
Injecting external system with poor man's DI
[TestFixture]
public class DefaultIntegrationTests
{
[Test]
public void SetSomethingLabel()
{
const string response = "something";
var classA = new ClassA(new ClassB(new MockRestService { Response = response }));
var defaultPage = new _Default(classA);
defaultPage.Page_Load(this, new EventArgs());
Assert.That(defaultPage.SomethingLabel.Text, Is.EqualTo(response));
}
}
public class MockRestService : IRestService
{
public string Response { get; set; }
public string GetDataFromRestService()
{
return this.Response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment