public void DeleteCustomer(Customer customer)
 {
     const string sql = "DELETE FROM Customer WHERE ID = @id";
     new FluentCommand<Customer>(sql)
         .AddGuid("id", customer.ID)
         .AsNonQuery();
 }
示例#2
0
        public void Add_Test()
        {
            var cust = new Customer
            {
                FirstName = "Chris",
                LastName = "Brandsma",
                Birthday = new DateTime(1975, 4, 2)
            };

            _dbo.AddCustomer(cust);

            Assert.IsNotNull(cust.ID);
        }
示例#3
0
        public void DeleteTest()
        {
            var cust = new Customer
            {
                FirstName = "Chris",
                LastName = "Brandsma",
                Birthday = new DateTime(1975, 4, 2)
            };

            _dbo.AddCustomer(cust);
            Assert.AreEqual(1, _dbo.GetList().Count);
            _dbo.DeleteCustomer(cust);
            Assert.AreEqual(0, _dbo.GetList().Count);
        }
示例#4
0
        public void AddFullCustomer_Test()
        {
            var cust = new Customer
            {
                FirstName = "Chris",
                LastName = "Brandsma",
                Birthday = new DateTime(1975, 4, 2),
                Height = new decimal(6.2),
                Weight = 210
            };

            _dbo.AddCustomer(cust);

            Assert.IsNotNull(cust.ID);
        }
        public void AddCustomer(Customer customer)
        {
            customer.ID = Guid.NewGuid();
            const string sql = @"INSERT INTO Customer
            (ID, FirstName, LastName, BirthDay, Height, Weight)
            VALUES (@id,@firstName,@lastName,@birthday,@height,@weight)";

            new FluentCommand<string>(sql)
                .AddGuid("id", customer.ID)
                .AddString("firstName", customer.FirstName)
                .AddString("lastName", customer.LastName)
                .AddDateTime("birthday", customer.Birthday)
                .AddDecimal("height", customer.Height)
                .AddInt("weight", customer.Weight)
                .AsNonQuery();
        }
示例#6
0
        public void AddListOfCustomers()
        {
            var cust = new Customer
            {
                FirstName = "Chris",
                LastName = "Brandsma",
                Birthday = new DateTime(1975, 4, 2),
                Height = new decimal(6.2),
                Weight = 210
            };
            var list = new List<Customer>();
            for (int i = 0; i < 20; i++)
            {
                list.Add(cust);
            }

            _dbo.AddCustomerList(list);
        }
示例#7
0
        public void Enumerator_Test()
        {
            var cust = new Customer
            {
                FirstName = "Chris",
                LastName = "Brandsma",
                Birthday = new DateTime(1975, 4, 2)
            };

            _dbo.AddCustomer(cust);
            _dbo.AddCustomer(cust);
            _dbo.AddCustomer(cust);

            var list = _dbo.GetEnumerable();
            Assert.AreEqual(3, list.Count());
        }
示例#8
0
        public void JustIdAndNameTest()
        {
            var cust = new Customer
            {
                FirstName = "Chris",
                LastName = "Brandsma",
                Birthday = new DateTime(1975, 4, 2),
                Height = new decimal(6.2),
                Weight = 210
            };

            _dbo.AddCustomer(cust);

            var list = _dbo.JustIdAndName();

            Assert.AreEqual(1, list.Count);
        }
示例#9
0
        public void GetById_Test()
        {
            var cust = new Customer
            {
                FirstName = "Chris",
                LastName = "Brandsma",
                Birthday = new DateTime(1975, 4, 2)
            };

            _dbo.AddCustomer(cust);

            var newCust = _dbo.ByID(cust.ID);
            Assert.AreEqual(cust.ID, newCust.ID);
            Assert.AreEqual(cust.FirstName, newCust.FirstName);
            Assert.AreEqual(cust.LastName , newCust.LastName);
        }