Skip to content

Commit f3076bf

Browse files
committed
Added serialization test
1 parent b7f6663 commit f3076bf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/MongoDB.Bson.Tests/Serialization/Serializers/TimeOnlySerializerTests.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@ public void GetHashCode_should_return_zero()
324324
result.Should().Be(0);
325325
}
326326

327+
[Theory]
328+
[InlineData("08:32:05.5946583", """{ "x" : { "Hour" : { "$numberInt" : "8" }, "Minute" : { "$numberInt" : "32" }, "Second" : { "$numberInt" : "5" }, "Millisecond" : { "$numberInt" : "594" }, "Ticks" : { "$numberLong" : "307255946583" } } }""")]
329+
[InlineData("00:00:00.0000000", """{ "x" : { "Hour" : { "$numberInt" : "0" }, "Minute" : { "$numberInt" : "0" }, "Second" : { "$numberInt" : "0" }, "Millisecond" : { "$numberInt" : "0" }, "Ticks" : { "$numberLong" : "0" } } }""")]
330+
[InlineData("23:59:59.9999999", """{ "x" : { "Hour" : { "$numberInt" : "23" }, "Minute" : { "$numberInt" : "59" }, "Second" : { "$numberInt" : "59" }, "Millisecond" : { "$numberInt" : "999" }, "Ticks" : { "$numberLong" : "863999999999" } } }""")]
331+
public void Serialize_with_document_representation_should_have_expected_result(string valueString, string expectedResult)
332+
{
333+
var subject = new TimeOnlySerializer(BsonType.Document);
334+
335+
TestSerialize(subject, valueString, expectedResult);
336+
}
337+
327338
[Theory]
328339
[InlineData(BsonType.String, "08:32:05.5946583", """{ "x" : "08:32:05.5946583" }""")]
329340
[InlineData(BsonType.String, "00:00:00.0000000", """{ "x" : "00:00:00.0000000" }""")]
@@ -525,7 +536,7 @@ private class TestClass
525536
[BsonTimeOnlyOptions(BsonType.Int64, TimeOnlyUnits.Nanoseconds )]
526537
public TimeOnly Nanoseconds { get; set; }
527538

528-
[BsonTimeOnlyOptions(BsonType.Document, TimeOnlyUnits.Nanoseconds )]
539+
[BsonTimeOnlyOptions(BsonType.Document)]
529540
public TimeOnly Document { get; set; }
530541
}
531542
}

0 commit comments

Comments
 (0)