コード例 #1
0
        public void TestWatchFunctionSuccess()
        {
            var request = new DefaultHttpContext().Request;

            request.QueryString = QueryString.Create("model", "any");

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

            var response = new WatchInfoFunction(TestProvider).
                           Run(request, logger);

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

            // Check that the contents of the response are the expected contents
            var result = (OkObjectResult)response;

            var watchinfo = TestProvider.ProvideWatchItem("realModel");

            string watchInfo =
                $"Watch Details: {watchinfo.Manufacturer}, " +
                $"{watchinfo.CaseType}, {watchinfo.Bezel}, {watchinfo.Dial}, " +
                $"{watchinfo.CaseFinish}, {watchinfo.Jewels}";

            Assert.Equal(watchInfo, result.Value);
        }
コード例 #2
0
        public IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous,
                                              "get", "post", Route = null)] HttpRequest req, ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            // Retrieve the model id from the query string
            string model = req.Query["model"];

            // If the user specified a model id, find the details of the model
            // of watch
            if (model != null)
            {
                WatchItem watchInfo =
                    _watchInfoProvider.ProvideWatchItem(model);

                return(new OkObjectResult(
                           $"Watch Details: {watchInfo.Manufacturer}, " +
                           $"{watchInfo.CaseType}, {watchInfo.Bezel}, " +
                           $"{watchInfo.Dial}, {watchInfo.CaseFinish}, " +
                           $"{watchInfo.Jewels}"));
            }
            return(new BadRequestObjectResult(
                       "Please provide a watch model in the query string"));
        }