public async Task Given_Type_When_Initiated_Then_It_Should_Return_HttpSettings()
        {
            var location = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
            var context  = new OpenApiHttpTriggerContext();

            var settings = (await context.SetApplicationAssemblyAsync(location, false))
                           .HttpSettings;

            settings.RoutePrefix.Should().Be("api");
        }
        public async Task Given_Type_When_GetOpenApiSpecVersion_Invoked_Then_It_Should_Return_Result(string format, OpenApiFormat expected)
        {
            var location = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
            var context  = new OpenApiHttpTriggerContext();

            var result = (await context.SetApplicationAssemblyAsync(location, false))
                         .GetOpenApiFormat(format);

            result.Should().Be(expected);
        }
        public async Task Given_Type_When_Initiated_Then_It_Should_Return_PackageAssembly()
        {
            var location = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
            var context  = new OpenApiHttpTriggerContext();

            var assembly = (await context.SetApplicationAssemblyAsync(location, false))
                           .PackageAssembly;

            assembly.DefinedTypes.Should().Contain(typeof(ISwaggerUI).GetTypeInfo());
        }
        public async Task Given_Type_With_Referenced_Project_When_Initiated_Then_It_Should_Return_ApplicationAssemblyOfRootAssembly()
        {
            var location = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
            var context  = new OpenApiHttpTriggerContext();

            var assembly = (await context.SetApplicationAssemblyAsync(location, false))
                           .ApplicationAssembly;

            assembly.FullName.Should().Be(typeof(OpenApiHttpTriggerContextTests).Assembly.FullName);
        }
        public async Task Given_Type_When_Initiated_Then_It_Should_Return_OpenApiCustomUIOptions()
        {
            var location = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
            var context  = new OpenApiHttpTriggerContext();

            var options = (await context.SetApplicationAssemblyAsync(location, false))
                          .OpenApiCustomUIOptions;

            options.CustomStylesheetPath.Should().Be("dist.custom.css");
            options.CustomJavaScriptPath.Should().Be("dist.custom.js");
        }
        public async Task Given_Type_When_Initiated_Then_It_Should_Return_OpenApiConfigurationOptions()
        {
            var location = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
            var context  = new OpenApiHttpTriggerContext();

            var options = (await context.SetApplicationAssemblyAsync(location, false))
                          .OpenApiConfigurationOptions;

            options.Info.Version.Should().Be("1.0.0");
            options.Servers.Count.Should().Be(0);
        }
        public async Task Given_Type_When_Initiated_Then_It_Should_NotReturn_ApplicationAssemblyWithGivenType(Type type)
        {
            var location = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
            var context  = new OpenApiHttpTriggerContext();

            var assembly = (await context.SetApplicationAssemblyAsync(location, false))
                           .ApplicationAssembly;

            var ti = type.GetTypeInfo();

            assembly.DefinedTypes.Select(p => p.FullName).Should().NotContain(ti.FullName);
        }
        public async Task Given_Authorization_When_AuthorizeAsync_Invoked_Then_It_Should_Return_Result()
        {
            var location = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
            var req      = new Mock <IHttpRequestDataObject>();
            var context  = new OpenApiHttpTriggerContext();

            var result = await context.SetApplicationAssemblyAsync(location, false)
                         .AuthorizeAsync(req.Object);

            result.StatusCode.Should().Be(FakeOpenApiHttpTriggerAuthorization.StatusCode);
            result.ContentType.Should().Be(FakeOpenApiHttpTriggerAuthorization.ContentType);
            result.Payload.Should().Be(FakeOpenApiHttpTriggerAuthorization.Payload);
        }