Skip to content

Commit

Permalink
Fix unit tests, add test for json serialization in JobProgressDispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
pieceofsummer committed Aug 10, 2018
1 parent 30c8db2 commit 08f0e8c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Hangfire.Console/Dashboard/JobProgressDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Hangfire.Console.Dashboard
/// </summary>
internal class JobProgressDispatcher : IDashboardDispatcher
{
private static readonly JsonSerializerSettings JsonSettings = new JsonSerializerSettings()
internal static readonly JsonSerializerSettings JsonSettings = new JsonSerializerSettings()
{
ContractResolver = new DefaultContractResolver()
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Collections.Generic;
using Hangfire.Console.Dashboard;
using Newtonsoft.Json;
using Xunit;

namespace Hangfire.Console.Tests.Dashboard
{
public class JobProgressDispatcherFacts
{
[Fact]
public void JsonSettings_PreservesDictionaryKeyCase()
{
var result = new Dictionary<string, double>
{
["AAA"] = 1.0,
["Bbb"] = 2.0,
["ccc"] = 3.0
};

var json = JsonConvert.SerializeObject(result, JobProgressDispatcher.JsonSettings);

Assert.Equal("{\"AAA\":1.0,\"Bbb\":2.0,\"ccc\":3.0}", json);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void CreatesConsoleContext_IfStateIsProcessing_FixesExpiration_IfFollowsJ
performer.Perform(context);

var consoleContext = ConsoleContext.FromPerformContext(context);
Assert.NotNull(consoleContext);
Assert.Null(consoleContext);

_connection.Verify(x => x.GetHashTtl(It.IsAny<string>()));

Expand All @@ -115,7 +115,7 @@ public void CreatesConsoleContext_IfStateIsProcessing_DoesNotFixExpiration_IfNeg
performer.Perform(context);

var consoleContext = ConsoleContext.FromPerformContext(context);
Assert.NotNull(consoleContext);
Assert.Null(consoleContext);

_connection.Verify(x => x.GetHashTtl(It.IsAny<string>()));

Expand All @@ -136,7 +136,7 @@ public void CreatesConsoleContext_IfStateIsProcessing_DoesNotFixExpiration_IfZer
performer.Perform(context);

var consoleContext = ConsoleContext.FromPerformContext(context);
Assert.NotNull(consoleContext);
Assert.Null(consoleContext);

_connection.Verify(x => x.GetHashTtl(It.IsAny<string>()));

Expand All @@ -155,7 +155,7 @@ public void CreatesConsoleContext_IfStateIsProcessing_ExpiresData_IfNotFollowsJo
performer.Perform(context);

var consoleContext = ConsoleContext.FromPerformContext(context);
Assert.NotNull(consoleContext);
Assert.Null(consoleContext);

_connection.Verify(x => x.GetHashTtl(It.IsAny<string>()), Times.Never);

Expand Down

0 comments on commit 08f0e8c

Please sign in to comment.