Esempio n. 1
0
 public void DeleteCustomer(Customer customer)
 {
     const string sql = "DELETE FROM Customer WHERE ID = @id";
     new FluentCommand<Customer>(sql)
         .AddGuid("id", customer.ID)
         .AsNonQuery();
 }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 5
0
        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();
        }
Esempio n. 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);
        }
Esempio n. 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());
        }
Esempio n. 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);
        }
Esempio n. 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);
        }