Ejemplo n.º 1
0
 public void IBiggyStore_Adds_Record()
 {
     _biggyStore = new SqlCeStore<Client>(_connectionStringName);
       var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
       _biggyStore.Add(newClient);
       Assert.True(newClient.ClientId > 0);
 }
Ejemplo n.º 2
0
        public void Adds_Item_To_List_And_Store()
        {
            // Just in case:
              _clients.Clear();
              var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              _clients.Add(newClient);

              // Open a new instance, to see if the item was added to the backing store as well:
              var altClientList = new BiggyList<Client>(new SqlCeStore<Client>(_connectionStringName));
              Assert.True(altClientList.Count() > 0);
        }
Ejemplo n.º 3
0
        public void IBiggyStore_Adds_Many_Records()
        {
            _biggyStore = new SqlCeStore<Client>(_connectionStringName);
              var insertThese = new List<Client>();

              for(int i = 0; i < 10; i++) {
            var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" };
            insertThese.Add(newClient);
              }
              _biggyStore.Add(insertThese);
              var newClients = _biggyStore.Load();
              Assert.True(newClients.Count > 0);
        }
Ejemplo n.º 4
0
        public void Adds_Many_Items_To_List_And_Store()
        {
            int INSERT_QTY = 10;
              // Just in case:
              _clients.Clear();
              var addThese = new List<Client>();
              for (int i = 0; i < INSERT_QTY; i++) {
            var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" };
            addThese.Add(newClient);
              }
              _clients.Add(addThese);

              // Open a new instance, to see if the item was added to the backing store as well:
              var altClientList = new BiggyList<Client>(new SqlCeStore<Client>(_connectionStringName));
              Assert.True(altClientList.Count() == INSERT_QTY);
        }
Ejemplo n.º 5
0
        public void Clears_All_Items_From_List_And_Store()
        {
            int INSERT_QTY = 10;

              // Just in case:
              _clients.Clear();
              var addThese = new List<Client>();
              for (int i = 0; i < INSERT_QTY; i++) {
            var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" };
            addThese.Add(newClient);
              }
              _clients.Add(addThese);

              // Reload the list:
              _clients = new BiggyList<Client>(new SqlCeStore<Client>(_connectionStringName));
              int loadedCount = _clients.Count();
              _clients.Clear();

              // Reload the list:
              _clients = new BiggyList<Client>(new SqlCeStore<Client>(_connectionStringName));
              int clearedCount = _clients.Count();
              Assert.True(loadedCount == INSERT_QTY && clearedCount == 0);
        }
Ejemplo n.º 6
0
        public void Updates_Item_From_List_And_Store()
        {
            // Just in case:
              _clients.Clear();
              var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              _clients.Add(newClient);
              _clients = new BiggyList<Client>(new SqlCeStore<Client>(_connectionStringName));
              var updateMe = _clients.FirstOrDefault();
              updateMe.LastName = "Appleseed";
              _clients.Update(updateMe);

              // Open a new instance, to see if the item was added to the backing store as well:
              var altClientList = new BiggyList<Client>(new SqlCeStore<Client>(_connectionStringName));
              var updated = altClientList.FirstOrDefault(c => c.LastName == "Appleseed");
              Assert.True(updated != null && updated.LastName == "Appleseed");
        }
Ejemplo n.º 7
0
        public void Removes_Many_Items_From_List_And_Store()
        {
            int INSERT_QTY = 10;

              // Just in case:
              _clients.Clear();
              var addThese = new List<Client>();
              for (int i = 0; i < INSERT_QTY; i++) {
            var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" };
            addThese.Add(newClient);
              }
              _clients.Add(addThese);

              // Open a new instance, to see if the item was added to the backing store as well:
              var altClientArray = new BiggyList<Client>(new SqlCeStore<Client>(_connectionStringName)).ToArray();

              var removeThese = new List<Client>();
              for (int i = 0; i < 5; i++) {
            removeThese.Add(altClientArray[i]);
              }

              _clients.Remove(removeThese);
              // Reload the list:
              _clients = new BiggyList<Client>(new SqlCeStore<Client>(_connectionStringName));
              Assert.True(_clients.Count() == (INSERT_QTY - removeThese.Count()));
        }
Ejemplo n.º 8
0
        public void Removes_Item_From_List_And_Store()
        {
            // Just in case:
              _clients.Clear();
              var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              _clients.Add(newClient);

              int firstCount = _clients.Count();

              // Open a new instance, to see if the item was added to the backing store as well:
              var altClientList = new BiggyList<Client>(new SqlCeStore<Client>(_connectionStringName));
              var deleteMe = altClientList.FirstOrDefault();
              altClientList.Remove(deleteMe);
              Assert.True(firstCount > 0 && altClientList.Count() == 0);
        }
Ejemplo n.º 9
0
        public void IUpdateableBiggyStore_Deletes_Many_Records()
        {
            _updateableStore = new SqlCeStore<Client>(_connectionStringName) as IUpdateableBiggyStore<Client>;
              var insertThese = new List<Client>();

              for (int i = 0; i < 10; i++) {
            var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" };
            insertThese.Add(newClient);
              }
              _updateableStore.Add(insertThese);
              var newClients = _updateableStore.Load();

              _updateableStore.Remove(newClients);
              newClients = _updateableStore.Load();
              Assert.True(newClients.Count == 0);
        }
Ejemplo n.º 10
0
 public void IQueryableBiggyStore_Finds_Record()
 {
     _queryableStore = new SqlCeStore<Client>(_connectionStringName);
       var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
       _queryableStore.Add(newClient);
       var foundClient = _queryableStore.AsQueryable().FirstOrDefault(c => c.LastName == "Atten");
       Assert.True(foundClient.LastName == "Atten");
 }
Ejemplo n.º 11
0
        public void IUpdateableBiggyStore_Updates_Record()
        {
            _updateableStore = new SqlCeStore<Client>(_connectionStringName) as IUpdateableBiggyStore<Client>;
              var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              _updateableStore.Add(newClient);

              // Stow the id so we can reload, then update (just to be SURE!!)
              int idToFind = newClient.ClientId;
              newClient = _updateableStore.Load().FirstOrDefault(c => c.ClientId == idToFind);
              newClient.FirstName = "John Paul";
              newClient.LastName = "Jones";
              _updateableStore.Update(newClient);

              var updatedClient = _updateableStore.Load().FirstOrDefault(c => c.ClientId == idToFind);
              Assert.True(updatedClient.LastName == "Jones");
        }
Ejemplo n.º 12
0
        public void IUpdateableBiggyStore_Deletes_Record()
        {
            _updateableStore = new SqlCeStore<Client>(_connectionStringName) as IUpdateableBiggyStore<Client>;
              var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              _updateableStore.Add(newClient);

              // Stow the id so we can reload, then update (just to be SURE!!)
              int idToFind = newClient.ClientId;
              newClient = _updateableStore.Load().FirstOrDefault(c => c.ClientId == idToFind);

              var deleteMe = _updateableStore.Load().FirstOrDefault(c => c.ClientId == idToFind);
              _updateableStore.Remove(deleteMe);
              var clients = _updateableStore.Load();
              Assert.True(clients.Count == 0);
        }