/// <summary> /// Checks the current values in the indexer store. Adds the check to the verification group provided. /// </summary> /// <typeparam name="TKey">The type of the indexer key.</typeparam> /// <typeparam name="TValue">The type of the indexer value.</typeparam> /// <param name="indexer">The <see cref="IStoredIndexer{TKey,TValue}" /> whose values to check.</param> /// <param name="collector">The verification group to which this check is added.</param> /// <param name="name">A name that can be used to identify the check in its verification group.</param> /// <param name="expectedValues"> /// A list of key-value pairs to check. The check will retrieve the value for each key /// in the list and compare it to the value in the list. /// </param> /// <param name="comparer">Optional parameter with a comparer used to verify that the values are equal.</param> /// <returns>The <see cref="IStoredIndexer{TKey,TValue}" /> instance that can be used to add further checks.</returns> public static IStoredIndexer <TKey, TValue> CurrentValuesCheck <TKey, TValue>(this IStoredIndexer <TKey, TValue> indexer, VerificationGroup collector, string?name, IEnumerable <KeyValuePair <TKey, TValue> >?expectedValues, IEqualityComparer <TValue>?comparer = null) { collector.Add(new CurrentValuesIndexerCheck <TKey, TValue>(indexer, name, expectedValues, comparer)); return(indexer); }
/// <summary> /// Step that checks the number of times the method has been called. Adds the check to the verification group /// provided. /// </summary> /// <typeparam name="TParam">The method parameter type.</typeparam> /// <typeparam name="TResult">The method return type.</typeparam> /// <param name="caller">The mock or step to which this 'verification' step is added.</param> /// <param name="verificationGroup">The verification group to which this check is added.</param> /// <param name="name">A name that can be used to identify the check in its group.</param> /// <param name="expectedNumberOfCalls">The expected number of times the method has been called.</param> /// <returns>An <see cref="ICanHaveNextMethodStep{TParam, TResult}" /> that can be used to add further steps.</returns> public static ICanHaveNextMethodStep <TParam, TResult> ExpectedUsage <TParam, TResult>( this ICanHaveNextMethodStep <TParam, TResult> caller, VerificationGroup verificationGroup, string?name, int?expectedNumberOfCalls = null) { if (verificationGroup == null) { throw new ArgumentNullException(nameof(verificationGroup)); } var step = new ExpectedUsageMethodStep <TParam, TResult>(name, expectedNumberOfCalls); verificationGroup.Add(step); return(caller.SetNextStep(step)); }
/// <summary> /// Step that checks the number of times values have been read from or written to the indexer. Adds the check /// to the verification group provided. /// </summary> /// <typeparam name="TKey">The type of the indexer key.</typeparam> /// <typeparam name="TValue">The type of the indexer value.</typeparam> /// <param name="caller">The mock or step to which this 'verification' step is added.</param> /// <param name="verificationGroup">The verification group to which this check is added.</param> /// <param name="name">A name that can be used to identify the check in its group.</param> /// <param name="expectedNumberOfGets">The expected number of times values have been read from the indexer.</param> /// <param name="expectedNumberOfSets">The expected number of times values have been written to the indexer.</param> /// <returns>An <see cref="ICanHaveNextIndexerStep{TKey, TValue}" /> that can be used to add further steps.</returns> public static ICanHaveNextIndexerStep <TKey, TValue> ExpectedUsage <TKey, TValue>( this ICanHaveNextIndexerStep <TKey, TValue> caller, VerificationGroup verificationGroup, string?name, int?expectedNumberOfGets = null, int?expectedNumberOfSets = null) { if (verificationGroup == null) { throw new ArgumentNullException(nameof(verificationGroup)); } var step = new ExpectedUsageIndexerStep <TKey, TValue>(name, expectedNumberOfGets, expectedNumberOfSets); verificationGroup.Add(step); return(caller.SetNextStep(step)); }
/// <summary> /// Step that checks the number of times event handlers have been added or removed. Adds the check to the verification /// group provided. /// </summary> /// <typeparam name="THandler">The event handler type for the event.</typeparam> /// <param name="caller">The mock or step to which this 'verification' step is added.</param> /// <param name="verificationGroup">The verification group to which this check is added.</param> /// <param name="name">A name that can be used to identify the check in its group.</param> /// <param name="expectedNumberOfAdds">The expected number of times event handlers have been added.</param> /// <param name="expectedNumberOfRemoves">The expected number of times event handlers have been removed.</param> /// <returns>An <see cref="ICanHaveNextEventStep{THandler}" /> that can be used to add further steps.</returns> public static ICanHaveNextEventStep <THandler> ExpectedUsage <THandler>( this ICanHaveNextEventStep <THandler> caller, VerificationGroup verificationGroup, string?name, int?expectedNumberOfAdds = null, int?expectedNumberOfRemoves = null) where THandler : Delegate { if (verificationGroup == null) { throw new ArgumentNullException(nameof(verificationGroup)); } var step = new ExpectedUsageEventStep <THandler>(name, expectedNumberOfAdds, expectedNumberOfRemoves); verificationGroup.Add(step); return(caller.SetNextStep(step)); }
/// <summary> /// Checks the current values in the property store. Adds the check to the verification group provided. /// </summary> /// <typeparam name="TValue">The type of the property.</typeparam> /// <param name="property">The <see cref="IStoredProperty{TValue}" /> whose value to check.</param> /// <param name="collector">The verification group to which this check is added.</param> /// <param name="name">A name that can be used to identify the check in its verification group.</param> /// <param name="expectedValue">The expected value. </param> /// <param name="comparer">Optional parameter with a comparer used to verify that the values are equal.</param> /// <returns>The <see cref="IStoredProperty{TValue}" /> instance that can be used to add further checks.</returns> public static IStoredProperty <TValue> CurrentValueCheck <TValue>(this IStoredProperty <TValue> property, VerificationGroup collector, string?name, TValue expectedValue, IEqualityComparer <TValue>?comparer = null) { collector.Add(new CurrentValuePropertyCheck <TValue>(property, name, expectedValue, comparer)); return(property); }