public void Persist_TwoRemoved_Success() { var trackedCollection = new TrackedModelCollection <GuidAggregate>(); var model1 = new GuidAggregate(); var model2 = new GuidAggregate(); trackedCollection.Existing(model1); trackedCollection.Existing(model2); trackedCollection.Remove(model1); trackedCollection.Remove(model2); var persister = new TrackedModelPersister <GuidAggregate>(); var changes = persister.GetChangesForWrite(trackedCollection).ToArray(); Assert.AreEqual(2, changes.Count()); AssertModelsDeleted(changes, model1.Id, model2.Id); }
public void Remove_Absent_Failure() { var collection = new TrackedModelCollection <BlankAggregate>(); var model = new BlankAggregate(); Assert.Throws <KeyNotFoundException>(() => { collection.Remove(model); }); }
public void Remove_MultipleExisting_Success() { var collection = new TrackedModelCollection <BlankAggregate>(); var model1 = new BlankAggregate(); var model2 = new BlankAggregate(); collection.Existing(model1); collection.Existing(model2); Assert.DoesNotThrow(() => { collection.Remove(model1); collection.Remove(model2); }); var removedModels = collection.OfState(TrackedModelState.Removed).Select(m => m.Model).ToList(); CollectionAssert.Contains(removedModels, model1); CollectionAssert.Contains(removedModels, model2); }
public void Remove_SingleExisting_Success() { var collection = new TrackedModelCollection <BlankAggregate>(); var model = new BlankAggregate(); collection.Existing(model); Assert.DoesNotThrow(() => { collection.Remove(model); }); CollectionAssert.Contains(collection.OfState(TrackedModelState.Removed).Select(m => m.Model), model); }
public void Remove_Added_Success() { var collection = new TrackedModelCollection <BlankAggregate>(); var model = new BlankAggregate(); collection.New(model); Assert.DoesNotThrow(() => { collection.Remove(model); }); CollectionAssert.DoesNotContain(collection.Select(m => m.Model), model); }
public void Add_RemovedModel_Success() { var collection = new TrackedModelCollection <BlankAggregate>(); var model = new BlankAggregate(); collection.Existing(model); collection.Remove(model); Assert.DoesNotThrow(() => { collection.New(model); }); Assert.AreEqual(model, collection.OfState(TrackedModelState.Existing).SingleOrDefault()?.Model); }
public void Remove_Null_Failure() { var collection = new TrackedModelCollection <BlankAggregate>(); Assert.Throws <ArgumentNullException>(() => { collection.Remove(null); }); }