public static RaiseEventExpectation AsEvent(this NotifyCollectionChangedAction action)
        {
            var result = new RaiseEventExpectation()
            {
                Action = action
            };

            return(result);
        }
示例#2
0
 /// <summary>
 /// An event will be raised.
 /// </summary>
 /// <param name="expectedEvent">The expected event.</param>
 /// <returns>The original step.</returns>
 public TStep Raise(RaiseEventExpectation expectedEvent)
 {
     expectedEvent = expectedEvent ?? new RaiseEventExpectation()
     {
         Action = null
     };
     _owningStep.AddExpectation(expectedEvent);
     return(_owningStep);
 }
        public static RaiseEventExpectation At(this RaiseEventExpectation spec, int index)
        {
            switch (spec.Action.Value)
            {
            case NotifyCollectionChangedAction.Add:
                return(spec.AtNew(index));

            case NotifyCollectionChangedAction.Remove:
                return(spec.AtNew(index));

            default:
                throw new NotSupportedException("Invalid event specification: Both New and Old indexes must be specified explicitly when not using Add or Remove event specifications.");
            }
        }
示例#4
0
 public void Expect(RaiseEventExpectation specification)
 {
     if (_arguments.Count > 0)
     {
         var lastEvent = _arguments.Dequeue();
         if (lastEvent != null)
         {
             specification.CompareTo(lastEvent);
         }
     }
     else
     {
         Assert.Fail("Event was not raised.");
     }
 }
        public static RaiseEventExpectation With(this RaiseEventExpectation spec, params object[] items)
        {
            switch (spec.Action.Value)
            {
            case NotifyCollectionChangedAction.Add:
                return(spec.WithNew(items));

            case NotifyCollectionChangedAction.Remove:
                return(spec.WithOld(items));

            case NotifyCollectionChangedAction.Move:
                return(spec.WithOld(items));

            default:
                throw new NotSupportedException("Invalid event specification: Both New and Old items must be specified explicitly when not using Add, Remove or Move event specifications.");
            }
        }
 public static RaiseEventExpectation WithOldCount(this RaiseEventExpectation spec, int count)
 {
     spec.OldItemsCount = count;
     return(spec);
 }
 public static RaiseEventExpectation AtOld(this RaiseEventExpectation spec, int index)
 {
     spec.OldIndex = index;
     return(spec);
 }
 public static RaiseEventExpectation AtNew(this RaiseEventExpectation spec, int index)
 {
     spec.NewIndex = index;
     return(spec);
 }
 public static RaiseEventExpectation WithOld(this RaiseEventExpectation spec, params object[] items)
 {
     spec.OldItems = items;
     return(spec);
 }