public void MethodAuthorizingContextShouldBePopulatedForPostHttpMethod() { var service = new TestService(); MethodInfo method = service.GetType().GetMethod("Post"); Assert.That(method, Is.Not.Null); var behaviorContext = new MethodAuthorizingContext(service, method); Assert.That(behaviorContext.Service, Is.SameAs(service)); Assert.That(behaviorContext.Method, Is.SameAs(method)); Assert.That(behaviorContext.GetServiceContractType(), Is.EqualTo(typeof(ITestService))); Assert.That(behaviorContext.GetServiceType(), Is.EqualTo(typeof(TestService))); Assert.That(behaviorContext.GetMethodName(), Is.EqualTo(method.Name)); var httpMethods = behaviorContext.GetSupportedHttpMethods().ToList(); Assert.That(httpMethods.Contains(HttpMethod.Get), Is.False); Assert.That(httpMethods.Contains(HttpMethod.Head), Is.False); Assert.That(httpMethods.Contains(HttpMethod.Post), Is.True); Assert.That(httpMethods.Contains(HttpMethod.Put), Is.False); Assert.That(httpMethods.Contains(HttpMethod.Patch), Is.False); Assert.That(httpMethods.Contains(HttpMethod.Delete), Is.False); }
public void Initialize() { m_context = MockContextManager.GenerateContext(); m_service = new TestService(); m_method = m_service.GetType().GetMethod("Post"); }
public void MethodExecutedContextShouldBePopulatedForPatchHttpMethod() { var service = new TestService(); MethodInfo method = service.GetType().GetMethod("Patch"); Assert.That(method, Is.Not.Null); var returnedObject = new ContentResult { Content = "ReturnedData", ContentType = "text/plain" }; var behaviorContext = new MethodExecutedContext(service, method, returnedObject); Assert.That(behaviorContext.Service, Is.SameAs(service)); Assert.That(behaviorContext.Method, Is.SameAs(method)); Assert.That(behaviorContext.ReturnedObject, Is.SameAs(returnedObject)); Assert.That(behaviorContext.GetServiceContractType(), Is.EqualTo(typeof(ITestService))); Assert.That(behaviorContext.GetServiceType(), Is.EqualTo(typeof(TestService))); Assert.That(behaviorContext.GetMethodName(), Is.EqualTo(method.Name)); var httpMethods = behaviorContext.GetSupportedHttpMethods().ToList(); Assert.That(httpMethods.Contains(HttpMethod.Get), Is.False); Assert.That(httpMethods.Contains(HttpMethod.Head), Is.False); Assert.That(httpMethods.Contains(HttpMethod.Post), Is.False); Assert.That(httpMethods.Contains(HttpMethod.Put), Is.False); Assert.That(httpMethods.Contains(HttpMethod.Patch), Is.True); Assert.That(httpMethods.Contains(HttpMethod.Delete), Is.False); }