コード例 #1
0
        public void RemoveNotExistingSearchRangeShouldDoNothing()
        {
            //Arrange
            var notExistingSearchRange = new SearchRange();
            var existingSearchRange1 = new SearchRange();
            var existingSearchRange2 = new SearchRange();
            var searchDict1 = new SearchRangeDictionary { existingSearchRange1, existingSearchRange2 };
            var searchDict2 = new SearchRangeDictionary { existingSearchRange1, existingSearchRange2 };

            //Act
            //Assert
            Assert.DoesNotThrow(() => searchDict1.Remove(notExistingSearchRange));
            Assert.That(searchDict1[0], Is.EqualTo(existingSearchRange1));
            Assert.That(searchDict1[1], Is.EqualTo(existingSearchRange2));
            Assert.That(searchDict1.Count, Is.EqualTo(2));
            Assert.DoesNotThrow(() => searchDict2.Remove(80));
            Assert.That(searchDict2[0], Is.EqualTo(existingSearchRange1));
            Assert.That(searchDict2[1], Is.EqualTo(existingSearchRange2));
            Assert.That(searchDict2.Count, Is.EqualTo(2));
        }
コード例 #2
0
        private static void RemoveTest(int key)
        {
            //Arrange
            var testSearch = new[] { new SearchRange(), new SearchRange(), new SearchRange() };
            var searchDict1 = new SearchRangeDictionary { testSearch };
            var searchDict2 = new SearchRangeDictionary { testSearch };

            //Act
            searchDict1.Remove(testSearch[key]);
            searchDict2.Remove(key);

            //Assert
            switch (key)
            {
                case 0:
                    Assert.That(searchDict1[0], Is.EqualTo(testSearch[1]));
                    Assert.That(searchDict1[1], Is.EqualTo(testSearch[2]));
                    Assert.That(searchDict2[0], Is.EqualTo(testSearch[1]));
                    Assert.That(searchDict2[1], Is.EqualTo(testSearch[2]));
                    break;

                case 1:
                    Assert.That(searchDict1[0], Is.EqualTo(testSearch[0]));
                    Assert.That(searchDict1[1], Is.EqualTo(testSearch[2]));
                    Assert.That(searchDict2[0], Is.EqualTo(testSearch[0]));
                    Assert.That(searchDict2[1], Is.EqualTo(testSearch[2]));
                    break;

                case 2:
                    Assert.That(searchDict1[0], Is.EqualTo(testSearch[0]));
                    Assert.That(searchDict1[1], Is.EqualTo(testSearch[1]));
                    Assert.That(searchDict2[0], Is.EqualTo(testSearch[0]));
                    Assert.That(searchDict2[1], Is.EqualTo(testSearch[1]));
                    break;
            }

            Assert.That(searchDict1.Count, Is.EqualTo(2));
            Assert.That(searchDict2.Count, Is.EqualTo(2));
        }