public void CreateProblemResponseTypes_NoParameters_IncludesDefaultResponse()
        {
            // Arrange
            var action = new ActionDescriptor()
            {
                FilterDescriptors = new List <FilterDescriptor>()
                {
                    new FilterDescriptor(Mock.Of <IApiBehaviorMetadata>(), FilterScope.Global),
                },
                BoundProperties = new List <ParameterDescriptor>(),
                Parameters      = new List <ParameterDescriptor>(),
            };
            var description = new ApiDescription()
            {
                ActionDescriptor = action,
            };

            var provider = new ApiBehaviorApiDescriptionProvider(new EmptyModelMetadataProvider());

            // Act
            var results = provider.CreateProblemResponseTypes(description);

            // Assert
            Assert.Collection(
                results.OrderBy(r => r.StatusCode),
                r =>
            {
                Assert.Equal(typeof(ProblemDetails), r.Type);
                Assert.Equal(0, r.StatusCode);
                Assert.True(r.IsDefaultResponse);
            });
        }
        public void IsIdParameter_ParameterNameDoesNotMatchConvention_ReturnsFalse(string name)
        {
            var parameter = new ParameterDescriptor()
            {
                Name = name,
            };

            var provider = new ApiBehaviorApiDescriptionProvider(new EmptyModelMetadataProvider());

            // Act
            var result = provider.IsIdParameter(parameter);

            // Assert
            Assert.False(result);
        }
        public void AppliesTo_ActionWithoutApiBehavior_ReturnsFalse()
        {
            // Arrange
            var action = new ActionDescriptor()
            {
                FilterDescriptors = new List <FilterDescriptor>(),
            };
            var description = new ApiDescription()
            {
                ActionDescriptor = action,
            };

            var provider = new ApiBehaviorApiDescriptionProvider(new EmptyModelMetadataProvider());

            // Act
            var result = provider.AppliesTo(description);

            // Assert
            Assert.False(result);
        }
        public void AppliesTo_ActionWithApiBehavior_ReturnsTrue()
        {
            // Arrange
            var action = new ActionDescriptor()
            {
                FilterDescriptors = new List <FilterDescriptor>()
                {
                    new FilterDescriptor(Mock.Of <IApiBehaviorMetadata>(), FilterScope.Global),
                }
            };
            var description = new ApiDescription()
            {
                ActionDescriptor = action,
            };

            var provider = new ApiBehaviorApiDescriptionProvider(new EmptyModelMetadataProvider());

            // Act
            var result = provider.AppliesTo(description);

            // Assert
            Assert.True(result);
        }