public void UseCallbackForJsonpWhenProvided() { var frameworkProviderMock = new Mock<IFrameworkProvider>(); var serializerMock = new Mock<ISerializer>(); var contextMock = new Mock<IResourceResultContext>(); contextMock.Setup(c => c.FrameworkProvider).Returns(frameworkProviderMock.Object); contextMock.Setup(c => c.Serializer).Returns(serializerMock.Object); var obj = new { Any = "Thing" }; var callback = "aJavasciptFunction"; var result = new JsonResourceResult(obj, callback); result.Execute(contextMock.Object); frameworkProviderMock.Verify(fp => fp.WriteHttpResponse(It.IsRegex(callback + ".+")), Times.Once()); }
public void Execute() { var frameworkProviderMock = new Mock<IFrameworkProvider>(); var serializerMock = new Mock<ISerializer>(); var contextMock = new Mock<IResourceResultContext>(); contextMock.Setup(c => c.FrameworkProvider).Returns(frameworkProviderMock.Object); contextMock.Setup(c => c.Serializer).Returns(serializerMock.Object); var obj = new { Any = "thing" }; var result = new JsonResourceResult(obj); result.Execute(contextMock.Object); frameworkProviderMock.Verify(fp => fp.WriteHttpResponse(It.IsAny<string>()), Times.Once()); serializerMock.Verify(s => s.Serialize(obj), Times.Once()); }