示例#1
0
        public void GetEnumerator()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("goose", 1, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("hello", 12, 0, WordLocation.Content);

            collection.Add(mi2);
            collection.Add(mi1);

            int count = 0;

            foreach (WordInfo r in collection)
            {
                if (count == 0)
                {
                    Assert.AreEqual(mi1, r, "Wrong item at position 0");
                }

                if (count == 1)
                {
                    Assert.AreEqual(mi2, r, "Wrong item at position 1");
                }

                count++;
            }
            Assert.AreEqual(2, count, "Wrong count - enumerator does not work");
        }
示例#2
0
        public void CopyTo()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("goose", 34, 0, WordLocation.Content);

            collection.Add(mi1);
            collection.Add(mi2);

            WordInfo[] matches = new WordInfo[2];
            collection.CopyTo(matches, 0);

            Assert.AreEqual(mi1, matches[0], "Wrong match item");
            Assert.AreEqual(mi2, matches[1], "Wrong match item");

            matches = new WordInfo[3];
            collection.CopyTo(matches, 0);

            Assert.AreEqual(mi1, matches[0], "Wrong match item");
            Assert.AreEqual(mi2, matches[1], "Wrong match item");
            Assert.IsNull(matches[2], "Non-null item");

            matches = new WordInfo[3];
            collection.CopyTo(matches, 1);

            Assert.IsNull(matches[0], "Non-null item");
            Assert.AreEqual(mi1, matches[1], "Wrong match item");
            Assert.AreEqual(mi2, matches[2], "Wrong match item");
        }
        public void GetEnumerator()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("goose", 1, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("hello", 12, 0, WordLocation.Content);

            collection.Add(mi2);
            collection.Add(mi1);

            int count = 0;

            foreach (WordInfo r in collection)
            {
                if (count == 0)
                {
                    Assert.Equal(mi1, r);
                }
                if (count == 1)
                {
                    Assert.Equal(mi2, r);
                }
                count++;
            }
            Assert.Equal(2, count);
        }
        public void CopyTo()
        {
            WordInfoCollection sut = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("goose", 34, 0, WordLocation.Content);

            sut.Add(mi1);
            sut.Add(mi2);

            WordInfo[] matches = new WordInfo[2];
            sut.CopyTo(matches, 0);

            Assert.Equal(mi1, matches[0]);
            Assert.Equal(mi2, matches[1]);

            matches = new WordInfo[3];
            sut.CopyTo(matches, 0);

            Assert.Equal(mi1, matches[0]);
            Assert.Equal(mi2, matches[1]);
            Assert.Null(matches[2]);

            matches = new WordInfo[3];
            sut.CopyTo(matches, 1);

            Assert.Null(matches[0]);
            Assert.Equal(mi1, matches[1]);
            Assert.Equal(mi2, matches[2]);
        }
        public void Indexer()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("taskbar", 1, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("goose", 12, 0, WordLocation.Content);

            collection.Add(mi2);
            collection.Add(mi1);

            Assert.Equal(mi1, collection[0]);
            Assert.Equal(mi2, collection[1]);
        }
示例#6
0
        public void Indexer()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("taskbar", 1, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("goose", 12, 0, WordLocation.Content);

            collection.Add(mi2);
            collection.Add(mi1);

            Assert.AreEqual(mi1, collection[0], "Wrong item at position 0");
            Assert.AreEqual(mi2, collection[1], "Wrong item at position 0");
        }
        public void Clear()
        {
            WordInfoCollection sut = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("taskbar", 21, 1, WordLocation.Content);

            sut.Add(mi1);
            sut.Add(mi2);
            Assert.Equal(2, sut.Count);

            sut.Clear();
            Assert.Empty(sut);
        }
示例#8
0
        public void CopyTo_NoSpaceAtIndex()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("home", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("taskbar", 100, 0, WordLocation.Content);

            collection.Add(mi1);
            collection.Add(mi2);

            WordInfo[] matches = new WordInfo[2];

            Assert.Throws <ArgumentOutOfRangeException>(() => collection.CopyTo(matches, 1));
        }
示例#9
0
        public void CopyTo_NoSpaceAtIndex()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("home", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("taskbar", 100, 0, WordLocation.Content);

            collection.Add(mi1);
            collection.Add(mi2);

            WordInfo[] matches = new WordInfo[2];

            collection.CopyTo(matches, 1);
        }
