Skip to content

Instantly share code, notes, and snippets.

View ThomasArdal's full-sized avatar
🎢

Thomas Ardal ThomasArdal

🎢
View GitHub Profile
@ThomasArdal
ThomasArdal / gist:4563160
Created January 18, 2013 08:29
A test using callbacks instead of Verify from Moq.
[Test]
public void SomeTest() {
// Arrange
var mock = new Mock<IDependency>();
string string1 = null;
string string2 = null;
mock
.Setup(x => x.AMethodCall(It.IsAny<string>(), It.IsAny<string>()))
.Callback<string, string>((s1, s2) =>
{
@ThomasArdal
ThomasArdal / gist:4562879
Last active December 11, 2015 06:58
A test using the Verify-method of Moq.
[Test]
public void SomeTest() {
// Arrange
var mock = new Mock<IDependency>();
var sut = new ServiceUnderTest(mock.Object);
// Act
sut.DoIt();
// Assert
@ThomasArdal
ThomasArdal / gist:3183580
Created July 26, 2012 18:09
A bit more advanced AutoFixture usage
var fixture = new Fixture();
var model =
fixture
.Build<MyModel>()
.Without(x => x.Id)
.CreateAnonymous();
@ThomasArdal
ThomasArdal / gist:3183569
Created July 26, 2012 18:07
Simple AutoFixture usage
var fixture = new Fixture();
var model = fixture.CreateAnonymous<MyModel>();