Skip to content

Commit

Permalink
Merge branch 'feature/case_insensitive_stringenumconverter' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Feb 18, 2018
2 parents 6cb80ba + e55ae32 commit 7224485
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Source/StrongGrid.IntegrationTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static async Task<int> Main()
{
// -----------------------------------------------------------------------------
// Do you want to proxy requests through Fiddler (useful for debugging)?
var useFiddler = false;
var useFiddler = true;

// As an alternative to Fiddler, you can display debug information about
// every HTTP request/response in the console. This is useful for debugging
Expand Down
23 changes: 9 additions & 14 deletions Source/StrongGrid.UnitTests/Utilities/StringEnumConverterTests.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Shouldly;
using StrongGrid.Models;
using System.IO;
using Xunit;

namespace StrongGrid.UnitTests.Utilities
{
public class StringEnumConverterTests
{
[Fact]
public void Read_single()
[Theory]
[InlineData("in progress", CampaignStatus.InProgress)]
[InlineData("IN PROGRESS", CampaignStatus.InProgress)]
[InlineData("In Progress", CampaignStatus.InProgress)]
[InlineData("In progress", CampaignStatus.InProgress)]
public void Case_insensitive(string json, CampaignStatus expectedStatus)
{
// Arrange
var json = "'in progress'";
var textReader = new StringReader(json);
var jsonReader = new JsonTextReader(textReader);
var objectType = typeof(CampaignStatus);
var converter = new StringEnumConverter();
var value = $"'{json}'";

// Act
jsonReader.Read();
var result = converter.ReadJson(jsonReader, objectType, (object)null, new JsonSerializer());
var result = JsonConvert.DeserializeObject<CampaignStatus>(value);

// Assert
result.ShouldNotBeNull();
result.ShouldBeOfType<CampaignStatus>();
((CampaignStatus)result).ShouldBe(CampaignStatus.InProgress);
result.ShouldBe(expectedStatus);
}
}
}
2 changes: 1 addition & 1 deletion Source/StrongGrid/StrongGrid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<ItemGroup>
<PackageReference Include="HttpMultipartParser" Version="2.2.1" />
<PackageReference Include="MimeTypesMap" Version="1.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
<PackageReference Include="Pathoschild.Http.FluentClient" Version="3.1.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
<PrivateAssets>All</PrivateAssets>
Expand Down

0 comments on commit 7224485

Please sign in to comment.