using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace CodeProject.VisualStudio.QualityTools.UnitTestFramework
{
public static class CollectionChangedWatcherExtensions
{
public static NotifyCollectionChangedEventArgs ShouldHaveSeen(this SpecificationValue<CollectionChangedWatcher> self,
NotifyCollectionChangedAction action)
{
return ShouldHaveSeen(self, action, string.Empty, null);
}
public static NotifyCollectionChangedEventArgs ShouldHaveSeen(this SpecificationValue<CollectionChangedWatcher> self,
NotifyCollectionChangedAction action, string message)
{
return ShouldHaveSeen(self, action, message, null);
}
public static NotifyCollectionChangedEventArgs ShouldHaveSeen(this SpecificationValue<CollectionChangedWatcher> self,
NotifyCollectionChangedAction action, string message, params object[] parameters)
{
IEnumerator<NotifyCollectionChangedEventArgs> enumerator = self.Value.Find(action);
NotifyCollectionChangedEventArgs found;
if (!enumerator.MoveNext())
Specify.Fail("ShouldHaveSeen", string.Empty, message, parameters);
found = enumerator.Current;
if (enumerator.MoveNext())
Specify.Fail("ShouldHaveSeen", string.Empty, message, parameters);
return found;
}
public static NotifyCollectionChangedEventArgs ShouldHaveSeen(this SpecificationValue<CollectionChangedWatcher> self,
NotifyCollectionChangedAction action, ICollection items)
{
return ShouldHaveSeen(self, action, items, string.Empty, null);
}
public static NotifyCollectionChangedEventArgs ShouldHaveSeen(this SpecificationValue<CollectionChangedWatcher> self,
NotifyCollectionChangedAction action, ICollection items, string message)
{
return ShouldHaveSeen(self, action, items, message, null);
}
public static NotifyCollectionChangedEventArgs ShouldHaveSeen(this SpecificationValue<CollectionChangedWatcher> self,
NotifyCollectionChangedAction action, ICollection items, string message, params object[] parameters)
{
IEnumerator<NotifyCollectionChangedEventArgs> enumerator = self.Value.Find(action, items);
NotifyCollectionChangedEventArgs found;
if (!enumerator.MoveNext())
Specify.Fail("ShouldHaveSeen", string.Empty, message, parameters);
found = enumerator.Current;
if (enumerator.MoveNext())
Specify.Fail("ShouldHaveSeen", string.Empty, message, parameters);
return found;
}
public static NotifyCollectionChangedEventArgs ShouldHaveSeen(this SpecificationValue<CollectionChangedWatcher> self,
NotifyCollectionChangedAction action, ICollection newItems, ICollection oldItems)
{
return ShouldHaveSeen(self, action, newItems, oldItems, string.Empty, null);
}
public static NotifyCollectionChangedEventArgs ShouldHaveSeen(this SpecificationValue<CollectionChangedWatcher> self,
NotifyCollectionChangedAction action, ICollection newItems, ICollection oldItems, string message)
{
return ShouldHaveSeen(self, action, newItems, oldItems, message, null);
}
public static NotifyCollectionChangedEventArgs ShouldHaveSeen(this SpecificationValue<CollectionChangedWatcher> self,
NotifyCollectionChangedAction action, ICollection newItems, ICollection oldItems, string message, params object[] parameters)
{
IEnumerator<NotifyCollectionChangedEventArgs> enumerator = self.Value.Find(action, newItems, oldItems);
NotifyCollectionChangedEventArgs found;
if (!enumerator.MoveNext())
Specify.Fail("ShouldHaveSeen", string.Empty, message, parameters);
found = enumerator.Current;
if (enumerator.MoveNext())
Specify.Fail("ShouldHaveSeen", string.Empty, message, parameters);
return found;
}
}
}