Esempio n. 1
0
        public void AddRange_AddNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringExtensible(Random);

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

            // Act & Assert
            Assert.That(() => invalidEnumerationDirection.IsForward(), Violates.PreconditionSaying(EnumMustBeDefined));
        }
Esempio n. 3
0
        public void Push_DisallowsNullPushNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringStack(Random, allowsNull: false);

            // Act & Assert
            Assert.That(() => collection.Push(null), Violates.PreconditionSaying(ItemMustBeNonNull));
        }
Esempio n. 4
0
        public void ItemGet_EmptyCollection_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetEmptyStack <string>();

            // Act & Assert
            Assert.That(() => collection[0], Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
        public void IsOppositeOf_OtherInvalidEnumerationDirection_ViolatesPrecondtion()
        {
            // Arrange
            var invalidEnumerationDirection = (EnumerationDirection)2;

            // Act & Assert
            Assert.That(() => Forwards.IsOppositeOf(invalidEnumerationDirection), Violates.PreconditionSaying(EnumMustBeDefined));
        }
Esempio n. 6
0
        public void Enqueue_DisallowsNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringQueue(Random, allowsNull: false);

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

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

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

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

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

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

            // Act & Assert
            Assert.That(() => collection.Pop(), Violates.PreconditionSaying(CollectionMustBeNonEmpty));
        }
Esempio n. 13
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>());
        }
Esempio 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));
        }
Esempio n. 15
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));
        }
Esempio n. 16
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));
        }
Esempio n. 17
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));
        }
Esempio n. 18
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));
        }
Esempio n. 19
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));
        }
Esempio n. 20
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));
        }
Esempio n. 21
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));
        }
Esempio n. 22
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));
        }
Esempio n. 23
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));
        }