public void ShouldGetBuildLogAndReturnResultOfDelegateTransformer() { DynamicMock buildRetrieverMock = new DynamicMock(typeof(IBuildRetriever)); DynamicMock delegateTransformerMock = new DynamicMock(typeof(IMultiTransformer)); BuildRequestTransformer requestTransformer = new BuildRequestTransformer((IBuildRetriever)buildRetrieverMock.MockInstance, (IMultiTransformer)delegateTransformerMock.MockInstance); DefaultBuildSpecifier buildSpecifier = new DefaultBuildSpecifier(new DefaultProjectSpecifier(new DefaultServerSpecifier("myServer"), "myProject"), "myBuild"); Build build = new Build(buildSpecifier, "logContents"); buildRetrieverMock.ExpectAndReturn("GetBuild", build, buildSpecifier, null); string[] fileNames = new string[] { "file1", "file2" }; delegateTransformerMock.ExpectAndReturn("Transform", "transformed", "logContents", fileNames, null); Assert.AreEqual("transformed", requestTransformer.Transform(buildSpecifier, fileNames, null, null)); buildRetrieverMock.Verify(); delegateTransformerMock.Verify(); }
public void ShouldGetBuildLogAndReturnResultOfDelegateTransformer() { var buildRetrieverMock = new Mock <IBuildRetriever>(); var delegateTransformerMock = new Mock <IMultiTransformer>(); BuildRequestTransformer requestTransformer = new BuildRequestTransformer((IBuildRetriever)buildRetrieverMock.Object, (IMultiTransformer)delegateTransformerMock.Object); DefaultBuildSpecifier buildSpecifier = new DefaultBuildSpecifier(new DefaultProjectSpecifier(new DefaultServerSpecifier("myServer"), "myProject"), "myBuild"); Build build = new Build(buildSpecifier, "logContents"); buildRetrieverMock.Setup(retriever => retriever.GetBuild(buildSpecifier, null)).Returns(build).Verifiable(); string[] fileNames = new string[] { "file1", "file2" }; delegateTransformerMock.Setup(transformer => transformer.Transform("logContents", fileNames, null)).Returns("transformed").Verifiable(); Assert.AreEqual("transformed", requestTransformer.Transform(buildSpecifier, fileNames, null, null)); buildRetrieverMock.Verify(); delegateTransformerMock.Verify(); }