Exemplo n.º 1
0
        public void Test03_Batch()
        {
            var doc = new Doc2 {
                Name = "Dogman", List = new List <Doc1> {
                    new Doc1 {
                        S1 = "1", S2 = "01", I1 = 15
                    },
                    new Doc1 {
                        S1 = "2", S2 = "sf01", I1 = 1555
                    },
                    new Doc1 {
                        S1 = "323456", S2 = "gdfg01", I1 = -1
                    }
                }
            };

            var got = doc.Validate(new ValidState(null, ValidErrorMode.Batch));

            got.See();

            Aver.IsTrue(got.IsAssigned);
            Aver.IsTrue(got.HasErrors);
            Aver.IsFalse(got.NoErrors);
            Aver.AreEqual(7, got.ErrorCount);
            Aver.IsTrue(got.ShouldContinue);
            Aver.IsFalse(got.ShouldStop);
            Aver.IsNotNull(got.Error);

            var batch = got.Error as ValidationBatchException;

            Aver.IsNotNull(batch);
            Aver.IsNotNull(batch.Batch);
            Aver.AreEqual(7, batch.Batch.Count);
        }
Exemplo n.º 2
0
        public void demonstration()
        {
            using (var store = DocumentStore.For(_ =>
            {
                _.DatabaseSchemaName = "setting_timestamp";
                _.Connection(ConnectionSource.ConnectionString);
                _.AutoCreateSchemaObjects = AutoCreate.All;
                _.Listeners.Add(new TimestampListener());
            }))
            {
                var doc1s = new Doc1[] { new Doc1(), new Doc1(), };
                var doc2s = new Doc2[] { new Doc2(), new Doc2(), };
                var doc3s = new Doc3[] { new Doc3(), new Doc3(), };

                using (var session = store.OpenSession())
                {
                    session.Store(doc1s);
                    session.Store(doc2s);
                    session.Store(doc3s);

                    session.SaveChanges();
                }

                doc1s.Each(x => x.Timestamp.ShouldNotBeNull());
                doc2s.Each(x => x.Timestamp.ShouldNotBeNull());
                doc3s.Each(x => x.Timestamp.ShouldNotBeNull());
            }
        }
        public void demonstration()
        {
            using (var store = DocumentStore.For(_ =>
            {
                _.Connection(ConnectionSource.ConnectionString);
                _.AutoCreateSchemaObjects = AutoCreate.All;
                _.Listeners.Add(new TimestampListener());
            }))
            {
                var doc1s = new Doc1[] {new Doc1(), new Doc1(), };
                var doc2s = new Doc2[] {new Doc2(), new Doc2(), };
                var doc3s = new Doc3[] {new Doc3(), new Doc3(), };

                using (var session = store.OpenSession())
                {
                    session.Store(doc1s);
                    session.Store(doc2s);
                    session.Store(doc3s);

                    session.SaveChanges();
                }

                doc1s.Each(x => x.Timestamp.ShouldNotBeNull());
                doc2s.Each(x => x.Timestamp.ShouldNotBeNull());
                doc3s.Each(x => x.Timestamp.ShouldNotBeNull());
            }
        }