Skip to content

Instantly share code, notes, and snippets.

@HamidMosalla
Created September 28, 2017 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HamidMosalla/3e7072c7f1ba879cf27d3c1edf34b43d to your computer and use it in GitHub Desktop.
Save HamidMosalla/3e7072c7f1ba879cf27d3c1edf34b43d to your computer and use it in GitHub Desktop.
//Moq
var lollipop = new Mock<ICandy>();
var shop = new Mock<ICandyShop>();
shop.Setup(s => s.GetTopSellingCandy()).Returns(lollipop);
shop.Verify(s => s.BuyCandy(lollipop), Times.AtMostOnce());
//NSubstitude
var lollipop = Substitute.For<ICandy>();
var shop = Substitute.For<ICandyShop>();
shop.GetTopSellingCandy().Returns(lollipop);
shop.Received().BuyCandy(lollipop);
//FakeItEasy
var lollipop = A.Fake<ICandy>();
var shop = A.Fake<ICandyShop>();
A.CallTo(() => shop.GetTopSellingCandy()).Returns(lollipop);
A.CallTo(() => shop.BuyCandy(lollipop)).MustHaveHappened();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment