Beispiel #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);
        }
Beispiel #2
0
        public WatchFunctionIntegrationTestLikeSaebs(TestHost testHost,
                                                     ITestOutputHelper outputHelp)
        {
            _sut = new WatchInfoFunction(testHost.ServiceProvider.
                                         GetRequiredService <IWatchInfoProvider>());

            _outputHelper = outputHelp;
        }
Beispiel #3
0
        public void TestWatchFunctionFailureNoQueryString()
        {
            var request = new DefaultHttpContext().Request;
            var logger  = NullLoggerFactory.Instance.CreateLogger("Null Logger");

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

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

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

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