Example #1
0
        public void TestWatchFunctionFailureNoModel()
        {
            var httpContext      = new DefaultHttpContext();
            var queryStringValue = "abc";
            var request          = new DefaultHttpRequest(new DefaultHttpContext())
            {
                Query = new QueryCollection
                        (
                    new System.Collections.Generic.Dictionary <string, StringValues>()
                {
                    { "not-model", queryStringValue }
                }
                        )
            };

            var logger = NullLoggerFactory.Instance.CreateLogger("Null Logger");

            var response = WatchPortalFunctionInfo.Run(request, logger);

            response.Wait();

            // Check that the response is an "Bad" response
            Assert.IsAssignableFrom <BadRequestObjectResult>(response.Result);

            // Check that the contents of the response are the expected contents
            var result = (BadRequestObjectResult)response.Result;

            Assert.Equal("Please provide a watch model in the query string", result.Value);
        }
Example #2
0
        public void TestWatchFunctionSuccess()
        {
            var httpContext      = new DefaultHttpContext();
            var queryStringValue = "abc";
            var request          = new DefaultHttpRequest(new DefaultHttpContext())
            {
                Query = new QueryCollection
                        (
                    new System.Collections.Generic.Dictionary <string, StringValues>()
                {
                    { "model", queryStringValue }
                }
                        )
            };

            var logger = NullLoggerFactory.Instance.CreateLogger("Null Logger");

            var response = WatchPortalFunctionInfo.Run(request, logger);

            response.Wait();

            // Check that the response is an "OK" response
            Assert.IsAssignableFrom <OkObjectResult>(response.Result);

            // Check that the contents of the response are the expected contents
            var     result    = (OkObjectResult)response.Result;
            dynamic watchinfo = new { Manufacturer = "Abc", CaseType = "Solid", Bezel = "Titanium", Dial = "Roman", CaseFinish = "Silver", Jewels = 15 };
            string  watchInfo = $"Watch Details: {watchinfo.Manufacturer}, {watchinfo.CaseType}, {watchinfo.Bezel}, {watchinfo.Dial}, {watchinfo.CaseFinish}, {watchinfo.Jewels}";

            Assert.Equal(watchInfo, result.Value);
        }
Example #3
0
        public void TestWatchFunctionFailureNoQueryString()
        {
            var httpContext = new DefaultHttpContext();
            var request     = new DefaultHttpRequest(new DefaultHttpContext());
            var logger      = NullLoggerFactory.Instance.CreateLogger("Null Logger");

            var response = WatchPortalFunctionInfo.Run(request, logger);

            response.Wait();

            // Check that the response is an "Bad" response
            Assert.IsAssignableFrom <BadRequestObjectResult>(response.Result);

            // Check that the contents of the response are the expected contents
            var result = (BadRequestObjectResult)response.Result;

            Assert.Equal("Please provide a watch model in the query string", result.Value);
        }