From 980f2fdec0e4434be5a7c8d848e9f3ebdab6086e Mon Sep 17 00:00:00 2001 From: Daniel Pfeiffer Date: Wed, 11 Jan 2023 09:03:59 -0600 Subject: [PATCH] Fixes an issue where the default timestamp was set to 0 --- .../TinCanStatementBuilder.tests.cs | 11 +++++++++++ .../TinCanStatementBuilder.cs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Float.TinCan.ActivityLibrary.Tests/TinCanStatementBuilder.tests.cs b/Float.TinCan.ActivityLibrary.Tests/TinCanStatementBuilder.tests.cs index f70bd8f..2061472 100644 --- a/Float.TinCan.ActivityLibrary.Tests/TinCanStatementBuilder.tests.cs +++ b/Float.TinCan.ActivityLibrary.Tests/TinCanStatementBuilder.tests.cs @@ -13,5 +13,16 @@ public void TestBuildStatement() .Build(); Assert.NotNull(statement); } + + [Fact] + public void TestDefaultStatementTimestamp() + { + var statement = new TinCanStatementBuilder() + .Build(); + + // The default timestamp should be (approximately) now. + Assert.InRange(statement.timestamp ?? new System.DateTime(), System.DateTime.UtcNow.AddSeconds(-1), System.DateTime.UtcNow); + System.Console.WriteLine(statement.ToJSON()); + } } } diff --git a/Float.TinCan.ActivityLibrary/TinCanStatementBuilder.cs b/Float.TinCan.ActivityLibrary/TinCanStatementBuilder.cs index 22351a0..93ab9ed 100644 --- a/Float.TinCan.ActivityLibrary/TinCanStatementBuilder.cs +++ b/Float.TinCan.ActivityLibrary/TinCanStatementBuilder.cs @@ -36,7 +36,7 @@ public class TinCanStatementBuilder /// /// The timestamp for the statement to be built. Optional. /// - DateTime timestamp; + DateTime? timestamp; /// /// Gets the session ID for the statement to be build. Optional.