コード例 #1
0
        public void TestCGuidGenerated() {
            collection.RemoveAll();

            var id = Guid.NewGuid();
            var document = new CGuid { Id = id, A = 1 };
            collection.Save(document);
            Assert.AreEqual(id, document.Id);
            Assert.AreEqual(1, collection.Count());

            document.A = 2;
            collection.Save(document);
            Assert.AreEqual(id, document.Id);
            Assert.AreEqual(1, collection.Count());

            document = collection.FindOneAs<CGuid>();
            Assert.AreEqual(id, document.Id);
            Assert.AreEqual(2, document.A);
        }
コード例 #2
0
        public void TestCGuidEmpty() {
            collection.RemoveAll();

            var document = new CGuid { A = 1 };
            Assert.AreEqual(Guid.Empty, document.Id);
            collection.Save(document);
            Assert.AreNotEqual(Guid.Empty, document.Id);
            Assert.AreEqual(1, collection.Count());

            var id = document.Id;
            document.A = 2;
            collection.Save(document);
            Assert.AreEqual(id, document.Id);
            Assert.AreEqual(1, collection.Count());

            document = collection.FindOneAs<CGuid>();
            Assert.AreEqual(id, document.Id);
            Assert.AreEqual(2, document.A);
        }