示例#1
0
        public void Test_RepositorReadOnlyExtended()
        {
            //Insert
            TestInsert10Assember();

            //Select a Randon index between 0 and 9 and get name selected
            int    ind       = new Random().Next(0, 9);
            string assembler = assmblers[ind];

            //Create Repository
            IRepositoryReadOnlyExtended <Assembler> RoRepository = new MyRepository <Assembler, MyContext>(this.uow, "Assemblers", new KeyValuePair <string, Type>("id", typeof(int)));

            //Test Count method
            Assert.AreEqual(10, RoRepository.Count(f => 1 == 1));

            //Test FindAll
            Assert.IsTrue(RoRepository.Exists(f => f.name == assembler));

            //Test Reload
            Assembler asb = new Assembler {
                id = ind + 1
            };

            RoRepository.Reload(ref asb);
            Assert.AreEqual(assembler, asb.name);

            //Delete
            TestClearDb();
        }