public void UseDefaultResourceInspectors_GetSet() { var options = new HalOptions(); options.UseDefaultResourceInspectors = false; Assert.IsFalse(options.UseDefaultResourceInspectors); }
public static IHalBuilder AddHal(this IServiceCollection services, Action <HalOptions> optionsAction) { var options = new HalOptions(); optionsAction.Invoke(options); throw new NotImplementedException(); }
public void SupportedMediaTypes_GetSet() { var options = new HalOptions(); var mediaTypes = new List <string>(); options.SupportedMediaTypes = mediaTypes; Assert.AreSame(mediaTypes, options.SupportedMediaTypes); }
public void ResourceInspectors_GetSet() { var options = new HalOptions(); var inspectors = Mock.Of <IList <IHalResourceInspectorMetadata> >(); options.ResourceInspectors = inspectors; Assert.AreSame(inspectors, options.ResourceInspectors); }
public void SupportedMediaTypes_DefaultHalJson() { var options = new HalOptions(); var mediaTypes = options.SupportedMediaTypes; Assert.AreEqual(1, mediaTypes.Count); Assert.AreEqual("application/hal+json", mediaTypes.First()); }
public void Configure_UseDefaultResourceInspectorsFalse_DoesNotAddResourceInspectors() { var resourceFactory = ResourceFactory.Object; IConfigureOptions <HalOptions> setup = new HalSetup(ServiceProvider.Object, resourceFactory); var options = new HalOptions { UseDefaultResourceInspectors = false }; setup.Configure(options); Assert.AreEqual(0, options.ResourceInspectors.Count); }
public void Configure_UseDefaultResourceInspectors_AddsResourceValidationInspector() { var services = new ServiceCollection(); services.AddMvcCore(); services.AddLogging(); services.AddSingleton(Mock.Of <LinkService>()); var provider = services.BuildServiceProvider(); IConfigureOptions <HalOptions> setup = new HalSetup(provider, ResourceFactory.Object); var options = new HalOptions { UseDefaultResourceInspectors = true }; setup.Configure(options); Assert.That(options.ResourceInspectors, Has.One.InstanceOf <ResourceValidationInspector>()); }
public HalJsonOutputFormatter( JsonSerializerSettings serializerSettings, ArrayPool <char> charPool, HalOptions options) : base(serializerSettings, charPool) { if (options == null) { throw new ArgumentNullException(nameof(options)); } this.SupportedMediaTypes.Clear(); if (options.SupportedMediaTypes != null) { foreach (var mediaType in options.SupportedMediaTypes) { this.SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse(mediaType)); } } }
public ResourceInspectorSelector(HalOptions options) { this.options = options ?? throw new ArgumentNullException(nameof(options)); }
public void UseDefaultResourceInspectors_DefaultTrue() { var options = new HalOptions(); Assert.IsTrue(options.UseDefaultResourceInspectors); }
public void ResourceInspectors_ThrowsIfNull() { var options = new HalOptions(); Assert.Throws <ArgumentNullException>(() => options.ResourceInspectors = null); }
public void ResourceInspectors_DefaultInitialized() { var options = new HalOptions(); Assert.NotNull(options.ResourceInspectors); }
public void SupportedMediaTypes_ThrowsIfNull() { var options = new HalOptions(); Assert.Throws <ArgumentNullException>(() => options.SupportedMediaTypes = null); }