Пример #1
0
 /// <summary>
 ///     Introduces a step that will remember ('store') values written to it, returning them when read.
 /// </summary>
 /// <typeparam name="TValue">The type of the property.</typeparam>
 /// <param name="caller">The mock or step to which this 'stored' step is added.</param>
 /// <param name="step">
 ///     Returns the added step itself. It can be used to manipulate the store and check contents of the
 ///     store.
 /// </param>
 /// <param name="initialValue">The initial value of the store, or default if none was given.</param>
 /// <returns>An <see cref="ICanHaveNextPropertyStep{TValue}" /> that can be used to add further steps.</returns>
 public static IStoredProperty <TValue> Stored <TValue>(
     this ICanHaveNextPropertyStep <TValue> caller,
     out StoredPropertyStep <TValue> step,
     TValue initialValue = default)
 {
     step = new StoredPropertyStep <TValue>(initialValue);
     return(caller.SetNextStep(step));
 }
Пример #2
0
 /// <summary>
 ///     Introduces a set of steps that mimic setting a property with event notification.
 /// </summary>
 /// <typeparam name="TValue">The type of the property.</typeparam>
 /// <param name="caller">The mock or step to which this 'stored' step is added.</param>
 /// <param name="storedPropertyStep">
 ///     Returns the 'stored' property step added. It can be used to manipulate the store and
 ///     check contents of the store.
 /// </param>
 /// <param name="propertyChangedEvent">The event step used to store <see cref="PropertyChangedEventHandler" /> instances.</param>
 /// <param name="initialValue">The initial value of the property.</param>
 /// <param name="comparer">
 ///     An optional comparer used to determine if the value of the property has changed. An event will
 ///     only be raised if it has.
 /// </param>
 /// <returns>An <see cref="ICanHaveNextPropertyStep{TValue}" /> that can be used to add further steps.</returns>
 public static IStoredProperty <TValue> StoredWithChangeNotification <TValue>(
     this ICanHaveNextPropertyStep <TValue> caller,
     out StoredPropertyStep <TValue> storedPropertyStep,
     IStoredEvent <PropertyChangedEventHandler> propertyChangedEvent,
     TValue initialValue = default,
     IEqualityComparer <TValue>?comparer = null)
 {
     return(caller
            .OnlySetIfChanged(comparer)
            .RaisePropertyChangedEvent(propertyChangedEvent)
            .Stored(out storedPropertyStep, initialValue));
 }