Exemplo n.º 1
0
        public void IsDeleting()
        {
            var obj = Test.Create();

            obj.Update("Test_Is_Write", 11000011);

            var objId = obj.Id;

            var writeRepo = new ReadWriteRepository(GetDbContext());

            writeRepo.Create <Test, Guid>(obj);

            //THIS IS NOT DONE IN PRODUCTION
            writeRepo.Commit();

            var readRepo = new ReadOnlyRepository(GetDbContext());

            var testObj = readRepo.GetById <Test, Guid>(objId);

            Assert.AreEqual(obj.Name, testObj.Name);
            Assert.AreEqual(obj.Value, testObj.Value);

            writeRepo.Delete <Test, Guid>(obj);

            writeRepo.Commit();

            var table = readRepo.Table <Test, Guid>().Where(o => o.Id.Equals(obj.Id)).ToList();

            Assert.AreEqual(table.Count, 0);
        }
Exemplo n.º 2
0
        public static D GetById(ReadOnlyRepository <S> repo, object id)
        {
            var item = repo.GetById(id);

            if (item != null)
            {
                var model = Mapper.Map <S, D>(item);
                return(model);
            }
            return(null);
        }
Exemplo n.º 3
0
        public void IsWritingUpdate()
        {
            var writeRepo = new ReadWriteRepository(GetDbContext());

            var obj = writeRepo.Table <Test, Guid>().First();

            var testId    = obj.Id;
            var valueTest = obj.Value + 1;

            obj.Update(obj.Name, valueTest);

            //THIS IS NOT DONE IN PRODUCTION
            writeRepo.Commit();

            var readRepo = new ReadOnlyRepository(GetDbContext());

            var testObj = readRepo.GetById <Test, Guid>(testId);

            Assert.AreEqual(valueTest, testObj.Value);
        }
Exemplo n.º 4
0
        public void IsWritingAdd()
        {
            var obj = Test.Create();

            obj.Update("Test_Is_Write", 11000011);

            var objId = obj.Id;

            var writeRepo = new ReadWriteRepository(GetDbContext());

            writeRepo.Create <Test, Guid>(obj);

            //THIS IS NOT DONE IN PRODUCTION
            writeRepo.Commit();

            var readRepo = new ReadOnlyRepository(GetDbContext());

            var testObj = readRepo.GetById <Test, Guid>(objId);

            Assert.AreEqual(obj.Name, testObj.Name);
            Assert.AreEqual(obj.Value, testObj.Value);
        }