public void ApiConventionAttributeIsAdded_IfAttributeExistsInAssembly() { // Arrange var controllerType = CreateTestControllerType(); var model = new ControllerModel(controllerType.GetTypeInfo(), Array.Empty <object>()); // Act ApiBehaviorApplicationModelProvider.AddGloballyConfiguredApiConventions(model); // Assert Assert.Collection( model.Filters, filter => Assert.IsType <ApiConventionAttribute>(filter)); }
public void ApiConventionAttributeIsNotAdded_IfModelAlreadyHasAttribute() { // Arrange var attribute = new ApiConventionAttribute(typeof(DefaultApiConventions)); var controllerType = CreateTestControllerType(); var model = new ControllerModel(controllerType.GetTypeInfo(), new[] { attribute }) { Filters = { attribute, }, }; // Act ApiBehaviorApplicationModelProvider.AddGloballyConfiguredApiConventions(model); // Assert Assert.Collection( model.Filters, filter => Assert.Same(attribute, filter)); }