public void ShouldReturnDownloadExistsTrue_IfDownloadExists() { // Arrange var loveThisFrameworkMock = new Mock <ILoveThisFramework>(); loveThisFrameworkMock.Setup(framework => framework.DownloadExists("2.0.0.0")).Returns(false); loveThisFrameworkMock.Setup(framework => framework.DownloadExists("4.0.0.0")).Returns(true); ILoveThisFramework loveThisFramework = loveThisFrameworkMock.Object; var rapidshareService = new RapidshareService(loveThisFramework); // Act var downloadExists = rapidshareService.DownloadExists("4.0.0.0"); // Assert downloadExists.Should().BeTrue(); }
public void ProjectHomePageDemo() { var mock = new Mock <ILoveThisFramework>(); // WOW! No record/reply weirdness?! :) mock.Setup(framework => framework.ShouldDownload(It.IsAny <Version>())) .Callback((Version version) => Debug.WriteLine("Someone wanted version {0}!!!", version)) .Returns(true) .AtMostOnce(); // Hand mock.Object as a collaborator and exercise it, // like calling methods on it... ILoveThisFramework lovable = mock.Object; bool download = lovable.ShouldDownload(new Version("2.0.0.0")); mock.VerifyAll(); mock.Verify(framework => framework.ShouldDownload(new Version("2.0.0.0"))); }
public RapidshareService(ILoveThisFramework loveThisFramework) { this.loveThisFramework = loveThisFramework; }