Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        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());
        }
Esempio n. 3
0
        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);
        }