예제 #1
0
        public void InsertingADuplicate()
        {
            // Given
            var sortedSet = new SortedSet.SortedSet();

            sortedSet.Insert(1, "one");

            // When a duplicate is inserted
            var result = sortedSet.Insert(1, "one");

            // Then it should not insert
            result.Should().BeFalse();
            sortedSet.Length.Should().Be(1);
        }
예제 #2
0
        public void InsertingExistingScoreWithNewElement()
        {
            // Given
            var sortedSet = new SortedSet.SortedSet();

            sortedSet.Insert(1, "one");

            // When an existing score is inserted using new element
            var result = sortedSet.Insert(1, "two");

            // Then it should successfully insert
            result.Should().BeTrue();
            sortedSet.Length.Should().Be(2);
        }
예제 #3
0
        public void DeletingARangeOfItems()
        {
            // Given
            var sortedSet = new SortedSet.SortedSet();

            sortedSet.Insert(1, "one");
            sortedSet.Insert(2, "two");
            sortedSet.Insert(3, "three");
            sortedSet.Insert(4, "four");

            // When deleting a range of items
            sortedSet.DeleteRangeByScore(1, 3);

            // It should successfully delete
            sortedSet.Length.Should().Be(1);
        }
예제 #4
0
        public void InsertingNewScoreAndElement()
        {
            // Given
            var sortedSet = new SortedSet.SortedSet();

            // When a score is inserted
            var result = sortedSet.Insert(1, "one");

            // Then it should successfully insert
            result.Should().BeTrue();
            sortedSet.Length.Should().Be(1);
        }
예제 #5
0
        public void UpdatingExistingScoreWithInvalidElement()
        {
            // Given
            var sortedSet = new SortedSet.SortedSet();

            sortedSet.Insert(1, "one");

            // When an existing score is updated with invalid element
            var result = sortedSet.Update(1, "two", 2);

            // Then it should not update
            result.Should().BeFalse();
        }
예제 #6
0
        public void UpdatingExistingScoreAndElement()
        {
            // Given
            var sortedSet = new SortedSet.SortedSet();

            sortedSet.Insert(1, "one");

            // When an existing score and element are updated
            var result = sortedSet.Update(1, "one", 2);

            // Then it should successfully update
            result.Should().BeTrue();
        }
예제 #7
0
        public void DeletingByNonExistingScoreAndElement()
        {
            // Given
            var sortedSet = new SortedSet.SortedSet();

            sortedSet.Insert(1, "one");

            // When deleting a non-existing score and element
            var result = sortedSet.Delete(1, "two");

            // Then it should not delete
            result.Should().BeFalse();
            sortedSet.Length.Should().Be(1);
        }
예제 #8
0
        public void DeletingByExistingScoreAndElement()
        {
            // Given
            var sortedSet = new SortedSet.SortedSet();

            sortedSet.Insert(1, "one");

            // When existing score and element are deleted
            var result = sortedSet.Delete(1, "one");

            // Then it should successfully delete
            result.Should().BeTrue();
            sortedSet.Length.Should().Be(0);
        }