Ejemplo n.º 1
0
        public async Task CanRoundtripSimpleDocumentAcrossTwoSessions()
        {
            string id;

            using (var session = new OrmishSession(MongoDatabase))
            {
                var someDocument = new SomeDocument {
                    Text = "i'd like to read this shit again"
                };

                id = await session.Save(someDocument);

                Console.WriteLine($"Generated ID: {id}");

                await session.SaveChanges();
            }

            using (var session = new OrmishSession(MongoDatabase))
            {
                var roundtrippedDocument = await session.Load <SomeDocument>(id);

                Assert.That(roundtrippedDocument, Is.Not.Null);
                Assert.That(roundtrippedDocument.Text, Is.EqualTo("i'd like to read this shit again"));
            }
        }
Ejemplo n.º 2
0
        public async Task LoadingNonExistentIdReturnsNull()
        {
            using (var session = new OrmishSession(MongoDatabase))
            {
                var document = await session.Load <SomeDocument>(Guid.NewGuid().ToString());

                Assert.That(document, Is.Null);
            }
        }