Exemplo n.º 1
0
        public void Pop_EmptyCollection_ViolatesPrecondtion()
        {
            // Arrange
            var collection = GetEmptyStack <string>();

            // Act & Assert
            Assert.That(() => collection.Pop(), Violates.PreconditionSaying(CollectionMustBeNonEmpty));
        }
        public void IsForward_InvalidValue_ViolatesPrecondition()
        {
            // Arrange
            var invalidEnumerationDirection = (EnumerationDirection)2;

            // Act & Assert
            Assert.That(() => invalidEnumerationDirection.IsForward(), Violates.PreconditionSaying(EnumMustBeDefined));
        }
        public void IsOppositeOf_OtherInvalidEnumerationDirection_ViolatesPrecondtion()
        {
            // Arrange
            var invalidEnumerationDirection = (EnumerationDirection)2;

            // Act & Assert
            Assert.That(() => Forwards.IsOppositeOf(invalidEnumerationDirection), Violates.PreconditionSaying(EnumMustBeDefined));
        }
Exemplo n.º 4
0
        public void AddRange_AddNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringExtensible(Random);

            // Act & Assert
            Assert.That(() => collection.AddRange(null), Violates.PreconditionSaying(ArgumentMustBeNonNull));
        }
Exemplo n.º 5
0
        public void Enqueue_DisallowsNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringQueue(Random, allowsNull: false);

            // Act & Assert
            Assert.That(() => collection.Enqueue(null), Violates.PreconditionSaying(ItemMustBeNonNull));
        }
Exemplo n.º 6
0
        public void Add_DisallowsNullAddNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringExtensible(Random, allowsNull: false);

            // Act & Assert
            Assert.That(() => collection.Add(null), Violates.PreconditionSaying(ItemMustBeNonNull));
        }
Exemplo n.º 7
0
        public void LastIndexOf_DisallowsNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringIndexed(Random, allowsNull: false);

            // Act & Assert
            Assert.That(() => collection.LastIndexOf(null), Violates.PreconditionSaying(ItemMustBeNonNull));
        }
Exemplo n.º 8
0
        public void Dequeue_EmptyCollection_ViolatesPrecondtion()
        {
            // Arrange
            var collection = GetEmptyQueue <string>();

            // Act & Assert
            Assert.That(() => collection.Dequeue(), Violates.PreconditionSaying(CollectionMustBeNonEmpty));
        }
Exemplo n.º 9
0
        public void RemoveAt_EmptyCollection_ViolatesPrecondtion()
        {
            // Arrange
            var collection = GetEmptyIndexed <string>();

            // Act & Assert
            Assert.That(() => collection.RemoveAt(0), Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
Exemplo n.º 10
0
        public void CopyTo_NullArray_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetIntCollectionValue(Random);

            // Act & Assert
            Assert.That(() => collection.CopyTo(null, 0), Violates.PreconditionSaying(ArgumentMustBeNonNull));
        }
Exemplo n.º 11
0
        public void ItemGet_EmptyCollection_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetEmptyStack <string>();

            // Act & Assert
            Assert.That(() => collection[0], Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
Exemplo n.º 12
0
        public void Push_DisallowsNullPushNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringStack(Random, allowsNull: false);

            // Act & Assert
            Assert.That(() => collection.Push(null), Violates.PreconditionSaying(ItemMustBeNonNull));
        }
Exemplo n.º 13
0
        public void AddRange_DisallowNullAddNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringExtensible(Random, allowsNull: false);
            var items      = GetStrings(Random).WithNull(Random);

            // Act & Assert
            Assert.That(() => collection.AddRange(items), Violates.PreconditionSaying(ItemsMustBeNonNull));
        }
