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)); }
public void AddRange_AddNull_ViolatesPrecondition() { // Arrange var collection = GetStringExtensible(Random); // Act & Assert Assert.That(() => collection.AddRange(null), Violates.PreconditionSaying(ArgumentMustBeNonNull)); }
public void Enqueue_DisallowsNull_ViolatesPrecondition() { // Arrange var collection = GetStringQueue(Random, allowsNull: false); // Act & Assert Assert.That(() => collection.Enqueue(null), Violates.PreconditionSaying(ItemMustBeNonNull)); }
public void Add_DisallowsNullAddNull_ViolatesPrecondition() { // Arrange var collection = GetStringExtensible(Random, allowsNull: false); // Act & Assert Assert.That(() => collection.Add(null), Violates.PreconditionSaying(ItemMustBeNonNull)); }
public void LastIndexOf_DisallowsNull_ViolatesPrecondition() { // Arrange var collection = GetStringIndexed(Random, allowsNull: false); // Act & Assert Assert.That(() => collection.LastIndexOf(null), Violates.PreconditionSaying(ItemMustBeNonNull)); }
public void Dequeue_EmptyCollection_ViolatesPrecondtion() { // Arrange var collection = GetEmptyQueue <string>(); // Act & Assert Assert.That(() => collection.Dequeue(), Violates.PreconditionSaying(CollectionMustBeNonEmpty)); }
public void RemoveAt_EmptyCollection_ViolatesPrecondtion() { // Arrange var collection = GetEmptyIndexed <string>(); // Act & Assert Assert.That(() => collection.RemoveAt(0), Violates.PreconditionSaying(ArgumentMustBeWithinBounds)); }
public void CopyTo_NullArray_ViolatesPrecondition() { // Arrange var collection = GetIntCollectionValue(Random); // Act & Assert Assert.That(() => collection.CopyTo(null, 0), Violates.PreconditionSaying(ArgumentMustBeNonNull)); }
public void ItemGet_EmptyCollection_ViolatesPrecondition() { // Arrange var collection = GetEmptyStack <string>(); // Act & Assert Assert.That(() => collection[0], Violates.PreconditionSaying(ArgumentMustBeWithinBounds)); }
public void Push_DisallowsNullPushNull_ViolatesPrecondition() { // Arrange var collection = GetStringStack(Random, allowsNull: false); // Act & Assert Assert.That(() => collection.Push(null), Violates.PreconditionSaying(ItemMustBeNonNull)); }
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)); }
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)); }
public void IsSorted_DefaultComparerWithNullEnumerable_ViolatesPrecondition() { // Arrange SCG.IEnumerable <int> enumerable = null; // Act & Assert // ReSharper disable once ExpressionIsAlwaysNull Assert.That(() => enumerable.IsSorted(), Violates.PreconditionSaying(ArgumentMustBeNonNull)); }
public void ItemGet_IndexOfCount_ViolatesPrecondition() { // Arrange var collection = GetStringIndexed(Random); var index = collection.Count; // Act & Assert Assert.That(() => collection[index], Violates.PreconditionSaying(ArgumentMustBeWithinBounds)); }
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)); }
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>()); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }