Ejemplo n.º 1
0
        public void WhenContentIsRequested_CookiesGetPersistedInQueue()
        {
            var queue = BuildQueue();

            var aspNetSessionid = "ASP.NET_SessionId";

            var cookieValue = "123";

            var contentService = new TestContentService(queue, "userId",
                                                        new MockHttpClient(BuildResponseMessage("text",
                                                                                                new[] { new CookieValue {
                                                                                                            Key = aspNetSessionid, Value = cookieValue
                                                                                                        } })));

            contentService.LoadAndFormatContent("HelpIntent", "default text");

            VerifyQueueContainsCookie(queue, aspNetSessionid, cookieValue);

            contentService = new TestContentService(queue, "userId",
                                                    new MockHttpClient(BuildResponseMessage("text")));

            contentService.LoadAndFormatContent("HelpIntent", "default text");

            VerifyQueueContainsCookie(queue, aspNetSessionid, cookieValue);
        }
Ejemplo n.º 2
0
        public void WhenContentIsRequested_ValidTextIsReturned()
        {
            var queue = BuildQueue();

            var responseText = "Welcome to the house of fun";

            var contentService = new TestContentService(queue, "userId",
                                                        new MockHttpClient(BuildResponseMessage(responseText)));

            var result = contentService.LoadAndFormatContent("HelpIntent", "default text");

            Assert.That(result.FormattedContent, Is.EqualTo(responseText));
        }
Ejemplo n.º 3
0
        private static string RunRequestWithParameters(RequestParameters requestParameters = null)
        {
            var queue = BuildQueue();

            var mockHttpClient = new Mock <IHttpClient>();

            HttpRequestMessage message = null;

            mockHttpClient.Setup(a => a.SendAsync(It.IsAny <HttpRequestMessage>()))
            .Callback <HttpRequestMessage>(a => message = a);

            var contentService = new TestContentService(queue, "userId", mockHttpClient.Object);

            contentService.LoadAndFormatContent("HelpIntent", "default text", requestParameters);

            var requestUri = message.RequestUri.ToString();

            return(requestUri);
        }