public void GetOpenAPIServiceHandler_ProcessRequest_GiveNoPathAndNonPublicRequest() { 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); request.Setup(communicationRequest => communicationRequest.Uri).Returns(new Uri("http://localhost:3142/secure")); 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 GetOpenAPIServiceHandler(cat.Object, auth.Object); //------------Execute Test--------------------------- handler.ProcessRequest(communicationContext.Object); //------------Assert Results------------------------- }
public void GetOpenAPIServiceHandler_ProcessRequest_GiveNullCommunicationContext_ThrowsException() { //------------Setup for test------------------------- var handler = new GetOpenAPIServiceHandler(); //------------Execute Test--------------------------- handler.ProcessRequest(null); //------------Assert Results------------------------- }
public void GetOpenAPIServiceHandler_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); request.Setup(communicationRequest => communicationRequest.Uri).Returns(new Uri("http://localhost:3142/secure")); communicationContext.Setup(context => context.Request).Returns(request.Object); //------------Setup for test------------------------- var handler = new GetOpenAPIServiceHandler(); //------------Execute Test--------------------------- handler.ProcessRequest(communicationContext.Object); //------------Assert Results------------------------- communicationContext.Verify(context => context.Send(It.IsAny <IResponseWriter>()), Times.AtLeastOnce); }