Skip to content

adamfur/DSubstitute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DSubstitute

public interface IDummy
{
	public int Foo(int bar, int baz);
}

unittest
{
	auto mock = Substitute.For!IDummy;
	mock.Foo(Arg.Any!int(), Arg.Is!int((x) { return x == 3; })).Returns(13);
	auto result = mock.Foo(2, 3);

	Assert.Equals(13, result);
}

unittest
{
	auto mock = Substitute.For!IDummy;
	mock.Foo(Arg.Any!int(), Arg.Is!int((x) { return x == 3; })).Returns(13);
	mock.Foo(Arg.Any!int(), Arg.Is!int((x) { return x == 4; })).Returns(15);
	auto result = mock.Foo(2, 4);

	Assert.Equals(15, result);
}

unittest
{
	auto mock = Substitute.For!IDummy;
	mock.Foo(Arg.Any!int(), Arg.Is!int((x) { return x == 3; })).Do(() {
		throw new StringException("Go Went Gone!");
	});

	Assert.Throws!StringException(() { mock.Foo(2, 3); });
}

unittest
{
	auto mock = Substitute.For!IDummy;
	mock.Foo(Arg.Any!int(), Arg.Any!int()).Returns(15);

	mock.Foo(2, 3);
	mock.Foo(2, 5);
	mock.Received().Foo(2, 3).Twice();
}

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages