public void FindAll_Filter_FiltedResults() { var unitOfWork = new MemoryUnitOfWork(); var target = CreateClient(); target.ClearAll(); target.SetUnitOfWork(unitOfWork); var data = new SimpleDataStub(); data.Name = "TEST_1"; target.Add(data); data = new SimpleDataStub(); data.Name = "TEST_2"; target.Add(data); unitOfWork.Commit(); Assert.AreEqual(2, target.FindAll().Count()); Assert.AreEqual(2, target.FindAll(0, 2).Count()); Assert.AreEqual(1, target.FindAll(0, 1).Count()); Assert.AreEqual(1, target.FindAll(1, 2).Count()); Assert.AreEqual(2, target.FindAll(c => c.Name.StartsWith("TEST")).Count()); Assert.AreEqual(2, target.FindAll(c => c.Name.Contains("_")).Count()); Assert.AreEqual(1, target.FindAll(c => c.Name.EndsWith("_1")).Count()); Assert.AreEqual(1, target.FindAll(c => c.Name.EndsWith("_2")).Count()); }
public void Pesists_Item_Persisted() { var unitOfWork = new MemoryUnitOfWork(); var target = CreateClient(); target.ClearAll(); target.SetUnitOfWork(unitOfWork); var data = new SimpleDataStub(); data.Name = "TEST_1"; target.Add(data); data = new SimpleDataStub(); data.Name = "TEST_2"; target.Add(data); unitOfWork.Commit(); var actual = target.FindAll().ToList(); Assert.AreEqual(2, actual.Count); Assert.AreEqual("TEST_1", actual[0].Name); Assert.AreEqual("TEST_2", actual[1].Name); var actualRecord = actual[1]; actualRecord.Name += " (UPDATED)"; target[actualRecord.Id] = actualRecord; target.Remove(actual[0]); unitOfWork.Commit(); actual = target.FindAll().ToList(); Assert.AreEqual(1, actual.Count); Assert.AreEqual("TEST_2 (UPDATED)", actual[0].Name); }
public void PersistNewItem_Item_PersistedOnDropbox() { var unitOfWork = new MemoryUnitOfWork(); var target = CreateClient(); target.ClearAll(); target.SetUnitOfWork(unitOfWork); var data = new SimpleDataStub(); data.Name = "Test1"; target.Add(data); var originalCount = target.CountAll(); unitOfWork.Commit(); Assert.AreEqual(originalCount + 1, target.CountAll()); }
public void PersistDeletedItem_Item_PersistedOnGData() { var unitOfWork = new MemoryUnitOfWork(); var target = CreateTarget(); target.SetUnitOfWork(unitOfWork); var originalCount = target.CountAll(); var all = target.FindAll(); var toDelete = all.FirstOrDefault(); if (toDelete != null) { target.Remove(toDelete); unitOfWork.Commit(); Assert.AreEqual(originalCount - 1, target.CountAll()); } }
public void PersistUpdatedItem_Item_PersistedOnGData() { var unitOfWork = new MemoryUnitOfWork(); var target = CreateTarget(); target.SetUnitOfWork(unitOfWork); var originalCount = target.CountAll(); var all = target.FindAll(); var toUpdate = all.First(); toUpdate.Name = "updated"; target[toUpdate.Id] = toUpdate; unitOfWork.Commit(); Assert.AreEqual(originalCount, target.CountAll()); var actual = target.FindBy(toUpdate.Id); Assert.AreEqual("updated", actual.Name); }
public void PersistNewItem_Item_PersistedOnGData() { var unitOfWork = new MemoryUnitOfWork(); var target = CreateTarget(); target.SetUnitOfWork(unitOfWork); var data = new SimpleDataStub(); data.CreatedDate = DateTime.Now; data.Enabled = true; data.Name = "The name"; data.Size = 100; target.Add(data); var originalCount = target.CountAll(); unitOfWork.Commit(); Assert.AreEqual(originalCount + 1, target.CountAll()); var actual = target.FindBy(data.Id); Assert.AreEqual("The name", actual.Name); }