public void Save_Ok()
        {
            ClearRepo();

            var cust = NewCustomer();

            cust.Address           = NewAddress();
            cust.Address.DateAdded = new DateTime(2016, 1, 1);

            var newCust = _customerRepo.Save(cust);

            Assert.Equal(1, _customerRepo.Count());
            Assert.NotNull(newCust);
            Assert.Equal("Hidden Valley", newCust.Address.City);

            DumpRepo();
            newCust.PrintDump();
        }
Ejemplo n.º 2
0
        public void RemoveById_Ok()
        {
            ClearCustomerRepo();

            _customerRepo.SaveAll(NewCustomers());

            var one = _customerRepo.One(x => x.Email.Equals("*****@*****.**"));

            Console.WriteLine("Removing Id: {0}", one.Id);
            _customerRepo.Remove(one.Id);

            Assert.Equal(2, _customerRepo.Count());

            var cust = _customerRepo.One(one.Id);

            Assert.Null(cust);

            DumpRepo();
        }
Ejemplo n.º 3
0
        public void Count()
        {
            ClearDapperCompisiteKeyEntity();
            try
            {
                CreateDapperCompisiteKeyEntity(1, 1, "2", "2", "5", "5");
                CreateDapperCompisiteKeyEntity(1, 2, "2", "4", "5", "2");
                CreateDapperCompisiteKeyEntity(2, 2, "3", "4", "5", "2");
                CreateDapperCompisiteKeyEntity(3, 3, "3", "4", "5", "2");
                CreateDapperCompisiteKeyEntity(4, 3, "3", "4", "5", "2");

                int count = _dapper.Count();
                Assert.Equal(5, count);
            }
            finally
            {
                ClearDapperCompisiteKeyEntity();
            }
        }
Ejemplo n.º 4
0
        public void CustomMapping_Save_Ok()
        {
            var repo = new DapperRepository <Customer>(_fixture.Settings, () =>
            {
                DapperExtensions.DapperExtensions.DefaultMapper = typeof(CustomMapper <>);
            });

            ClearCustomerRepo();

            var cust = NewCustomer();

            cust.Address = NewAddress();

            var newCust = repo.Save(cust);

            Assert.Equal(1, repo.Count());
            Assert.NotNull(newCust);

            newCust.PrintDump();
        }