예제 #1
0
        public void Initializes_Memory_Only_List_With_True_Argument()
        {
            _biggyMemoryList = new BiggyList <Widget>(inMemory: true);
            var BiggyJsonList = new BiggyList <Widget>();

            _biggyMemoryList.Clear();
            BiggyJsonList.Clear();

            var batch = new List <Widget>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                batch.Add(new Widget {
                    SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i
                });
            }
            _biggyMemoryList.Add(batch);
            BiggyJsonList.Add(batch);

            int memoryCount = _biggyMemoryList.Count();

            _biggyMemoryList.Clear();

            BiggyJsonList = new BiggyList <Widget>();

            Assert.True(memoryCount == INSERT_QTY && _biggyMemoryList.Count() == 0 && BiggyJsonList.Count() == INSERT_QTY);
        }
예제 #2
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 PGStore <Client>(_connectionStringName));
            int loadedCount = _clients.Count();

            _clients.Clear();

            // Reload the list:
            _clients = new BiggyList <Client>(new PGStore <Client>(_connectionStringName));
            int clearedCount = _clients.Count();

            Assert.True(loadedCount == INSERT_QTY && clearedCount == 0);
        }
예제 #3
0
 public void Clears_List_But_Not_Store()
 {
     _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true);
       _biggyMemoryList.Clear();
       var storeWidgets = _widgetStore.Load();
       Assert.True(_biggyMemoryList.Count() == 0 && storeWidgets.Count == INSERT_QTY);
 }
예제 #4
0
        public void Clears_List_But_Not_Store()
        {
            _biggyMemoryList = new BiggyList <Widget>(_widgetStore, inMemory: true);
            _biggyMemoryList.Clear();
            var storeWidgets = _widgetStore.Load();

            Assert.True(_biggyMemoryList.Count() == 0 && storeWidgets.Count == INSERT_QTY);
        }
예제 #5
0
        public void Initializes_List_With_Json_Default_Store()
        {
            _biggyMemoryList = new BiggyList <Widget>();
            _biggyMemoryList.Clear();
            var batch = new List <Widget>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                batch.Add(new Widget {
                    SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i
                });
            }
            _biggyMemoryList.Add(batch);
            Assert.True(_biggyMemoryList.Count() == INSERT_QTY);
        }
예제 #6
0
        public void Adds_Item_To_List_And_Store()
        {
            _biggyWidgetList.Clear();
            _biggyWidgetList.Add(new Widget {
                SKU = "001", Name = "Test widget 1", Price = 2.00M
            });

            // Reload the list:
            _biggyWidgetList = new BiggyList <Widget>(_widgets);
            var addedItem = _biggyWidgetList.FirstOrDefault(w => w.SKU == "001");

            Assert.True(addedItem != null && _biggyWidgetList.Count() == 1);
        }
예제 #7
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 PGStore <Client>(_connectionStringName));

            Assert.True(altClientList.Count() > 0);
        }
예제 #8
0
        public void Clears_List_and_Store()
        {
            int INSERT_QTY = 100;

            var addRange = new List <MonkeyDocument>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                addRange.Add(new MonkeyDocument {
                    Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back"
                });
            }
            var inserted = _monkeyDocuments.Add(addRange);

            // Reload, make sure everything was persisted:
            _monkeyDocuments = new BiggyList <MonkeyDocument>(new PGDocumentStore <MonkeyDocument>(_connectionStringName));

            _monkeyDocuments.Clear();

            // Reload, make sure everything was persisted:
            _monkeyDocuments = new BiggyList <MonkeyDocument>(new PGDocumentStore <MonkeyDocument>(_connectionStringName));

            Assert.True(_monkeyDocuments.Count() == 0);
        }
예제 #9
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>(_clientStore);
              int loadedCount = _clients.Count();
              _clients.Clear();

              // Reload the list:
              _clients = new BiggyList<Client>(_clientStore);
              int clearedCount = _clients.Count();
              Assert.True(loadedCount == INSERT_QTY && clearedCount == 0);
        }
예제 #10
0
 public void Initializes_List_With_Json_Default_Store()
 {
     _biggyMemoryList = new BiggyList<Widget>();
       _biggyMemoryList.Clear();
       var batch = new List<Widget>();
       for (int i = 0; i < INSERT_QTY; i++) {
     batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i });
       }
       _biggyMemoryList.Add(batch);
       Assert.True(_biggyMemoryList.Count() == INSERT_QTY);
 }
예제 #11
0
        public void Initializes_Memory_Only_List_With_True_Argument()
        {
            _biggyMemoryList = new BiggyList<Widget>(inMemory: true);
              var BiggyJsonList = new BiggyList<Widget>();
              _biggyMemoryList.Clear();
              BiggyJsonList.Clear();

              var batch = new List<Widget>();
              for (int i = 0; i < INSERT_QTY; i++) {
            batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i });
              }
              _biggyMemoryList.Add(batch);
              BiggyJsonList.Add(batch);

              int memoryCount = _biggyMemoryList.Count();
              _biggyMemoryList.Clear();

              BiggyJsonList = new BiggyList<Widget>();

              Assert.True(memoryCount == INSERT_QTY && _biggyMemoryList.Count() == 0 && BiggyJsonList.Count() == INSERT_QTY);
        }
예제 #12
0
        public void Clears_List_and_Store()
        {
            int INSERT_QTY = 100;

              var addRange = new List<MonkeyDocument>();
              for (int i = 0; i < INSERT_QTY; i++) {
            addRange.Add(new MonkeyDocument { Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" });
              }
              var inserted = _monkeyDocuments.Add(addRange);

              // Reload, make sure everything was persisted:
              _monkeyDocuments = new BiggyList<MonkeyDocument>(new SqlCeDocumentStore<MonkeyDocument>(_connectionStringName));

              _monkeyDocuments.Clear();

              // Reload, make sure everything was persisted:
              _monkeyDocuments = new BiggyList<MonkeyDocument>(new SqlCeDocumentStore<MonkeyDocument>(_connectionStringName));

              Assert.True(_monkeyDocuments.Count() == 0);
        }