Exemplo n.º 14
0
        public void CopyTo_NegativeIndex_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetIntCollectionValue(Random);
            var array      = new int[collection.Count];

            // Act & Assert
            Assert.That(() => collection.CopyTo(array, -1), Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
Exemplo n.º 15
0
        public void IsSorted_DefaultComparerWithNullEnumerable_ViolatesPrecondition()
        {
            // Arrange
            SCG.IEnumerable <int> enumerable = null;

            // Act & Assert
            // ReSharper disable once ExpressionIsAlwaysNull
            Assert.That(() => enumerable.IsSorted(), Violates.PreconditionSaying(ArgumentMustBeNonNull));
        }
Exemplo n.º 16
0
        public void ItemGet_IndexOfCount_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringIndexed(Random);
            var index      = collection.Count;

            // Act & Assert
            Assert.That(() => collection[index], Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
Exemplo n.º 17
0
        public void ItemGet_NegativeIndex_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringIndexed(Random);
            var index      = Random.Next(int.MinValue, 0);

            // Act & Assert
            Assert.That(() => collection[index], Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
Exemplo n.º 18
0
        public void Choose_EmptyCollection_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetEmptyCollectionValue <int>();

            // Act & Assert
            Assert.That(() => collection.Choose(), Violates.PreconditionSaying(CollectionMustBeNonEmpty));
            //Assert.That(() => collection.Choose(), Throws.TypeOf<PreconditionException>());
        }
Exemplo n.º 19
0
        public void RemoveAt_IndexLargerThanCount_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringIndexed(Random);
            var index      = Random.Next(collection.Count + 1, int.MaxValue);

            // Act & Assert
            Assert.That(() => collection.RemoveAt(index), Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
Exemplo n.º 20
0
        public void ItemsRemoved_RemovesInactiveEvent_ViolatesPrecondition()
        {
            Run.If(ListenableEvents.HasFlag(Removed));

            // Arrange
            var collection = GetEmptyListenable <int>();

            // Act & Assert
            Assert.That(() => collection.ItemsRemoved -= _removed, Violates.PreconditionSaying(EventMustBeActive));
        }
Exemplo n.º 21
0
        public void ItemsRemoved_ListenWithNull_ViolatesPrecondition()
        {
            Run.If(ListenableEvents.HasFlag(Removed));

            // Arrange
            var collection = GetEmptyListenable <int>();

            // Act & Assert
            Assert.That(() => collection.ItemsRemoved += null, Violates.PreconditionSaying(ArgumentMustBeNonNull));
        }
Exemplo n.º 22
0
        public void ItemsAdded_ListenToUnlistenableEvent_ViolatesPrecondition()
        {
            Run.If(!ListenableEvents.HasFlag(Added));

            // Arrange
            var collection = GetEmptyListenable <int>();

            // Act & Assert
            Assert.That(() => collection.ItemsAdded += _added, Violates.PreconditionSaying(EventMustBeListenable));
        }
Exemplo n.º 23
0
        public void RemoveIndexRange_CountIsOneLongerThanCollection_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringIndexed(Random);
            var startIndex = Random.Next(0, collection.Count);
            var count      = collection.Count - startIndex + 1;

            // Act & Assert
            Assert.That(() => collection.RemoveIndexRange(startIndex, count), Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
Exemplo n.º 24
0
        public void RemoveIndexRange_NegativeCount_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringIndexed(Random);
            var count      = collection.Count / 2;
            var startIndex = Random.Next(0, count);

            // Act & Assert
            Assert.That(() => collection.RemoveIndexRange(startIndex, -count), Violates.PreconditionSaying(ArgumentMustBeNonNegative));
        }
Exemplo n.º 25
0
        public void RemoveIndexRange_IndexOfCount_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringIndexed(Random);
            var startIndex = collection.Count;
            var count      = collection.Count / 2;

            // Act & Assert
            Assert.That(() => collection.RemoveIndexRange(startIndex, count), Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
Exemplo n.º 26
0
        public void CopyTo_IndexOutOfBound_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetIntCollectionValue(Random);
            var array      = new int[collection.Count];
            var index      = Random.Next(1, collection.Count);

            // Act & Assert
            Assert.That(() => collection.CopyTo(array, index), Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
Exemplo n.º 27
0
        public void Show_NullStringBuilder_ViolatesPrecondition()
        {
            // Arrange
            var collectionValue = GetIntCollectionValue(Random);
            var rest            = int.MaxValue;
            var formatProvider  = CultureInfo.CurrentCulture.NumberFormat;

            // Act & Assert
            Assert.That(() => collectionValue.Show(null, ref rest, formatProvider), Violates.PreconditionSaying(ArgumentMustBeNonNull));
        }
Exemplo n.º 28
0
        public void GetIndexRange_IndexLargerThanCount_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringIndexed(Random);
            var startIndex = Random.Next(collection.Count + 1, int.MaxValue);
            var count      = collection.Count / 2;

            // Act & Assert
            Assert.That(() => collection.GetIndexRange(startIndex, count), Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
Exemplo n.º 29
0
        public void GetIndexRange_NegativeIndex_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringIndexed(Random);
            var startIndex = Random.Next(int.MinValue, 0);
            var count      = collection.Count / 2;

            // Act & Assert
            Assert.That(() => collection.GetIndexRange(startIndex, count), Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
Exemplo n.º 30
0
        public void ItemGet_IndexLargerThanCount_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringStack(Random);
            var count      = collection.Count;
            var index      = Random.Next(count + 1, int.MaxValue);

            // Act & Assert
            Assert.That(() => collection[index], Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }