示例#1
0
        public void guid_empty_should_be_insert()
        {
            var doc = new GuidDoc {
                Id = default(Guid)
            };

            theSession.Store(doc);

            theSession.PendingChanges.InsertsFor <GuidDoc>().Single().ShouldBeTheSameAs(doc);
            theSession.PendingChanges.Inserts().Single().ShouldBeTheSameAs(doc);

            theSession.PendingChanges.Updates().Any().ShouldBeFalse();

            doc.Id.ShouldNotBe(Guid.Empty);
        }
        public async Task stream_by_Guid_id_hit()
        {
            var doc = new GuidDoc {
            };

            theSession.Store(doc);
            await theSession.SaveChangesAsync();

            var stream = new MemoryStream();
            var found  = await theSession.Json.StreamById <GuidDoc>(doc.Id, stream);

            found.ShouldBeTrue();

            var target = deserialize <GuidDoc>(stream);

            target.Id.ShouldBe(doc.Id);
        }
示例#3
0
        public void guid_not_empty_is_update()
        {
            var theId = Guid.NewGuid();
            var doc   = new GuidDoc {
                Id = theId
            };

            theSession.Store(doc);

            theSession.PendingChanges.UpdatesFor <GuidDoc>().Single().ShouldBeTheSameAs(doc);
            theSession.PendingChanges.Updates().Single().ShouldBeTheSameAs(doc);

            theSession.PendingChanges.Inserts().Any().ShouldBeFalse();

            //
            doc.Id.ShouldBe(theId);
        }
示例#4
0
        public void mixed_change_and_update()
        {
            var doc1 = new GuidDoc {
                Id = Guid.NewGuid()
            };
            var doc2 = new GuidDoc {
                Id = Guid.NewGuid()
            };
            var doc3 = new GuidDoc {
                Id = Guid.Empty
            };

            theSession.Store(doc1, doc2, doc3);

            theSession.PendingChanges.UpdatesFor <GuidDoc>().ShouldHaveTheSameElementsAs(doc1, doc2);
            theSession.PendingChanges.InsertsFor <GuidDoc>().Single().ShouldBe(doc3);

            theSession.PendingChanges.AllChangedFor <GuidDoc>().Count().ShouldBe(3);
        }