public void Test_Clear()
        {
            const string key = "CouchbaseDictionaryTests.Test_Clear";
            _bucket.Remove(key);

            var dictionary = new CouchbaseDictionary<string, Poco>(_bucket, key);
            dictionary.Add("somekey1", new Poco { Name = "poco1" });
            dictionary.Add("somekey2", new Poco { Name = "poco2" });

            dictionary.Clear();
            var count = dictionary.Count;

            Assert.AreEqual(0, count);
        }
Ejemplo n.º 2
0
        public void Test_Clear()
        {
            const string key = "CouchbaseDictionaryTests.Test_Clear";

            _bucket.Remove(key);

            var dictionary = new CouchbaseDictionary <string, Poco>(_bucket, key);

            dictionary.Add("somekey1", new Poco {
                Name = "poco1"
            });
            dictionary.Add("somekey2", new Poco {
                Name = "poco2"
            });

            dictionary.Clear();
            var count = dictionary.Count;

            Assert.AreEqual(0, count);
        }
Ejemplo n.º 3
0
        private static void DictionaryDemo(IBucket bucket)
        {
            //var dictionary = new Dictionary<string, PizzaEmployee>();
            var dictionary = new CouchbaseDictionary <string, PizzaEmployee>(bucket, "Dictionary_PizzaStaff");

            dictionary.Clear();

            dictionary.Add("Matt", new PizzaEmployee {
                Shift = "8-5", HourlyWage = 7.25M
            });
            dictionary.Add("Mary", new PizzaEmployee {
                Shift = "5-12", HourlyWage = 8.25M
            });

            foreach (var key in dictionary.Keys)
            {
                Console.WriteLine($"Employee '{key}' makes {dictionary[key].HourlyWage}/hour");
            }
            Console.WriteLine();

            dictionary.Add("Hiro", new PizzaEmployee {
                Shift = "5-12", HourlyWage = 10.25M
            });

            try
            {
                dictionary.Add("Matt", new PizzaEmployee {
                    Shift = "8-12", HourlyWage = 20.00M
                });
            }
            catch (ArgumentException)
            {
                Console.WriteLine("Can't add 'Matt' to the dictionary twice.");
                Console.WriteLine();
            }

            foreach (var key in dictionary.Keys)
            {
                Console.WriteLine($"Employee '{key}' makes {dictionary[key].HourlyWage}/hour");
            }
        }