示例#1
0
        public void PopulateTimestamps()
        {
            var target   = new AllTimestampOptionsModel();
            var db       = FirestoreDb.Create("project", "database", new FakeFirestoreClient());
            var snapshot = GetSampleSnapshot(db, "doc1");

            AttributedTimestampAssigner.MaybeAssignTimestamps(target, snapshot);

            Assert.Equal(snapshot.CreateTime.Value.ToDateTime(), target.CreateDateTime);
            Assert.Equal(snapshot.CreateTime.Value.ToDateTimeOffset(), target.CreateDateTimeOffset);
            Assert.Equal(snapshot.CreateTime, target.CreateTimestamp);
            Assert.Equal(snapshot.CreateTime.Value.ToDateTime(), target.NullableCreateDateTime);
            Assert.Equal(snapshot.CreateTime.Value.ToDateTimeOffset(), target.NullableCreateDateTimeOffset);
            Assert.Equal(snapshot.CreateTime, target.NullableCreateTimestamp);
            Assert.Equal(snapshot.CreateTime.Value.ToProto(), target.CreateTimestampProto);

            Assert.Equal(snapshot.UpdateTime.Value.ToDateTime(), target.UpdateDateTime);
            Assert.Equal(snapshot.UpdateTime.Value.ToDateTimeOffset(), target.UpdateDateTimeOffset);
            Assert.Equal(snapshot.UpdateTime, target.UpdateTimestamp);
            Assert.Equal(snapshot.UpdateTime.Value.ToDateTime(), target.NullableUpdateDateTime);
            Assert.Equal(snapshot.UpdateTime.Value.ToDateTimeOffset(), target.NullableUpdateDateTimeOffset);
            Assert.Equal(snapshot.UpdateTime, target.NullableUpdateTimestamp);
            Assert.Equal(snapshot.UpdateTime.Value.ToProto(), target.UpdateTimestampProto);

            Assert.Equal(snapshot.ReadTime.ToDateTime(), target.ReadDateTime);
            Assert.Equal(snapshot.ReadTime.ToDateTimeOffset(), target.ReadDateTimeOffset);
            Assert.Equal(snapshot.ReadTime, target.ReadTimestamp);
            Assert.Equal(snapshot.ReadTime.ToDateTime(), target.NullableReadDateTime);
            Assert.Equal(snapshot.ReadTime.ToDateTimeOffset(), target.NullableReadDateTimeOffset);
            Assert.Equal(snapshot.ReadTime, target.NullableReadTimestamp);
            Assert.Equal(snapshot.ReadTime.ToProto(), target.ReadTimestampProto);
        }
示例#2
0
        public void MissingDocumentTimestamps()
        {
            var target   = new AllTimestampOptionsModel();
            var db       = FirestoreDb.Create("project", "database", new FakeFirestoreClient());
            var readTime = new Timestamp(1, 100);
            var snapshot = DocumentSnapshot.ForMissingDocument(db, db.Document("col1/doc1").Path, readTime);

            AttributedTimestampAssigner.MaybeAssignTimestamps(target, snapshot);

            Assert.Equal(default, target.CreateDateTime);