diff --git a/MongoDB.Entities/MongoDB.Entities.csproj b/MongoDB.Entities/MongoDB.Entities.csproj
index 5980f09e5..5578f4cc3 100644
--- a/MongoDB.Entities/MongoDB.Entities.csproj
+++ b/MongoDB.Entities/MongoDB.Entities.csproj
@@ -15,7 +15,7 @@
- [breaking] remove MongoDB.Entities.Core namespace
- [breaking] make ModifiedOn property opt-in using IModifiedOn interface
- [breaking] remove support for geo haystack indexes as deprecated in official driver
-- new interface ICreatedOn for optionally adding creation date to entities
+- new interface ICreatedOn for optionally adding auto-managed creation date to entities
- misc. changes
MongoDB.Entities
MongoDB.Entities
diff --git a/Tests/Models/Author.cs b/Tests/Models/Author.cs
index e396dbfd1..7dbab492d 100644
--- a/Tests/Models/Author.cs
+++ b/Tests/Models/Author.cs
@@ -3,7 +3,7 @@
namespace MongoDB.Entities.Tests
{
[Name("Writer")]
- public class Author : Entity, IModifiedOn
+ public class Author : Entity, IModifiedOn, ICreatedOn
{
public string Name { get; set; }
public string Surname { get; set; }
@@ -30,6 +30,8 @@ public class Author : Entity, IModifiedOn
public string BookIDs { get; set; }
public DateTime ModifiedOn { get; set; }
+
+ public DateTime CreatedOn { get; set; }
public Author() => this.InitOneToMany(() => Books);
}
diff --git a/Tests/TestSaving.cs b/Tests/TestSaving.cs
index 784594786..636409c9e 100644
--- a/Tests/TestSaving.cs
+++ b/Tests/TestSaving.cs
@@ -29,6 +29,22 @@ public void saved_book_has_correct_title()
Assert.AreEqual("Test", title);
}
+ [TestMethod]
+ public void created_on_property_works()
+ {
+ var author = new Author { Name = "test" };
+ author.Save();
+
+ var res = DB.Find()
+ .Match(a => a.ID == author.ID)
+ .Project(a => a.CreatedOn)
+ .Execute()
+ .Single();
+
+ Assert.AreEqual(res.ToLongTimeString(), author.CreatedOn.ToLongTimeString());
+ Assert.IsTrue(DateTime.UtcNow.Subtract(res).TotalSeconds <= 5);
+ }
+
[TestMethod]
public void save_preserving()
{