示例#10
0
        public void AddAndCount()
        {
            var collection = new WordInfoCollection();

            var mi1 = new WordInfo("continuous", 0, 0, WordLocation.Content);
            var mi2 = new WordInfo("taskbar", 21, 1, WordLocation.Content);

            Assert.AreEqual(0, collection.Count, "Wrong count (collection should be empty)");
            collection.Add(mi2);
            collection.Add(mi1);
            Assert.AreEqual(2, collection.Count, "Wrong count (collection should contain 2 items)");
            Assert.AreEqual(mi1, collection[0], "Wrong item at index 0");
            Assert.AreEqual(mi2, collection[1], "Wrong item at index 1");
        }
        public void Clear()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("taskbar", 21, 1, WordLocation.Content);

            collection.Add(mi1);
            collection.Add(mi2);
            Assert.AreEqual(2, collection.Count, "Wrong count (collection should contain 2 items)");

            collection.Clear();
            Assert.AreEqual(0, collection.Count, "Wrong count (collection should be empty)");
        }
示例#12
0
        public void Clear()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("taskbar", 21, 1, WordLocation.Content);

            collection.Add(mi1);
            collection.Add(mi2);
            Assert.AreEqual(2, collection.Count, "Wrong count (collection should contain 2 items)");

            collection.Clear();
            Assert.AreEqual(0, collection.Count, "Wrong count (collection should be empty)");
        }
示例#13
0
        public void CopyTo_ArrayTooSmall()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("home", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("taskbar", 100, 0, WordLocation.Content);

            collection.Add(mi1);
            collection.Add(mi2);

            WordInfo[] matches = new WordInfo[1];

            collection.CopyTo(matches, 0);
        }
        public void CopyTo_Index_TooSmall()
        {
            WordInfoCollection sut = new WordInfoCollection();
            WordInfo           mi1 = new WordInfo("home", 0, 0, WordLocation.Content);
            WordInfo           mi2 = new WordInfo("taskbar", 100, 0, WordLocation.Content);

            sut.Add(mi1);
            sut.Add(mi2);

            WordInfo[] matches = new WordInfo[1];

            var ex = Assert.Throws <ArgumentOutOfRangeException>(() => sut.CopyTo(matches, 0));

            Assert.Equal("Not enough space for copying the items starting at the specified index.\r\nParameter name: arrayIndex", ex.Message);
        }
        public void Add_Item_Null()
        {
            WordInfoCollection sut = new WordInfoCollection();
            var ex = Assert.Throws <ArgumentNullException>(() => sut.Add(null));

            Assert.Equal("Value cannot be null.\r\nParameter name: item", ex.Message);
        }
示例#16
0
        public void Remove()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("goose", 1, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("hello", 12, 0, WordLocation.Content);

            collection.Add(mi1);
            Assert.IsTrue(collection.Contains(mi1), "Collection should contain item");
            Assert.IsFalse(collection.Contains(mi2), "Collection should not contain item");

            Assert.IsFalse(collection.Contains(null as WordInfo), "Contains should return false");
        }
示例#17
0
        public void Contains_WordInfo()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("taskbar", 21, 0, WordLocation.Content);

            collection.Add(mi1);

            Assert.IsTrue(collection.Contains(mi1), "Collection should contain item");
            Assert.IsFalse(collection.Contains(mi2), "Collection should not contain item");

            Assert.IsFalse(collection.Contains(null as WordInfo), "Contains should return false");
        }
示例#18
0
        public void Contains_String()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 0, 0, WordLocation.Content);

            collection.Add(mi1);

            Assert.IsTrue(collection.Contains("continuous"), "Collection should contain string");
            Assert.IsFalse(collection.Contains("taskbar"), "Collection should not contain string");

            Assert.IsFalse(collection.Contains(null as string), "Contains should return false");
            Assert.IsFalse(collection.Contains(""), "Contains should return false");
        }
        public void ContainsOccurrence()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 7, 0, WordLocation.Content);

            collection.Add(mi1);

            Assert.IsTrue(collection.ContainsOccurrence("continuous", 7), "Collection should contain occurrence");
            Assert.IsFalse(collection.ContainsOccurrence("continuous2", 7), "Collection should not contain occurrence");
            Assert.IsFalse(collection.ContainsOccurrence("continuous", 6), "Collection should not contain occurrence");
            Assert.IsFalse(collection.ContainsOccurrence("continuous", 8), "Collection should not contain occurrence");
            Assert.IsFalse(collection.ContainsOccurrence("continuous2", 6), "Collection should not contain occurrence");

            Assert.IsFalse(collection.ContainsOccurrence("continuous2", -1), "Contains should return false");
            Assert.IsFalse(collection.ContainsOccurrence("", 7), "Contains should return false");
            Assert.IsFalse(collection.ContainsOccurrence(null, 7), "Contains should return false");
        }
