public void Arrange()
        {
            Path     = "/" + Dummy.CreateRandomString(15);
            Port     = 50000 + Dummy.CreateRandomInt(1000);
            Prefixes = new[]
            {
                "http://*:" + Port + Path + "/"
            };
            AuthenticationSchemes = AuthenticationSchemes.Basic;
            TcpClient             = new TcpClient();
            Identity          = Dummy.CreateIdentity();
            Password          = Dummy.CreateRandomString(20);
            Credential        = new NetworkCredential(Identity.ToString(), Password);
            HttpClientHandler = new HttpClientHandler()
            {
                Credentials = Credential
            };
            HttpClient            = new HttpClient(HttpClientHandler);
            EnvelopeId            = Guid.NewGuid();
            QueryStringValue1     = Dummy.CreateRandomString(10);
            QueryStringValue2     = Dummy.CreateRandomInt(100);
            RequestUri            = new System.Uri("http://localhost:" + Port + Path + "/?value1=" + QueryStringValue1 + "&value2=" + QueryStringValue2);
            GetHttpRequestMessage = new HttpRequestMessage(HttpMethod.Get, RequestUri);
            GetHttpRequestMessage.Headers.Add(Constants.ENVELOPE_ID_HEADER, EnvelopeId.ToString());

            RequestBodyMediaType           = Dummy.CreateJsonMediaType();
            RequestBody                    = Dummy.CreateMessageJson();
            PostHttpRequestMessage         = new HttpRequestMessage(HttpMethod.Post, RequestUri);
            PostHttpRequestMessage.Content = new StringContent(RequestBody, Encoding.UTF8, RequestBodyMediaType.ToString());

            HttpResponseHeaders = new WebHeaderCollection();
            HttpResponseHeaders.Add(Dummy.CreateRandomString(10), Dummy.CreateRandomString(10));
            HttpResponseHeaders.Add(Dummy.CreateRandomString(10), Dummy.CreateRandomString(10));
            HttpResponseHeaders.Add(Dummy.CreateRandomString(10), Dummy.CreateRandomString(10));
            ResponseBodyMediaType = Dummy.CreateJsonMediaType();
            ResponseBody          = Dummy.CreateMessageJson();
            ResponseBodyStream    = new MemoryStream(Encoding.UTF8.GetBytes(ResponseBody));
            HttpResponse          = new HttpResponse(EnvelopeId, HttpStatusCode.OK, Dummy.CreateRandomString(50), HttpResponseHeaders, ResponseBodyMediaType, ResponseBodyStream);

            CancellationToken = TimeSpan.FromSeconds(5).ToCancellationToken();
            Target            = new Lazy <HttpServer>(() => new HttpServer(Prefixes, AuthenticationSchemes));
        }
Exemple #2
0
        public void Arrange()
        {
            EnvelopeStorage   = new Mock <IEnvelopeStorage <Envelope> >();
            Principal         = new Mock <IPrincipal>();
            PrincipalIdentity = new Mock <System.Security.Principal.IIdentity>();
            Principal.SetupGet(p => p.Identity).Returns(() => PrincipalIdentity.Object);
            Identity = Dummy.CreateIdentity();
            PrincipalIdentityName = Identity.ToString();
            PrincipalIdentity.SetupGet(p => p.Name).Returns(() => PrincipalIdentityName);
            Envelope                   = Dummy.CreateMessage(Dummy.CreateTextContent());
            Envelope.Pp                = Dummy.CreateNode();
            EnvelopeId                 = Envelope.Id;
            GetMessageUri              = new Uri("http://" + Constants.MESSAGES_PATH + ":" + Dummy.CreateRandomInt(50000) + "/" + EnvelopeId);
            GetMessageHttpRequest      = new HttpRequest("GET", GetMessageUri, Principal.Object, Guid.NewGuid().ToString());
            GetMessageUriTemplateMatch = new UriTemplateMatch();
            GetMessageUriTemplateMatch.BoundVariables.Add("id", EnvelopeId.ToString());
            GetMessageHttpResponse = new HttpResponse(GetMessageHttpRequest.CorrelatorId, System.Net.HttpStatusCode.OK);
            CancellationToken      = TimeSpan.FromSeconds(5).ToCancellationToken();

            Target = new MockGetEnvelopeByIdHttpProcessorBase(EnvelopeStorage.Object, Constants.MESSAGES_PATH);
            Target.GetEnvelopeResponseFunc = (m, r) => GetMessageHttpResponse;
        }