Initializing HubOptions.JsonSerializationSettings to default settings

This commit is contained in:
Pawel Kadluczka 2017-09-06 13:51:22 -07:00
parent b4c61b6c2d
commit 9e614b6cc7
3 changed files with 24 additions and 2 deletions

View File

@ -7,6 +7,6 @@ namespace Microsoft.AspNetCore.SignalR
{
public class HubOptions
{
public JsonSerializerSettings JsonSerializerSettings { get; set; }
public JsonSerializerSettings JsonSerializerSettings { get; set; } = new JsonSerializerSettings();
}
}

View File

@ -4,7 +4,6 @@
using System;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Microsoft.CSharp;
namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
{

View File

@ -0,0 +1,23 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Xunit;
namespace Microsoft.AspNetCore.SignalR.Tests
{
public class SignalRDependencyInjectionExtensionsTests
{
[Fact]
public void JSonSerializerSettingsShouldNotBeNullInOptions()
{
var services = new ServiceCollection();
services.AddOptions();
services.AddSignalR();
var serviceProvider = services.BuildServiceProvider();
var hubOptions = serviceProvider.GetService<IOptions<HubOptions>>();
Assert.NotNull(hubOptions.Value.JsonSerializerSettings);
}
}
}