public void Test_IsValidForRequest_ReturnsMatcherResult(bool expected) { matcherMock.Setup(x => x.IsMatch(It.IsAny <MethodMetadata>(), It.IsAny <string>())) .Returns(expected); var items = new Dictionary <object, object>() { [JsonRpcConstants.NestedPipelineItemKey] = true, [JsonRpcConstants.RequestItemKey] = Mock.Of <IUntypedCall>(), }; var httpContextMock = new Mock <HttpContext>(); httpContextMock.SetupGet(x => x.Items) .Returns(items); httpContextMock.SetupGet(x => x.RequestServices) .Returns(testEnvironment.ServiceProvider); var properties = new Dictionary <object, object> { [typeof(MethodMetadata)] = new MethodMetadata(new JsonRpcMethodOptions(), new JsonName("test", "test"), new JsonName("test", "test")) }; var actionDescriptorMock = new Mock <ActionDescriptor>(); actionDescriptorMock.Object.Properties = properties; var attribute = new JsonRpcAttribute(); var result = attribute.IsValidForRequest(new RouteContext(httpContextMock.Object), actionDescriptorMock.Object); result.Should().Be(expected); matcherMock.Verify(x => x.IsMatch(It.IsAny <MethodMetadata>(), It.IsAny <string>())); matcherMock.VerifyNoOtherCalls(); }
public void Test_IsValidForRequest_FalseWhenNoItem() { var items = new Dictionary <object, object>(); var httpContextMock = new Mock <HttpContext>(); httpContextMock.SetupGet(x => x.Items) .Returns(items); var attribute = new JsonRpcAttribute(); var result = attribute.IsValidForRequest(new RouteContext(httpContextMock.Object), Mock.Of <ActionDescriptor>()); result.Should().BeFalse(); }