public void ProcessRequest_GiveNullCommunicationContext_ThrowsException() { //------------Setup for test------------------------- var handler = new GetApisJsonServiceHandler(); //------------Execute Test--------------------------- handler.ProcessRequest(null); //------------Assert Results------------------------- }
public void ProcessRequest_GiveNoPathAndNonPublicRequest() { var communicationContext = new Mock<ICommunicationContext>(); var request = new Mock<ICommunicationRequest>(); request.Setup(communicationRequest => communicationRequest.BoundVariables).Returns(LocalQueryString); communicationContext.Setup(context => context.Request).Returns(request.Object); //------------Setup for test------------------------- var auth = new Mock<IAuthorizationService>(); var cat = new Mock<IResourceCatalog>(); cat.Setup(catalog => catalog.GetResourceList(It.IsAny<Guid>())).Returns(new List<IResource>()); var handler = new GetApisJsonServiceHandler(cat.Object, auth.Object); //------------Execute Test--------------------------- handler.ProcessRequest(communicationContext.Object); //------------Assert Results------------------------- }
public void ProcessRequest_GivePublicRequest() { var collection = new NameValueCollection { { "Name", "the_name" }, { "isPublic", "true" }, { "path", "" }, }; var communicationContext = new Mock<ICommunicationContext>(); var request = new Mock<ICommunicationRequest>(); request.Setup(communicationRequest => communicationRequest.BoundVariables).Returns(collection); communicationContext.Setup(context => context.Request).Returns(request.Object); //------------Setup for test------------------------- var handler = new GetApisJsonServiceHandler(); //------------Execute Test--------------------------- handler.ProcessRequest(communicationContext.Object); //------------Assert Results------------------------- communicationContext.Verify(context => context.Send(It.IsAny<IResponseWriter>()), Times.AtLeastOnce); }