示例#20
0
        public void ContainsOccurrence()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 7, 0, WordLocation.Content);

            collection.Add(mi1);

            Assert.IsTrue(collection.ContainsOccurrence("continuous", 7), "Collection should contain occurrence");
            Assert.IsFalse(collection.ContainsOccurrence("continuous2", 7), "Collection should not contain occurrence");
            Assert.IsFalse(collection.ContainsOccurrence("continuous", 6), "Collection should not contain occurrence");
            Assert.IsFalse(collection.ContainsOccurrence("continuous", 8), "Collection should not contain occurrence");
            Assert.IsFalse(collection.ContainsOccurrence("continuous2", 6), "Collection should not contain occurrence");

            Assert.IsFalse(collection.ContainsOccurrence("continuous2", -1), "Contains should return false");
            Assert.IsFalse(collection.ContainsOccurrence("", 7), "Contains should return false");
            Assert.IsFalse(collection.ContainsOccurrence(null, 7), "Contains should return false");
        }
        public void Contains_String()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 0, 0, WordLocation.Content);

            collection.Add(mi1);

            Assert.IsTrue(collection.Contains("continuous"), "Collection should contain string");
            Assert.IsFalse(collection.Contains("taskbar"), "Collection should not contain string");

            Assert.IsFalse(collection.Contains(null as string), "Contains should return false");
            Assert.IsFalse(collection.Contains(""), "Contains should return false");
        }
示例#22
0
        public void Add_NullItem()
        {
            WordInfoCollection collection = new WordInfoCollection();

            collection.Add(null);
        }
 public void Add_NullItem()
 {
     WordInfoCollection collection = new WordInfoCollection();
     collection.Add(null);
 }
        public void Remove()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("goose", 1, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("hello", 12, 0, WordLocation.Content);

            collection.Add(mi1);
            Assert.IsTrue(collection.Contains(mi1), "Collection should contain item");
            Assert.IsFalse(collection.Contains(mi2), "Collection should not contain item");

            Assert.IsFalse(collection.Contains(null as WordInfo), "Contains should return false");
        }
        public void Indexer()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("taskbar", 1, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("goose", 12, 0, WordLocation.Content);

            collection.Add(mi2);
            collection.Add(mi1);

            Assert.AreEqual(mi1, collection[0], "Wrong item at position 0");
            Assert.AreEqual(mi2, collection[1], "Wrong item at position 0");
        }
        public void GetEnumerator()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("goose", 1, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("hello", 12, 0, WordLocation.Content);

            collection.Add(mi2);
            collection.Add(mi1);

            int count = 0;
            foreach(WordInfo r in collection) {
                if(count == 0) Assert.AreEqual(mi1, r, "Wrong item at position 0");
                if(count == 1) Assert.AreEqual(mi2, r, "Wrong item at position 1");
                count++;
            }
            Assert.AreEqual(2, count, "Wrong count - enumerator does not work");
        }
        public void CopyTo_NoSpaceAtIndex()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("home", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("taskbar", 100, 0, WordLocation.Content);

            collection.Add(mi1);
            collection.Add(mi2);

            WordInfo[] matches = new WordInfo[2];

            collection.CopyTo(matches, 1);
        }
        public void CopyTo_ArrayTooSmall()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("home", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("taskbar", 100, 0, WordLocation.Content);

            collection.Add(mi1);
            collection.Add(mi2);

            WordInfo[] matches = new WordInfo[1];

            collection.CopyTo(matches, 0);
        }
        public void CopyTo()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("goose", 34, 0, WordLocation.Content);

            collection.Add(mi1);
            collection.Add(mi2);

            WordInfo[] matches = new WordInfo[2];
            collection.CopyTo(matches, 0);

            Assert.AreEqual(mi1, matches[0], "Wrong match item");
            Assert.AreEqual(mi2, matches[1], "Wrong match item");

            matches = new WordInfo[3];
            collection.CopyTo(matches, 0);

            Assert.AreEqual(mi1, matches[0], "Wrong match item");
            Assert.AreEqual(mi2, matches[1], "Wrong match item");
            Assert.IsNull(matches[2], "Non-null item");

            matches = new WordInfo[3];
            collection.CopyTo(matches, 1);

            Assert.IsNull(matches[0], "Non-null item");
            Assert.AreEqual(mi1, matches[1], "Wrong match item");
            Assert.AreEqual(mi2, matches[2], "Wrong match item");
        }
        public void Contains_WordInfo()
        {
            WordInfoCollection collection = new WordInfoCollection();

            WordInfo mi1 = new WordInfo("continuous", 0, 0, WordLocation.Content);
            WordInfo mi2 = new WordInfo("taskbar", 21, 0, WordLocation.Content);

            collection.Add(mi1);

            Assert.IsTrue(collection.Contains(mi1), "Collection should contain item");
            Assert.IsFalse(collection.Contains(mi2), "Collection should not contain item");

            Assert.IsFalse(collection.Contains(null as WordInfo), "Contains should return false");
        }
示例#31
0
        public void Add_NullItem()
        {
            WordInfoCollection collection = new WordInfoCollection();

            Assert.That(() => collection.Add(null), Throws.ArgumentNullException);
        }