예제 #1
0
파일: IStackTests.cs 프로젝트: flyer87/C6
        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));
        }
예제 #4
0
        public void AddRange_AddNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringExtensible(Random);

            // Act & Assert
            Assert.That(() => collection.AddRange(null), Violates.PreconditionSaying(ArgumentMustBeNonNull));
        }
예제 #5
0
파일: IQueueTests.cs 프로젝트: flyer87/C6
        public void Enqueue_DisallowsNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringQueue(Random, allowsNull: false);

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

            // Act & Assert
            Assert.That(() => collection.Add(null), Violates.PreconditionSaying(ItemMustBeNonNull));
        }
예제 #7
0
파일: IIndexedTests.cs 프로젝트: flyer87/C6
        public void LastIndexOf_DisallowsNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringIndexed(Random, allowsNull: false);

            // Act & Assert
            Assert.That(() => collection.LastIndexOf(null), Violates.PreconditionSaying(ItemMustBeNonNull));
        }
예제 #8
0
파일: IQueueTests.cs 프로젝트: flyer87/C6
        public void Dequeue_EmptyCollection_ViolatesPrecondtion()
        {
            // Arrange
            var collection = GetEmptyQueue <string>();

            // Act & Assert
            Assert.That(() => collection.Dequeue(), Violates.PreconditionSaying(CollectionMustBeNonEmpty));
        }
예제 #9
0
파일: IIndexedTests.cs 프로젝트: flyer87/C6
        public void RemoveAt_EmptyCollection_ViolatesPrecondtion()
        {
            // Arrange
            var collection = GetEmptyIndexed <string>();

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

            // Act & Assert
            Assert.That(() => collection.CopyTo(null, 0), Violates.PreconditionSaying(ArgumentMustBeNonNull));
        }
예제 #11
0
파일: IStackTests.cs 프로젝트: flyer87/C6
        public void ItemGet_EmptyCollection_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetEmptyStack <string>();

            // Act & Assert
            Assert.That(() => collection[0], Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
예제 #12
0
파일: IStackTests.cs 프로젝트: flyer87/C6
        public void Push_DisallowsNullPushNull_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringStack(Random, allowsNull: false);

            // Act & Assert
            Assert.That(() => collection.Push(null), Violates.PreconditionSaying(ItemMustBeNonNull));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #16
0
파일: IIndexedTests.cs 프로젝트: flyer87/C6
        public void ItemGet_IndexOfCount_ViolatesPrecondition()
        {
            // Arrange
            var collection = GetStringIndexed(Random);
            var index      = collection.Count;

            // Act & Assert
            Assert.That(() => collection[index], Violates.PreconditionSaying(ArgumentMustBeWithinBounds));
        }
예제 #17
0
파일: IIndexedTests.cs 프로젝트: flyer87/C6
        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));
        }
예제 #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>());
        }
예제 #19
0
파일: IIndexedTests.cs 프로젝트: flyer87/C6
        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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #23
0
파일: IIndexedTests.cs 프로젝트: flyer87/C6
        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));
        }
예제 #24
0
파일: IIndexedTests.cs 프로젝트: flyer87/C6
        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));
        }
예제 #25
0
파일: IIndexedTests.cs 프로젝트: flyer87/C6
        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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #28
0
파일: IIndexedTests.cs 프로젝트: flyer87/C6
        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));
        }
예제 #29
0
파일: IIndexedTests.cs 프로젝트: flyer87/C6
        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));
        }
예제 #30
0
파일: IStackTests.cs 프로젝트: flyer87/C6
        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));
        }