コード例 #1
0
        public void Count()
        {
            var dict = new OneToManyDictionary <string, int>();

            dict.Add("x", 42);
            dict.Add("y", 66);

            Assert.AreEqual(dict.Count, 2);
        }
コード例 #2
0
		public void IndexerGet_KeyFound_ReturnsItems()
		{
			var dict = new OneToManyDictionary<string, int>();
			dict.Add("key", 2);
			dict.Add("key", 1);

			var values = dict["key"];

			Assert.IsTrue(values.SequenceEqual(2, 1));
		}
コード例 #3
0
        public void Add_ExistingKey_DuplicateValuesIgnored()
        {
            var dict = new OneToManyDictionary <string, int>();

            dict.Add("key", 42);
            dict.Add("key", 42);

            var values = dict["key"];

            Assert.IsTrue(values.SequenceEqual(42));
        }
コード例 #4
0
        public void Remove_KeyExists_RemovesAllItems()
        {
            var dict = new OneToManyDictionary <string, int>();

            dict.Add("key", 42);
            dict.Add("key", 43);

            dict.Remove("key");

            Assert.IsFalse(dict.ContainsKey("key"));
        }
コード例 #5
0
        public void IndexerGet_KeyFound_ReturnsItems()
        {
            var dict = new OneToManyDictionary <string, int>();

            dict.Add("key", 2);
            dict.Add("key", 1);

            var values = dict["key"];

            Assert.IsTrue(values.SequenceEqual(2, 1));
        }
コード例 #6
0
        public void Add_ExistingKey_AppendsToList()
        {
            var dict = new OneToManyDictionary <string, int>();

            dict.Add("key", 42);
            dict.Add("key", 43);

            var values = dict["key"];

            Assert.IsTrue(values.SequenceEqual(42, 43));
        }
コード例 #7
0
        public void Keys_ReturnsKeys()
        {
            var dict = new OneToManyDictionary <string, int>();

            dict.Add("key2", 1);
            dict.Add("key2", 2);
            dict.Add("key1", 3);

            var keys = dict.Keys;

            Assert.IsTrue(keys.OrderBy(k => k).SequenceEqual("key1", "key2"));
        }
コード例 #8
0
        public void ContainsKey_KeyExists_ReturnsTrue()
        {
            var dict = new OneToManyDictionary <string, int>();

            dict.Add("key", 42);
            Assert.IsTrue(dict.ContainsKey("key"));
        }
コード例 #9
0
		public void IndexerSet_ExistingKey_EmptyList_ClearsItems()
		{
			var dict = new OneToManyDictionary<string, int>();
			dict.Add("key", 42);
			dict["key"] = new int[0];

			var values = dict["key"];

			Assert.IsFalse(values.Any());
		}
コード例 #10
0
		public void IndexerSet_ExistingKey_ReplacesItems()
		{
			var dict = new OneToManyDictionary<string, int>();
			dict.Add("key", 42);
			dict["key"] = new[] { 2, 3, 1 };

			var values = dict["key"];

			Assert.IsTrue(values.SequenceEqual(2, 3, 1));
		}
コード例 #11
0
        public void Add_NewKey_CreatesList()
        {
            var dict = new OneToManyDictionary <string, int>();

            dict.Add("key", 42);

            var values = dict["key"];

            Assert.IsTrue(values.SequenceEqual(42));
        }
コード例 #12
0
        public void IndexerSet_ExistingKey_EmptyList_ClearsItems()
        {
            var dict = new OneToManyDictionary <string, int>();

            dict.Add("key", 42);
            dict["key"] = new int[0];

            var values = dict["key"];

            Assert.IsFalse(values.Any());
        }
コード例 #13
0
		public void Keys_ReturnsKeys()
		{
			var dict = new OneToManyDictionary<string, int>();
			dict.Add("key2", 1);
			dict.Add("key2", 2);
			dict.Add("key1", 3);

			var keys = dict.Keys;

			Assert.IsTrue(keys.OrderBy(k => k).SequenceEqual("key1", "key2"));
		}
コード例 #14
0
        public void IndexerSet_ExistingKey_ReplacesItems()
        {
            var dict = new OneToManyDictionary <string, int>();

            dict.Add("key", 42);
            dict["key"] = new[] { 2, 3, 1 };

            var values = dict["key"];

            Assert.IsTrue(values.SequenceEqual(2, 3, 1));
        }
コード例 #15
0
		public void Add_ExistingKey_DuplicateValuesIgnored()
		{
			var dict = new OneToManyDictionary<string, int>();
			dict.Add("key", 42);
			dict.Add("key", 42);

			var values = dict["key"];

			Assert.IsTrue(values.SequenceEqual(42));
		}
コード例 #16
0
		public void ContainsKey_KeyExists_ReturnsTrue()
		{
			var dict = new OneToManyDictionary<string, int>();
			dict.Add("key", 42);
			Assert.IsTrue(dict.ContainsKey("key"));
		}
コード例 #17
0
		public void Remove_KeyExists_RemovesAllItems()
		{
			var dict = new OneToManyDictionary<string, int>();
			dict.Add("key", 42);
			dict.Add("key", 43);

			dict.Remove("key");

			Assert.IsFalse(dict.ContainsKey("key"));
		}
コード例 #18
0
		public void Count()
		{
			var dict = new OneToManyDictionary<string, int>();
			dict.Add("x", 42);
			dict.Add("y", 66);

			Assert.AreEqual(dict.Count, 2);
		}
コード例 #19
0
		public void Add_NewKey_CreatesList()
		{
			var dict = new OneToManyDictionary<string, int>();
			dict.Add("key", 42);

			var values = dict["key"];

			Assert.IsTrue(values.SequenceEqual(42));
		}
コード例 #20
0
		public void AddRange_ExistingKey_AppendsToList()
		{
			var dict = new OneToManyDictionary<string, int>();
			dict.Add("key", 42);
			dict.AddRange("key", new[] { 43, 44 });

			var values = dict["key"];

			Assert.IsTrue(values.SequenceEqual(42, 43, 44));
		}