Esempio n. 1
0
        public void Persist_NoneAdded_DatabaseNotCalled()
        {
            var trackedCollection = new TrackedModelCollection <BlankAggregate>();

            var persister = new TrackedModelPersister <BlankAggregate>();
            var changes   = persister.GetChangesForWrite(trackedCollection).ToArray();

            Assert.AreEqual(0, changes.Count());
        }
Esempio n. 2
0
        public void Persist_SingleAdded_Success()
        {
            var trackedCollection = new TrackedModelCollection <BlankAggregate>();
            var model             = new BlankAggregate();

            trackedCollection.New(model);

            var persister = new TrackedModelPersister <BlankAggregate>();
            var changes   = persister.GetChangesForWrite(trackedCollection).ToArray();

            Assert.AreEqual(1, changes.Count());
            Assert.IsTrue(changes.All(c => c.ModelType == WriteModelType.InsertOne), "Expected all changes to be inserts");
        }
Esempio n. 3
0
        public void Persist_NoneRemoved_DatabaseNotCalled()
        {
            var trackedCollection = new TrackedModelCollection <GuidAggregate>();
            var model1            = new GuidAggregate();
            var model2            = new GuidAggregate();

            trackedCollection.Existing(model1);
            trackedCollection.Existing(model2);

            var persister = new TrackedModelPersister <GuidAggregate>();
            var changes   = persister.GetChangesForWrite(trackedCollection).ToArray();

            Assert.AreEqual(0, changes.Count());
        }
Esempio n. 4
0
        public void Persist_SingleUpdated_Success()
        {
            var trackedCollection = new TrackedModelCollection <FlatAggregate>();
            var model             = new FlatAggregate();

            trackedCollection.Existing(model);
            model.Name = "Jane Doe";

            var persister = new TrackedModelPersister <FlatAggregate>();
            var changes   = persister.GetChangesForWrite(trackedCollection).ToArray();

            Assert.AreEqual(1, changes.Count());
            AssertModelsUpdated(changes, model.Id);
        }
Esempio n. 5
0
        public void Persist_SingleRemoved_Success()
        {
            var trackedCollection = new TrackedModelCollection <GuidAggregate>();
            var model1            = new GuidAggregate();
            var model2            = new GuidAggregate();

            trackedCollection.Existing(model1);
            trackedCollection.Existing(model2);
            trackedCollection.Remove(model1);

            var persister = new TrackedModelPersister <GuidAggregate>();
            var changes   = persister.GetChangesForWrite(trackedCollection).ToArray();

            Assert.AreEqual(1, changes.Count());

            AssertModelsDeleted(changes, model1.Id);
        }
Esempio n. 6
0
        public void Persist_TwoUpdated_Success()
        {
            var trackedCollection = new TrackedModelCollection <FlatAggregate>();
            var model1            = new FlatAggregate();
            var model2            = new FlatAggregate();

            trackedCollection.Existing(model1);
            trackedCollection.Existing(model2);
            model1.Name = "Jane Doe";
            model2.Name = "Bob Sinclair";

            var persister = new TrackedModelPersister <FlatAggregate>();
            var changes   = persister.GetChangesForWrite(trackedCollection).ToArray();

            Assert.AreEqual(2, changes.Count());
            AssertModelsUpdated(changes, model1.Id, model2.Id);
        }