diff --git a/.editorconfig b/.editorconfig index 2f6bcf896..0df0c455c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,7 +7,7 @@ trim_trailing_whitespace = true indent_size = 4 indent_style = space -[*.{sln,csproj,fsproj,yml}] +[*.{sln,csproj,fsproj,yml,props}] indent_size = 2 indent_style = space diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 2efd75b40..52b2044a5 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -1,6 +1,6 @@ -name: Build and Test - +name: Build, Test, and Format on: [push, pull_request] + jobs: test: strategy: @@ -10,12 +10,12 @@ jobs: include: - os: windows-latest framework: net462 - + runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v3 - + - name: Setup .NET uses: actions/setup-dotnet@v3 with: @@ -23,13 +23,13 @@ jobs: 6.0.x 7.0.x 8.0.x - + - name: Build run: dotnet build - + - name: Test run: dotnet test -f ${{ matrix.framework }} --no-build --no-restore - + test-documentation: runs-on: windows-latest steps: @@ -37,7 +37,7 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - + - name: Setup .NET uses: actions/setup-dotnet@v3 with: @@ -45,7 +45,7 @@ jobs: 6.0.x 7.0.x 8.0.x - + # used for documentation - name: Setup Ruby uses: ruby/setup-ruby@v1 @@ -54,4 +54,18 @@ jobs: bundler-cache: true - name: Build all targets - run: build\build.cmd --target All \ No newline at end of file + run: build\build.cmd --target All + + format-verify: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + + - name: Format + run: dotnet format --verify-no-changes \ No newline at end of file diff --git a/src/NSubstitute/Arg.cs b/src/NSubstitute/Arg.cs index 6bd4f5fe1..b9714ee70 100644 --- a/src/NSubstitute/Arg.cs +++ b/src/NSubstitute/Arg.cs @@ -114,7 +114,7 @@ public static ref TDelegate InvokeDelegate(params object[] arguments) /// public static ref T Do(Action useArgument) { - return ref ArgumentMatcher.Enqueue(new AnyArgumentMatcher(typeof(T)), x => useArgument((T) x!)); + return ref ArgumentMatcher.Enqueue(new AnyArgumentMatcher(typeof(T)), x => useArgument((T)x!)); } /// @@ -225,7 +225,7 @@ public static class Compat private static Action InvokeDelegateAction(params object[] arguments) { - return x => ((Delegate) x).DynamicInvoke(arguments); + return x => ((Delegate)x).DynamicInvoke(arguments); } } } diff --git a/src/NSubstitute/ClearOptions.cs b/src/NSubstitute/ClearOptions.cs index 54825aed2..f0e3c2df6 100644 --- a/src/NSubstitute/ClearOptions.cs +++ b/src/NSubstitute/ClearOptions.cs @@ -2,27 +2,27 @@ namespace NSubstitute { - [Flags] - public enum ClearOptions - { - /// - /// Clear all the received calls - /// - ReceivedCalls = 1, + [Flags] + public enum ClearOptions + { + /// + /// Clear all the received calls + /// + ReceivedCalls = 1, - /// - /// Clear all configured return results (including auto-substituted values). - /// - ReturnValues = 2, + /// + /// Clear all configured return results (including auto-substituted values). + /// + ReturnValues = 2, - /// - /// Clear all call actions configured for this substitute (via When..Do, Arg.Invoke, and Arg.Do) - /// - CallActions = 4, + /// + /// Clear all call actions configured for this substitute (via When..Do, Arg.Invoke, and Arg.Do) + /// + CallActions = 4, - /// - /// Clears all received calls and configured return values and callbacks. - /// - All = ReceivedCalls | ReturnValues | CallActions - } + /// + /// Clears all received calls and configured return values and callbacks. + /// + All = ReceivedCalls | ReturnValues | CallActions + } } \ No newline at end of file diff --git a/src/NSubstitute/Core/Arguments/ArgumentFormatter.cs b/src/NSubstitute/Core/Arguments/ArgumentFormatter.cs index 8b03c1000..4b696f4c5 100644 --- a/src/NSubstitute/Core/Arguments/ArgumentFormatter.cs +++ b/src/NSubstitute/Core/Arguments/ArgumentFormatter.cs @@ -17,10 +17,10 @@ private string Format(object? arg) { return arg switch { - null => "", - string str => $"\"{str}\"", + null => "", + string str => $"\"{str}\"", { } obj when HasDefaultToString(obj) => arg.GetType().GetNonMangledTypeName(), - _ => arg.ToString() ?? string.Empty + _ => arg.ToString() ?? string.Empty }; static bool HasDefaultToString(object obj) diff --git a/src/NSubstitute/Core/Arguments/ArgumentMatchInfo.cs b/src/NSubstitute/Core/Arguments/ArgumentMatchInfo.cs index ede83d469..e60e5fc65 100644 --- a/src/NSubstitute/Core/Arguments/ArgumentMatchInfo.cs +++ b/src/NSubstitute/Core/Arguments/ArgumentMatchInfo.cs @@ -34,8 +34,8 @@ public override bool Equals(object? obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != typeof (ArgumentMatchInfo)) return false; - return Equals((ArgumentMatchInfo) obj); + if (obj.GetType() != typeof(ArgumentMatchInfo)) return false; + return Equals((ArgumentMatchInfo)obj); } public override int GetHashCode() @@ -43,8 +43,8 @@ public override int GetHashCode() unchecked { int result = Index; - result = (result*397) ^ (_argument != null ? _argument.GetHashCode() : 0); - result = (result*397) ^ _specification.GetHashCode(); + result = (result * 397) ^ (_argument != null ? _argument.GetHashCode() : 0); + result = (result * 397) ^ _specification.GetHashCode(); return result; } } diff --git a/src/NSubstitute/Core/Arguments/ArgumentMatcher.cs b/src/NSubstitute/Core/Arguments/ArgumentMatcher.cs index 23c0a38a5..9887aa91d 100644 --- a/src/NSubstitute/Core/Arguments/ArgumentMatcher.cs +++ b/src/NSubstitute/Core/Arguments/ArgumentMatcher.cs @@ -17,7 +17,7 @@ public static class ArgumentMatcher IArgumentMatcher nonGenericMatcher = argumentMatcher switch { IDescribeNonMatches => new GenericToNonGenericMatcherProxyWithDescribe(argumentMatcher), - _ => new GenericToNonGenericMatcherProxy(argumentMatcher) + _ => new GenericToNonGenericMatcherProxy(argumentMatcher) }; return ref EnqueueArgSpecification(new ArgumentSpecification(typeof(T), nonGenericMatcher)); @@ -44,7 +44,7 @@ public GenericToNonGenericMatcherProxy(IArgumentMatcher matcher) _matcher = matcher; } - public bool IsSatisfiedBy(object? argument) => _matcher.IsSatisfiedBy((T?) argument!); + public bool IsSatisfiedBy(object? argument) => _matcher.IsSatisfiedBy((T?)argument!); } private class GenericToNonGenericMatcherProxyWithDescribe : GenericToNonGenericMatcherProxy, IDescribeNonMatches @@ -54,7 +54,7 @@ public GenericToNonGenericMatcherProxyWithDescribe(IArgumentMatcher matcher) if (matcher is not IDescribeNonMatches) throw new SubstituteInternalException("Should implement IDescribeNonMatches type."); } - public string DescribeFor(object? argument) => ((IDescribeNonMatches) _matcher).DescribeFor(argument); + public string DescribeFor(object? argument) => ((IDescribeNonMatches)_matcher).DescribeFor(argument); } private class DefaultValueContainer diff --git a/src/NSubstitute/Core/Arguments/ArrayContentsArgumentMatcher.cs b/src/NSubstitute/Core/Arguments/ArrayContentsArgumentMatcher.cs index 3172e0871..8b49dd437 100644 --- a/src/NSubstitute/Core/Arguments/ArrayContentsArgumentMatcher.cs +++ b/src/NSubstitute/Core/Arguments/ArrayContentsArgumentMatcher.cs @@ -17,7 +17,7 @@ public bool IsSatisfiedBy(object? argument) { if (argument != null) { - var argumentArray = ((IEnumerable) argument).Cast().ToArray(); + var argumentArray = ((IEnumerable)argument).Cast().ToArray(); if (argumentArray.Length == _argumentSpecifications.Length) { return _argumentSpecifications @@ -41,9 +41,10 @@ private IEnumerable Format(object[] args, IArgumentSpecification[] specs { if (specs.Any() && !args.Any()) { - return new [] { "**" }; + return new[] { "**" }; } - return args.Select((arg, index) => { + return args.Select((arg, index) => + { var hasSpecForThisArg = index < specs.Length; return hasSpecForThisArg ? specs[index].FormatArgument(arg) : ArgumentFormatter.Default.Format(arg, true); }); diff --git a/src/NSubstitute/Core/CallFactory.cs b/src/NSubstitute/Core/CallFactory.cs index 75305c09c..12f037145 100644 --- a/src/NSubstitute/Core/CallFactory.cs +++ b/src/NSubstitute/Core/CallFactory.cs @@ -10,7 +10,7 @@ public class CallFactory : ICallFactory { public ICall Create(MethodInfo methodInfo, object?[] arguments, object target, IList argumentSpecifications, Func? baseMethod) { - return new Call(methodInfo, arguments, target, argumentSpecifications , baseMethod); + return new Call(methodInfo, arguments, target, argumentSpecifications, baseMethod); } public ICall Create(MethodInfo methodInfo, object?[] arguments, object target, IList argumentSpecifications) diff --git a/src/NSubstitute/Core/CallInfo.cs b/src/NSubstitute/Core/CallInfo.cs index 89aa1b8ea..5994ceb6c 100644 --- a/src/NSubstitute/Core/CallInfo.cs +++ b/src/NSubstitute/Core/CallInfo.cs @@ -114,7 +114,7 @@ public T ArgAt(int position) try { - return (T) _callArguments[position].Value!; + return (T)_callArguments[position].Value!; } catch (InvalidCastException) { diff --git a/src/NSubstitute/Core/CallRouterResolver.cs b/src/NSubstitute/Core/CallRouterResolver.cs index cb8011c8f..97fb6e154 100644 --- a/src/NSubstitute/Core/CallRouterResolver.cs +++ b/src/NSubstitute/Core/CallRouterResolver.cs @@ -9,10 +9,10 @@ public ICallRouter ResolveFor(object substitute) { return substitute switch { - null => throw new NullSubstituteReferenceException(), - ICallRouterProvider provider => provider.GetCallRouter(), + null => throw new NullSubstituteReferenceException(), + ICallRouterProvider provider => provider.GetCallRouter(), Delegate { Target: ICallRouterProvider provider } => provider.GetCallRouter(), - _ => throw new NotASubstituteException() + _ => throw new NotASubstituteException() }; } } diff --git a/src/NSubstitute/Core/CallSpecification.cs b/src/NSubstitute/Core/CallSpecification.cs index 5162870c6..97c1f7a44 100644 --- a/src/NSubstitute/Core/CallSpecification.cs +++ b/src/NSubstitute/Core/CallSpecification.cs @@ -42,7 +42,7 @@ public bool IsSatisfiedBy(ICall call) } private static bool AreComparable(MethodInfo a, MethodInfo b) - { + { if (a == b) { return true; @@ -53,29 +53,29 @@ private static bool AreComparable(MethodInfo a, MethodInfo b) return CanCompareGenericMethods(a, b); } - return false; - } + return false; + } private static bool CanCompareGenericMethods(MethodInfo a, MethodInfo b) { - return - AreEquivalentDefinitions(a, b) - && TypesAreAllEquivalent(ParameterTypes(a), ParameterTypes(b)) - && TypesAreAllEquivalent(a.GetGenericArguments(), b.GetGenericArguments()); + return + AreEquivalentDefinitions(a, b) + && TypesAreAllEquivalent(ParameterTypes(a), ParameterTypes(b)) + && TypesAreAllEquivalent(a.GetGenericArguments(), b.GetGenericArguments()); } private static Type[] ParameterTypes(MethodInfo info) - { - return info.GetParameters().Select(p=>p.ParameterType).ToArray(); - } - - internal static bool TypesAreAllEquivalent(Type[] aArgs, Type[] bArgs) - { - if (aArgs.Length != bArgs.Length) return false; - for (var i = 0; i < aArgs.Length; i++) - { - var first = aArgs[i]; - var second = bArgs[i]; + { + return info.GetParameters().Select(p => p.ParameterType).ToArray(); + } + + internal static bool TypesAreAllEquivalent(Type[] aArgs, Type[] bArgs) + { + if (aArgs.Length != bArgs.Length) return false; + for (var i = 0; i < aArgs.Length; i++) + { + var first = aArgs[i]; + var second = bArgs[i]; if (first.IsGenericType && second.IsGenericType && first.GetGenericTypeDefinition() == second.GetGenericTypeDefinition()) @@ -90,17 +90,17 @@ internal static bool TypesAreAllEquivalent(Type[] aArgs, Type[] bArgs) var areEquivalent = first.IsAssignableFrom(second) || second.IsAssignableFrom(first) || typeof(Arg.AnyType).IsAssignableFrom(first) || typeof(Arg.AnyType).IsAssignableFrom(second); - if (!areEquivalent) return false; - } - return true; - } - - private static bool AreEquivalentDefinitions(MethodInfo a, MethodInfo b) - { - return a.IsGenericMethod == b.IsGenericMethod + if (!areEquivalent) return false; + } + return true; + } + + private static bool AreEquivalentDefinitions(MethodInfo a, MethodInfo b) + { + return a.IsGenericMethod == b.IsGenericMethod && a.ReturnType == b.ReturnType && a.Name.Equals(b.Name, StringComparison.Ordinal); - } + } private bool IsMatchingArgumentSpecifications(ICall call) { diff --git a/src/NSubstitute/Core/DependencyInjection/NSubContainer.cs b/src/NSubstitute/Core/DependencyInjection/NSubContainer.cs index 726d1f393..1263dfc2e 100644 --- a/src/NSubstitute/Core/DependencyInjection/NSubContainer.cs +++ b/src/NSubstitute/Core/DependencyInjection/NSubContainer.cs @@ -67,7 +67,7 @@ object Factory(Scope scope) } public IConfigurableNSubContainer Register(Func factory, NSubLifetime lifetime) - where TKey: notnull + where TKey : notnull { object Factory(Scope scope) { @@ -85,14 +85,14 @@ public IConfigurableNSubContainer Decorate(Func Registration? existingRegistration = TryFindRegistration(typeof(TKey)); if (existingRegistration == null) { - throw new ArgumentException("Cannot decorate type " + typeof(TKey).FullName +" as implementation is not registered."); + throw new ArgumentException("Cannot decorate type " + typeof(TKey).FullName + " as implementation is not registered."); } object Factory(Scope scope) { // Freeze original registration discovered during decoration. // This way we avoid recursion and support nested decorators. - var originalInstance = (TKey) scope.Resolve(existingRegistration); + var originalInstance = (TKey)scope.Resolve(existingRegistration); return factory.Invoke(originalInstance, scope); } @@ -189,7 +189,7 @@ public Scope(NSubContainer mostNestedContainer) _mostNestedContainer = mostNestedContainer; } - public T Resolve() where T : notnull => (T) Resolve(typeof(T)); + public T Resolve() where T : notnull => (T)Resolve(typeof(T)); public bool TryGetCached(Registration registration, [MaybeNullWhen(false)] out object result) { diff --git a/src/NSubstitute/Core/Events/DelegateEventWrapper.cs b/src/NSubstitute/Core/Events/DelegateEventWrapper.cs index bf4586c31..66d8ec060 100644 --- a/src/NSubstitute/Core/Events/DelegateEventWrapper.cs +++ b/src/NSubstitute/Core/Events/DelegateEventWrapper.cs @@ -14,7 +14,7 @@ public DelegateEventWrapper(params object?[] arguments) _providedArguments = arguments; } -// Disable nullability for client API, so it does not affect clients. + // Disable nullability for client API, so it does not affect clients. #nullable disable annotations public static implicit operator T(DelegateEventWrapper wrapper) { diff --git a/src/NSubstitute/Core/Events/EventHandlerWrapper.cs b/src/NSubstitute/Core/Events/EventHandlerWrapper.cs index d17db111a..c143223d6 100644 --- a/src/NSubstitute/Core/Events/EventHandlerWrapper.cs +++ b/src/NSubstitute/Core/Events/EventHandlerWrapper.cs @@ -18,7 +18,7 @@ public EventHandlerWrapper(object? sender, EventArgs? eventArgs) _eventArgs = eventArgs; } -// Disable nullability for client API, so it does not affect clients. + // Disable nullability for client API, so it does not affect clients. #nullable disable annotations public static implicit operator EventHandler(EventHandlerWrapper wrapper) { diff --git a/src/NSubstitute/Core/ICallActions.cs b/src/NSubstitute/Core/ICallActions.cs index 81a756e5b..99a13116c 100644 --- a/src/NSubstitute/Core/ICallActions.cs +++ b/src/NSubstitute/Core/ICallActions.cs @@ -8,6 +8,6 @@ public interface ICallActions void Add(ICallSpecification callSpec); void InvokeMatchingActions(ICall callInfo); void MoveActionsForSpecToNewSpec(ICallSpecification oldCallSpecification, ICallSpecification newCallSpecification); - void Clear(); + void Clear(); } } \ No newline at end of file diff --git a/src/NSubstitute/Core/ICallResults.cs b/src/NSubstitute/Core/ICallResults.cs index 9f3313452..723469155 100644 --- a/src/NSubstitute/Core/ICallResults.cs +++ b/src/NSubstitute/Core/ICallResults.cs @@ -4,6 +4,6 @@ public interface ICallResults { void SetResult(ICallSpecification callSpecification, IReturn result); bool TryGetResult(ICall call, out object? result); - void Clear(); + void Clear(); } } \ No newline at end of file diff --git a/src/NSubstitute/Core/IResultsForType.cs b/src/NSubstitute/Core/IResultsForType.cs index a710f8074..7a47c8fe2 100644 --- a/src/NSubstitute/Core/IResultsForType.cs +++ b/src/NSubstitute/Core/IResultsForType.cs @@ -2,7 +2,8 @@ namespace NSubstitute.Core { - public interface IResultsForType { + public interface IResultsForType + { void SetResult(Type type, IReturn resultToReturn); bool TryGetResult(ICall call, out object? result); void Clear(); diff --git a/src/NSubstitute/Core/IReturn.cs b/src/NSubstitute/Core/IReturn.cs index 0901f2820..fc34c3bf3 100644 --- a/src/NSubstitute/Core/IReturn.cs +++ b/src/NSubstitute/Core/IReturn.cs @@ -47,8 +47,8 @@ public ReturnValueFromFunc(Func? funcToReturnValue) } public object? ReturnFor(CallInfo info) => _funcToReturnValue(info); - public Type TypeOrNull() => typeof (T); - public bool CanBeAssignedTo(Type t) => typeof (T).IsAssignableFrom(t); + public Type TypeOrNull() => typeof(T); + public bool CanBeAssignedTo(Type t) => typeof(T).IsAssignableFrom(t); private static Func ReturnNull() { @@ -70,8 +70,8 @@ public ReturnMultipleValues(T?[] values) public object? GetReturnValue() => GetNext(); public object? ReturnFor(CallInfo info) => GetReturnValue(); - public Type TypeOrNull() => typeof (T); - public bool CanBeAssignedTo(Type t) => typeof (T).IsAssignableFrom(t); + public Type TypeOrNull() => typeof(T); + public bool CanBeAssignedTo(Type t) => typeof(T).IsAssignableFrom(t); private T? GetNext() => _valuesToReturn.TryDequeue(out var nextResult) ? nextResult : _lastValue; } @@ -88,8 +88,8 @@ public ReturnMultipleFuncsValues(Func[] funcs) } public object? ReturnFor(CallInfo info) => GetNext(info); - public Type TypeOrNull() => typeof (T); - public bool CanBeAssignedTo(Type t) => typeof (T).IsAssignableFrom(t); + public Type TypeOrNull() => typeof(T); + public bool CanBeAssignedTo(Type t) => typeof(T).IsAssignableFrom(t); private T? GetNext(CallInfo info) => _funcsToReturn.TryDequeue(out var nextFunc) ? nextFunc(info) : _lastFunc(info); } diff --git a/src/NSubstitute/Core/ISubstituteFactory.cs b/src/NSubstitute/Core/ISubstituteFactory.cs index 72ca54bd4..01b8c5422 100644 --- a/src/NSubstitute/Core/ISubstituteFactory.cs +++ b/src/NSubstitute/Core/ISubstituteFactory.cs @@ -4,7 +4,7 @@ namespace NSubstitute.Core { public interface ISubstituteFactory { - object Create(Type[] typesToProxy, object[] constructorArguments); - object CreatePartial(Type[] typesToProxy, object[] constructorArguments); + object Create(Type[] typesToProxy, object[] constructorArguments); + object CreatePartial(Type[] typesToProxy, object[] constructorArguments); } } \ No newline at end of file diff --git a/src/NSubstitute/Core/Maybe.cs b/src/NSubstitute/Core/Maybe.cs index 6db701564..f571ba12f 100644 --- a/src/NSubstitute/Core/Maybe.cs +++ b/src/NSubstitute/Core/Maybe.cs @@ -45,7 +45,7 @@ IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator() { - return ((IEnumerable) this).GetEnumerator(); + return ((IEnumerable)this).GetEnumerator(); } } diff --git a/src/NSubstitute/Core/PropertyHelper.cs b/src/NSubstitute/Core/PropertyHelper.cs index ca637d3ef..cc76b5cea 100644 --- a/src/NSubstitute/Core/PropertyHelper.cs +++ b/src/NSubstitute/Core/PropertyHelper.cs @@ -18,7 +18,7 @@ public PropertyHelper(ICallFactory callFactory, IArgumentSpecificationCompatibil _callFactory = callFactory; _argSpecCompatTester = argSpecCompatTester; } - + public bool IsCallToSetAReadWriteProperty(ICall call) { var propertySetter = GetPropertyFromSetterCall(call); @@ -45,7 +45,7 @@ public ICall CreateCallToPropertyGetterFromSetterCall(ICall callToSetter) var getter = propertyInfo.GetGetMethod(nonPublic: true); if (getter is null) throw new SubstituteInternalException("A property with a getter expected."); - + var getterArgs = SkipLast(callToSetter.GetOriginalArguments()); var getterArgumentSpecifications = GetGetterCallSpecificationsFromSetterCall(callToSetter); diff --git a/src/NSubstitute/Core/ResultsForType.cs b/src/NSubstitute/Core/ResultsForType.cs index b777f1403..0da23870b 100644 --- a/src/NSubstitute/Core/ResultsForType.cs +++ b/src/NSubstitute/Core/ResultsForType.cs @@ -40,7 +40,7 @@ public MatchingReturnTypeSpecification(Type expectedReturnType) public bool IsSatisfiedBy(ICall call) => call.GetReturnType() == _expectedReturnType; - + // ******* Rest methods are not required ******* public string Format(ICall call) diff --git a/src/NSubstitute/Core/SequenceChecking/SequenceFormatter.cs b/src/NSubstitute/Core/SequenceChecking/SequenceFormatter.cs index 699d5a68b..5c8d20e9b 100644 --- a/src/NSubstitute/Core/SequenceChecking/SequenceFormatter.cs +++ b/src/NSubstitute/Core/SequenceChecking/SequenceFormatter.cs @@ -116,7 +116,7 @@ private IEnumerable FormatArgs(ArgAndParamInfo[] arguments) var argsWithParamsExpanded = arguments .SelectMany(a => a.ParamInfo.IsParams() - ? ((IEnumerable) a.Argument!).Cast() + ? ((IEnumerable)a.Argument!).Cast() : ToEnumerable(a.Argument)) .Select(x => ArgumentFormatter.Default.Format(x, false)) .ToArray(); diff --git a/src/NSubstitute/Core/SequenceChecking/SequenceInOrderAssertion.cs b/src/NSubstitute/Core/SequenceChecking/SequenceInOrderAssertion.cs index 128413606..1573a15fe 100644 --- a/src/NSubstitute/Core/SequenceChecking/SequenceInOrderAssertion.cs +++ b/src/NSubstitute/Core/SequenceChecking/SequenceInOrderAssertion.cs @@ -25,11 +25,11 @@ public void Assert(IQueryResults queryResult) var callsAndSpecs = matchingCallsInOrder .Zip(querySpec, (call, specAndTarget) => new - { - Call = call, - Spec = specAndTarget.CallSpecification, - IsMatch = Matches(call, specAndTarget) - } + { + Call = call, + Spec = specAndTarget.CallSpecification, + IsMatch = Matches(call, specAndTarget) + } ); if (callsAndSpecs.Any(x => !x.IsMatch)) diff --git a/src/NSubstitute/Core/ThreadLocalContext.cs b/src/NSubstitute/Core/ThreadLocalContext.cs index 9103e94b1..a916ee035 100644 --- a/src/NSubstitute/Core/ThreadLocalContext.cs +++ b/src/NSubstitute/Core/ThreadLocalContext.cs @@ -41,8 +41,8 @@ public ConfiguredCall LastCallShouldReturn(IReturn value, MatchArgs matchArgs) if (lastCallRouter == null) throw new CouldNotSetReturnDueToNoLastCallException(); - if(!PendingSpecification.HasPendingCallSpecInfo()) - throw new CouldNotSetReturnDueToMissingInfoAboutLastCallException(); + if (!PendingSpecification.HasPendingCallSpecInfo()) + throw new CouldNotSetReturnDueToMissingInfoAboutLastCallException(); if (_argumentSpecifications.Value.Count > 0) { diff --git a/src/NSubstitute/Exceptions/CannotReturnNullforValueType.cs b/src/NSubstitute/Exceptions/CannotReturnNullforValueType.cs index 6d584a154..8c3ad10de 100644 --- a/src/NSubstitute/Exceptions/CannotReturnNullforValueType.cs +++ b/src/NSubstitute/Exceptions/CannotReturnNullforValueType.cs @@ -8,6 +8,6 @@ public class CannotReturnNullForValueType : SubstituteException "Cannot return null for {0} because it is a value type. " + "If you want to return the default value for this type use \"default({0})\"."; - public CannotReturnNullForValueType(Type valueType) : base(string.Format(Description, valueType.Name)) {} + public CannotReturnNullForValueType(Type valueType) : base(string.Format(Description, valueType.Name)) { } } } diff --git a/src/NSubstitute/Exceptions/CouldNotSetReturnException.cs b/src/NSubstitute/Exceptions/CouldNotSetReturnException.cs index ae9829b3c..a1f33510a 100644 --- a/src/NSubstitute/Exceptions/CouldNotSetReturnException.cs +++ b/src/NSubstitute/Exceptions/CouldNotSetReturnException.cs @@ -5,7 +5,7 @@ namespace NSubstitute.Exceptions { public abstract class CouldNotSetReturnException : SubstituteException { - protected const string WhatProbablyWentWrong = + protected const string WhatProbablyWentWrong = "Make sure you called Returns() after calling your substitute (for example: mySub.SomeMethod().Returns(value)),\n" + "and that you are not configuring other substitutes within Returns() (for example, avoid this: mySub.SomeMethod().Returns(ConfigOtherSub())).\n" + "\n" + @@ -44,8 +44,8 @@ public CouldNotSetReturnDueToTypeMismatchException(Type? returnType, MethodInfo private static string DescribeProblem(Type? typeOfReturnValue, MethodInfo member) { - return typeOfReturnValue == null - ? string.Format("Can not return null for {0}.{1} (expected type {2}).", member.DeclaringType!.Name, member.Name, member.ReturnType.Name) + return typeOfReturnValue == null + ? string.Format("Can not return null for {0}.{1} (expected type {2}).", member.DeclaringType!.Name, member.Name, member.ReturnType.Name) : string.Format("Can not return value of type {0} for {1}.{2} (expected type {3}).", typeOfReturnValue.Name, member.DeclaringType!.Name, member.Name, member.ReturnType.Name); } } diff --git a/src/NSubstitute/Exceptions/SubstituteInternalException.cs b/src/NSubstitute/Exceptions/SubstituteInternalException.cs index b5dca1ff1..4bef21a54 100644 --- a/src/NSubstitute/Exceptions/SubstituteInternalException.cs +++ b/src/NSubstitute/Exceptions/SubstituteInternalException.cs @@ -9,6 +9,7 @@ public SubstituteInternalException() : this("") { } public SubstituteInternalException(string message) : this(message, null) { } public SubstituteInternalException(string message, Exception? innerException) : base("Please report this exception at https://github.com/nsubstitute/NSubstitute/issues: \n\n" + message, - innerException) { } + innerException) + { } } } \ No newline at end of file diff --git a/src/NSubstitute/Extensions/ConfigurationExtensions.cs b/src/NSubstitute/Extensions/ConfigurationExtensions.cs index 32a1b98a1..5bebd4ed4 100644 --- a/src/NSubstitute/Extensions/ConfigurationExtensions.cs +++ b/src/NSubstitute/Extensions/ConfigurationExtensions.cs @@ -27,7 +27,7 @@ public static class ConfigurationExtensions public static T Configure(this T substitute) where T : class { if (substitute == null) throw new NullSubstituteReferenceException(); - + var context = SubstitutionContext.Current; var callRouter = context.GetCallRouterFor(substitute!); context.ThreadContext.SetNextRoute(callRouter, context.RouteFactory.RecordCallSpecification); diff --git a/src/NSubstitute/Extensions/ExceptionExtensions.cs b/src/NSubstitute/Extensions/ExceptionExtensions.cs index c02ce304a..030f67fc3 100644 --- a/src/NSubstitute/Extensions/ExceptionExtensions.cs +++ b/src/NSubstitute/Extensions/ExceptionExtensions.cs @@ -239,13 +239,14 @@ private static object FromException(object value, Exception exception) { var fromExceptionMethodInfo = typeof(Task).GetMethods(BindingFlags.Static | BindingFlags.Public).Single(m => m.Name == "FromException" && m.ContainsGenericParameters); var specificFromExceptionMethod = fromExceptionMethodInfo.MakeGenericMethod(valueType.GenericTypeArguments); - return specificFromExceptionMethod.Invoke(null, new object[] {exception}); + return specificFromExceptionMethod.Invoke(null, new object[] { exception }); } return TaskFromException(exception); } - private static Task TaskFromException(Exception ex) { + private static Task TaskFromException(Exception ex) + { #if NET45 return new Task(() => throw ex); #else diff --git a/src/NSubstitute/Extensions/ReceivedExtensions.cs b/src/NSubstitute/Extensions/ReceivedExtensions.cs index c1293568e..0d2502d07 100644 --- a/src/NSubstitute/Extensions/ReceivedExtensions.cs +++ b/src/NSubstitute/Extensions/ReceivedExtensions.cs @@ -112,14 +112,15 @@ public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != typeof (ExactQuantity)) return false; - return Equals((ExactQuantity) obj); + if (obj.GetType() != typeof(ExactQuantity)) return false; + return Equals((ExactQuantity)obj); } public override int GetHashCode() { return _number; } } - private class AnyNonZeroQuantity : Quantity { + private class AnyNonZeroQuantity : Quantity + { public override bool Matches(IEnumerable items) { return items.Any(); } public override bool RequiresMoreThan(IEnumerable items) { return !items.Any(); } @@ -137,8 +138,8 @@ public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != typeof (AnyNonZeroQuantity)) return false; - return Equals((AnyNonZeroQuantity) obj); + if (obj.GetType() != typeof(AnyNonZeroQuantity)) return false; + return Equals((AnyNonZeroQuantity)obj); } public override int GetHashCode() @@ -165,8 +166,8 @@ public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != typeof (NoneQuantity)) return false; - return Equals((NoneQuantity) obj); + if (obj.GetType() != typeof(NoneQuantity)) return false; + return Equals((NoneQuantity)obj); } public override int GetHashCode() { return 0; } @@ -176,12 +177,15 @@ private class RangeQuantity : Quantity { private readonly int minInclusive; private readonly int maxInclusive; - public RangeQuantity(int minInclusive, int maxInclusive) { - if (minInclusive < 0) { + public RangeQuantity(int minInclusive, int maxInclusive) + { + if (minInclusive < 0) + { throw new ArgumentOutOfRangeException(nameof(minInclusive), $"{nameof(minInclusive)} must be >= 0, but was {minInclusive}."); } - if (maxInclusive <= minInclusive) { + if (maxInclusive <= minInclusive) + { throw new ArgumentOutOfRangeException(nameof(maxInclusive), $"{nameof(maxInclusive)} must be greater than {nameof(minInclusive)} (was {maxInclusive}, required > {minInclusive})."); } @@ -191,7 +195,8 @@ public RangeQuantity(int minInclusive, int maxInclusive) { public override string Describe(string singularNoun, string pluralNoun) => $"between {minInclusive} and {maxInclusive} (inclusive) {((maxInclusive == 1) ? singularNoun : pluralNoun)}"; - public override bool Matches(IEnumerable items) { + public override bool Matches(IEnumerable items) + { var count = items.Count(); return count >= minInclusive && count <= maxInclusive; } diff --git a/src/NSubstitute/NSubstitute.csproj b/src/NSubstitute/NSubstitute.csproj index b1611cf78..f6ffa0d32 100644 --- a/src/NSubstitute/NSubstitute.csproj +++ b/src/NSubstitute/NSubstitute.csproj @@ -32,7 +32,6 @@ true - true true nsubstitute.snk diff --git a/src/NSubstitute/Proxies/CastleDynamicProxy/CastleDynamicProxyFactory.cs b/src/NSubstitute/Proxies/CastleDynamicProxy/CastleDynamicProxyFactory.cs index 99be50e05..d6be3da9d 100644 --- a/src/NSubstitute/Proxies/CastleDynamicProxy/CastleDynamicProxyFactory.cs +++ b/src/NSubstitute/Proxies/CastleDynamicProxy/CastleDynamicProxyFactory.cs @@ -42,7 +42,7 @@ private object GenerateTypeProxy(ICallRouter callRouter, Type typeToProxy, Type[ typeToProxy, additionalInterfaces, constructorArguments, - new IInterceptor[] {proxyIdInterceptor, forwardingInterceptor}, + new IInterceptor[] { proxyIdInterceptor, forwardingInterceptor }, proxyGenerationOptions); forwardingInterceptor.SwitchToFullDispatchMode(); @@ -65,7 +65,7 @@ private object GenerateDelegateProxy(ICallRouter callRouter, Type delegateType, typeToProxy: typeof(object), additionalInterfaces: null, constructorArguments: null, - interceptors: new IInterceptor[] {proxyIdInterceptor, forwardingInterceptor}, + interceptors: new IInterceptor[] { proxyIdInterceptor, forwardingInterceptor }, proxyGenerationOptions); forwardingInterceptor.SwitchToFullDispatchMode(); diff --git a/src/NSubstitute/Proxies/ProxyFactory.cs b/src/NSubstitute/Proxies/ProxyFactory.cs index d8ecf957b..b28558bc7 100644 --- a/src/NSubstitute/Proxies/ProxyFactory.cs +++ b/src/NSubstitute/Proxies/ProxyFactory.cs @@ -19,7 +19,7 @@ public ProxyFactory(IProxyFactory delegateFactory, IProxyFactory dynamicProxyFac public object GenerateProxy(ICallRouter callRouter, Type typeToProxy, Type[]? additionalInterfaces, object?[]? constructorArguments) { var isDelegate = typeToProxy.IsDelegate(); - return isDelegate + return isDelegate ? _delegateFactory.GenerateProxy(callRouter, typeToProxy, additionalInterfaces, constructorArguments) : _dynamicProxyFactory.GenerateProxy(callRouter, typeToProxy, additionalInterfaces, constructorArguments); } diff --git a/src/NSubstitute/Raise.cs b/src/NSubstitute/Raise.cs index 3e367c20d..45cc94a58 100644 --- a/src/NSubstitute/Raise.cs +++ b/src/NSubstitute/Raise.cs @@ -83,7 +83,7 @@ private static object[] FixParamsArrayAmbiguity(object[] arguments, Type delegat if (singleParameterType.IsInstanceOfType(arguments)) { - return new object[] {arguments}; + return new object[] { arguments }; } return arguments; diff --git a/src/NSubstitute/Routing/AutoValues/AutoTaskProvider.cs b/src/NSubstitute/Routing/AutoValues/AutoTaskProvider.cs index d8702a901..22c709035 100644 --- a/src/NSubstitute/Routing/AutoValues/AutoTaskProvider.cs +++ b/src/NSubstitute/Routing/AutoValues/AutoTaskProvider.cs @@ -30,8 +30,8 @@ public object GetValue(Type type) var value = valueProvider == null ? GetDefault(type) : valueProvider.GetValue(taskType); var taskCompletionSourceType = typeof(TaskCompletionSource<>).MakeGenericType(taskType); var taskCompletionSource = Activator.CreateInstance(taskCompletionSourceType); - taskCompletionSourceType.GetMethod(nameof(TaskCompletionSource.SetResult))!.Invoke(taskCompletionSource, new[] {value}); - return taskCompletionSourceType.GetProperty(nameof(TaskCompletionSource.Task))!.GetValue( taskCompletionSource, null)!; + taskCompletionSourceType.GetMethod(nameof(TaskCompletionSource.SetResult))!.Invoke(taskCompletionSource, new[] { value }); + return taskCompletionSourceType.GetProperty(nameof(TaskCompletionSource.Task))!.GetValue(taskCompletionSource, null)!; } else { diff --git a/src/NSubstitute/Routing/Handlers/DoActionsCallHandler.cs b/src/NSubstitute/Routing/Handlers/DoActionsCallHandler.cs index d3fc9863f..0eceaf3c0 100644 --- a/src/NSubstitute/Routing/Handlers/DoActionsCallHandler.cs +++ b/src/NSubstitute/Routing/Handlers/DoActionsCallHandler.cs @@ -2,7 +2,7 @@ namespace NSubstitute.Routing.Handlers { - public class DoActionsCallHandler :ICallHandler + public class DoActionsCallHandler : ICallHandler { private readonly ICallActions _callActions; diff --git a/src/NSubstitute/Routing/Handlers/EventSubscriptionHandler.cs b/src/NSubstitute/Routing/Handlers/EventSubscriptionHandler.cs index 0eb1e089e..3638038df 100644 --- a/src/NSubstitute/Routing/Handlers/EventSubscriptionHandler.cs +++ b/src/NSubstitute/Routing/Handlers/EventSubscriptionHandler.cs @@ -6,7 +6,7 @@ namespace NSubstitute.Routing.Handlers { - public class EventSubscriptionHandler: ICallHandler + public class EventSubscriptionHandler : ICallHandler { private readonly IEventHandlerRegistry _eventHandlerRegistry; diff --git a/src/NSubstitute/Routing/Handlers/SetActionForCallHandler.cs b/src/NSubstitute/Routing/Handlers/SetActionForCallHandler.cs index dcf45cfa8..3a1160984 100644 --- a/src/NSubstitute/Routing/Handlers/SetActionForCallHandler.cs +++ b/src/NSubstitute/Routing/Handlers/SetActionForCallHandler.cs @@ -3,7 +3,7 @@ namespace NSubstitute.Routing.Handlers { - public class SetActionForCallHandler :ICallHandler + public class SetActionForCallHandler : ICallHandler { private readonly ICallSpecificationFactory _callSpecificationFactory; private readonly ICallActions _callActions; diff --git a/src/NSubstitute/Substitute.cs b/src/NSubstitute/Substitute.cs index d1ca5f510..206e57f4a 100644 --- a/src/NSubstitute/Substitute.cs +++ b/src/NSubstitute/Substitute.cs @@ -19,10 +19,10 @@ public static class Substitute /// The type of interface or class to substitute. /// Arguments required to construct a class being substituted. Not required for interfaces or classes with default constructors. /// A substitute for the interface or class. - public static T For(params object[] constructorArguments) + public static T For(params object[] constructorArguments) where T : class { - return (T) For(new[] {typeof(T)}, constructorArguments); + return (T)For(new[] { typeof(T) }, constructorArguments); } /// @@ -38,7 +38,7 @@ public static T1 For(params object[] constructorArguments) where T1 : class where T2 : class { - return (T1) For(new[] { typeof(T1), typeof(T2) }, constructorArguments); + return (T1)For(new[] { typeof(T1), typeof(T2) }, constructorArguments); } /// @@ -57,7 +57,7 @@ public static T1 For(params object[] constructorArguments) where T2 : class where T3 : class { - return (T1) For(new[] { typeof(T1), typeof(T2), typeof(T3) }, constructorArguments); + return (T1)For(new[] { typeof(T1), typeof(T2), typeof(T3) }, constructorArguments); } /// @@ -68,7 +68,7 @@ public static T1 For(params object[] constructorArguments) /// The types of interfaces or a type of class and multiple interfaces the substitute should implement. /// Arguments required to construct a class being substituted. Not required for interfaces or classes with default constructors. /// A substitute implementing the specified types. - public static object For(Type[] typesToProxy, object[] constructorArguments) + public static object For(Type[] typesToProxy, object[] constructorArguments) { var substituteFactory = SubstitutionContext.Current.SubstituteFactory; return substituteFactory.Create(typesToProxy, constructorArguments); @@ -84,11 +84,11 @@ public static object For(Type[] typesToProxy, object[] constructorArguments) /// /// An instance of the class that will execute real methods when called, but allows parts to be selectively /// overridden via `Returns` and `When..DoNotCallBase`. - public static T ForPartsOf(params object[] constructorArguments) + public static T ForPartsOf(params object[] constructorArguments) where T : class { var substituteFactory = SubstitutionContext.Current.SubstituteFactory; - return (T) substituteFactory.CreatePartial(new[] {typeof (T)}, constructorArguments); + return (T)substituteFactory.CreatePartial(new[] { typeof(T) }, constructorArguments); } } } \ No newline at end of file diff --git a/tests/NSubstitute.Acceptance.Specs/ArgumentMatching.cs b/tests/NSubstitute.Acceptance.Specs/ArgumentMatching.cs index 56966e7af..c87bb603e 100644 --- a/tests/NSubstitute.Acceptance.Specs/ArgumentMatching.cs +++ b/tests/NSubstitute.Acceptance.Specs/ArgumentMatching.cs @@ -84,24 +84,24 @@ public void Should_match_strings_by_content() [Test] public void Should_match_nullable_ref_types_by_content() { - #nullable enable +#nullable enable SomeClass? nullClassToMatch = null; List? nullList = null; _something.Anything(Arg.Is(nullClassToMatch)).Returns(456); Assert.That(_something.Anything(nullClassToMatch), Is.EqualTo(456)); Assert.That(_something.Anything(nullList), Is.EqualTo(456)); - #nullable disable +#nullable disable } [Test] public void Should_match_non_string_non_record_ref_types_by_reference() { - var listToMatch = new List{1, 2}; + var listToMatch = new List { 1, 2 }; _something.Anything(Arg.Is(listToMatch)).Returns(123); Assert.That(_something.Anything(listToMatch), Is.EqualTo(123)); - Assert.That(_something.Anything(new List{1, 2}), Is.EqualTo(0)); + Assert.That(_something.Anything(new List { 1, 2 }), Is.EqualTo(0)); var classToMatch = new SomeClass(); _something.Anything(Arg.Is(classToMatch)).Returns(456); diff --git a/tests/NSubstitute.Acceptance.Specs/AssemblySigningTest.cs b/tests/NSubstitute.Acceptance.Specs/AssemblySigningTest.cs index 55fdacedb..f92e7f3d1 100644 --- a/tests/NSubstitute.Acceptance.Specs/AssemblySigningTest.cs +++ b/tests/NSubstitute.Acceptance.Specs/AssemblySigningTest.cs @@ -11,7 +11,7 @@ public void NSubstitute_assembly_should_be_signed() { var assemblyName = typeof(Substitute).GetTypeInfo().Assembly.GetName(); var publicKeyToken = string.Join("", assemblyName.GetPublicKeyToken().Select(x => x.ToString("x"))); - + Assert.That(publicKeyToken, Is.EqualTo("92dd2e9066daa5ca")); } } diff --git a/tests/NSubstitute.Acceptance.Specs/AutoValuesForSubs.cs b/tests/NSubstitute.Acceptance.Specs/AutoValuesForSubs.cs index cd5b3aff0..4142018b6 100644 --- a/tests/NSubstitute.Acceptance.Specs/AutoValuesForSubs.cs +++ b/tests/NSubstitute.Acceptance.Specs/AutoValuesForSubs.cs @@ -147,7 +147,8 @@ public void Should_auto_return_a_substitute_from_a_delegate_that_returns_an_inte } [Test] - public void Should_auto_return_a_value_from_a_task() { + public void Should_auto_return_a_value_from_a_task() + { var sub = Substitute.For(); var task = sub.GetIntAsync(); Assert.That(task.IsCompleted, Is.True); @@ -155,7 +156,8 @@ public void Should_auto_return_a_value_from_a_task() { } [Test] - public void Should_auto_return_an_autosub_from_a_task() { + public void Should_auto_return_an_autosub_from_a_task() + { var sub = Substitute.For(); var task = sub.GetSample(); @@ -168,13 +170,14 @@ public void Should_auto_return_an_autosub_from_a_task() { } [Test] - public void Should_auto_return_a_completed_non_generic_task() { + public void Should_auto_return_a_completed_non_generic_task() + { var sub = Substitute.For(); var task = sub.GetNonGenericTask(); Assert.That(task.IsCompleted, Is.True); } - public interface IFooWithTasks + public interface IFooWithTasks { System.Threading.Tasks.Task GetSample(); System.Threading.Tasks.Task GetIntAsync(); @@ -182,7 +185,8 @@ public interface IFooWithTasks } [Test] - public void Should_auto_return_an_observable() { + public void Should_auto_return_an_observable() + { var sub = Substitute.For(); int sample = -42; sub.GetInts().Subscribe(new AnonymousObserver(x => sample = x)); @@ -190,7 +194,8 @@ public void Should_auto_return_an_observable() { } [Test] - public void Should_auto_return_an_autosub_from_an_observable() { + public void Should_auto_return_an_autosub_from_an_observable() + { var sub = Substitute.For(); ISample sample = null; sub.GetSamples().Subscribe(new AnonymousObserver(x => sample = x)); @@ -214,7 +219,7 @@ public void Multiple_calls_to_observable_method() Assert.That(sample1, Is.SameAs(sample2)); } - public interface IFooWithObservable + public interface IFooWithObservable { IObservable GetInts(); IObservable GetSamples(); @@ -231,7 +236,7 @@ public AnonymousObserver(Action onNext, Action onError = null, Act { _onNext = onNext ?? (_ => { }); _onError = onError ?? (_ => { }); - _onCompleted = onCompleted ?? (() => {}); + _onCompleted = onCompleted ?? (() => { }); } public void OnNext(T value) { _onNext(value); } diff --git a/tests/NSubstitute.Acceptance.Specs/CallbackCalling.cs b/tests/NSubstitute.Acceptance.Specs/CallbackCalling.cs index 95beadbee..991128627 100644 --- a/tests/NSubstitute.Acceptance.Specs/CallbackCalling.cs +++ b/tests/NSubstitute.Acceptance.Specs/CallbackCalling.cs @@ -271,7 +271,7 @@ public void WhenRunOutOfCallbacks() { _something.Count(); } - Assert.That(calls, Is.EqualTo(new[] {"1", "2", "3"})); + Assert.That(calls, Is.EqualTo(new[] { "1", "2", "3" })); } [Test] @@ -291,7 +291,7 @@ public void WhenToldToKeepDoingSomething() { _something.Count(); } - Assert.That(calls, Is.EqualTo(new[] {"1", "2", "3", "+", "+"})); + Assert.That(calls, Is.EqualTo(new[] { "1", "2", "3", "+", "+" })); } [Test] @@ -311,7 +311,7 @@ public void WhenToldToKeepThrowingAfterCallbacks() Assert.Throws(() => _something.Count()); Assert.Throws(() => _something.Count()); Assert.Throws(() => _something.Count()); - Assert.That(calls, Is.EqualTo(new[] {"1", "2"})); + Assert.That(calls, Is.EqualTo(new[] { "1", "2" })); } [Test] @@ -331,7 +331,7 @@ public void KeepDoingAndAlwaysDo() { _something.Count(); } - Assert.That(calls, Is.EqualTo(new[] {"1", "+", "+", "+", "+"})); + Assert.That(calls, Is.EqualTo(new[] { "1", "+", "+", "+", "+" })); Assert.That(count, Is.EqualTo(5)); } diff --git a/tests/NSubstitute.Acceptance.Specs/CompatArgsTests.cs b/tests/NSubstitute.Acceptance.Specs/CompatArgsTests.cs index ff598c2f7..fd56d654b 100644 --- a/tests/NSubstitute.Acceptance.Specs/CompatArgsTests.cs +++ b/tests/NSubstitute.Acceptance.Specs/CompatArgsTests.cs @@ -4,12 +4,15 @@ using NSubstitute.Compatibility; using NUnit.Framework; -namespace NSubstitute.Acceptance.Specs { +namespace NSubstitute.Acceptance.Specs +{ - public class CompatArgsTests { + public class CompatArgsTests + { [Test] - public void CompatAndCompatArgInstanceShouldBeInSync() { + public void CompatAndCompatArgInstanceShouldBeInSync() + { var flags = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance; var compatMembers = typeof(Arg.Compat).GetMethods(flags).Select(DescribeMethod).OrderBy(x => x); @@ -23,7 +26,8 @@ public void CompatAndCompatArgInstanceShouldBeInSync() { } [Test] - public void CompatAndArgShouldBeInSync() { + public void CompatAndArgShouldBeInSync() + { var flags = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance; var argMembers = typeof(Arg).GetMethods(flags).Select(DescribeMethod).OrderBy(x => x); @@ -36,15 +40,18 @@ public void CompatAndArgShouldBeInSync() { ); } - private static string DescribeMethod(MethodInfo m) { + private static string DescribeMethod(MethodInfo m) + { return $"{m.Name}<{DescribeTypeList(m.GetGenericArguments())}>({DescribeParameters(m.GetParameters())})"; } - private static string DescribeTypeList(Type[] args) { + private static string DescribeTypeList(Type[] args) + { return string.Join(", ", args.Select(x => x.Name)); } - private static string DescribeParameters(ParameterInfo[] parameters) { + private static string DescribeParameters(ParameterInfo[] parameters) + { return string.Join(", ", parameters.Select(x => $"{x.ParameterType.Name} {x.Name}")); } diff --git a/tests/NSubstitute.Acceptance.Specs/ExceptionsWhenCheckingSequencesOfCalls.cs b/tests/NSubstitute.Acceptance.Specs/ExceptionsWhenCheckingSequencesOfCalls.cs index 20a6c0e2b..e22414584 100644 --- a/tests/NSubstitute.Acceptance.Specs/ExceptionsWhenCheckingSequencesOfCalls.cs +++ b/tests/NSubstitute.Acceptance.Specs/ExceptionsWhenCheckingSequencesOfCalls.cs @@ -21,7 +21,7 @@ public interface IBar { int Huh(); } - + [TestFixture] public class ExceptionsWhenCheckingSequencesOfCalls { diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/ArgMatchingWithNestedSubCalls.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/ArgMatchingWithNestedSubCalls.cs index 037155c46..75ffe97bf 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/ArgMatchingWithNestedSubCalls.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/ArgMatchingWithNestedSubCalls.cs @@ -5,7 +5,8 @@ namespace NSubstitute.Acceptance.Specs.FieldReports public class ArgMatchingWithNestedSubCalls { public interface IHaveAMethod { void Method(int a, string b); } - public interface IStealArgMatchers { + public interface IStealArgMatchers + { string StealMatcherBeforeUsedElsewhere { get; } string this[int i] { get; } } @@ -19,7 +20,7 @@ public void Use_arg_matcher_then_access_another_sub_without_args_before_call_spe sub.Method(2, stealer.StealMatcherBeforeUsedElsewhere); sub.Received().Method(Arg.Any(), stealer.StealMatcherBeforeUsedElsewhere); - } + } [Test] [Pending, Explicit] @@ -34,6 +35,6 @@ public void Use_arg_matcher_then_access_another_sub_with_args_before_call_spec_i //This example still blows up because the call to stealer[0] takes the Arg.Any() matcher //away. The call router thinks the Arg.Any belongs to that call, not the sub.Method() call. sub.Received().Method(Arg.Any(), stealer[0]); - } + } } } \ No newline at end of file diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/CallingIntoNewSubWithinReturns.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/CallingIntoNewSubWithinReturns.cs index 12a8ace1b..71e5d3a96 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/CallingIntoNewSubWithinReturns.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/CallingIntoNewSubWithinReturns.cs @@ -15,7 +15,7 @@ public void ShouldDetectTypeMismatchInReturns() { var sub = Substitute.For(); - var ex = + var ex = Assert.Throws(() => // GetFoo() called, then IPityTheFoo(), then Returns(..) is called. // This means Returns(..) tries to update the last called sub, @@ -38,7 +38,7 @@ public void ShouldDetectedWhenNestedReturnsClearsLastCallRouter() { var sub = Substitute.For(); - Assert.Throws(() => + Assert.Throws(() => sub.GetFoo().Returns(CreateFooAndCallReturns()) ); } @@ -55,8 +55,8 @@ public void ShouldDetectTypeMismatchWhenNullIsInvolved() { var sub = Substitute.For(); - var ex = - Assert.Throws(() => + var ex = + Assert.Throws(() => sub.GetFoo().Returns(DoEvilAndReturnNullRef()) ); diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/DisposeWithThreadLocal.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/DisposeWithThreadLocal.cs index e2b1ad86d..157d11e60 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/DisposeWithThreadLocal.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/DisposeWithThreadLocal.cs @@ -8,7 +8,7 @@ public class DisposeWithThreadLocal [Test] public void DisposeSubstituteAndPerformGC() { - using (var s = Substitute.For()) { } + using (var s = Substitute.For()) { } GC.Collect(); GC.WaitForPendingFinalizers(); diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/ExceptionsThrownFromCustomArgumentMatchers.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/ExceptionsThrownFromCustomArgumentMatchers.cs index 21b89007b..a9a4b2325 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/ExceptionsThrownFromCustomArgumentMatchers.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/ExceptionsThrownFromCustomArgumentMatchers.cs @@ -4,7 +4,8 @@ namespace NSubstitute.Acceptance.Specs.FieldReports { public class ExceptionsThrownFromCustomArgumentMatchers { - public interface IRequest { + public interface IRequest + { string Get(string url); string[] GetMultiple(string[] url); } @@ -81,9 +82,9 @@ public void Multiple_conditions_where_one_requires_an_array_index_available() var emptyArray = new string[0]; var request = Substitute.For(); request.GetMultiple(Arg.Is(x => x[0] == "greeting")).Returns(new[] { "hello", "bye" }); - request.GetMultiple(emptyArray).Returns(new [] {"?"}); + request.GetMultiple(emptyArray).Returns(new[] { "?" }); - Assert.That(request.GetMultiple(new [] {"greeting"}), Is.EqualTo(new[] {"hello", "bye"})); + Assert.That(request.GetMultiple(new[] { "greeting" }), Is.EqualTo(new[] { "hello", "bye" })); Assert.That(request.GetMultiple(emptyArray), Is.EqualTo(new[] { "?" })); } } diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue118_ConcreteClassWithPublicStaticMethod.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue118_ConcreteClassWithPublicStaticMethod.cs index 6d5b8d7dc..011444e5c 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue118_ConcreteClassWithPublicStaticMethod.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue118_ConcreteClassWithPublicStaticMethod.cs @@ -64,7 +64,7 @@ public void Substitute_of_concrete_with_static_member_should_allow_setup_of_retu public class ConcreteWithPublicStaticMethod { public virtual string AProperty { get; set; } - public static void AStaticMethod() {} + public static void AStaticMethod() { } } public class ConcreteWithoutPublicStaticMethod diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue129_AmbiguousArgsWithOutRef.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue129_AmbiguousArgsWithOutRef.cs index fa321d5d7..3f3d8ceef 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue129_AmbiguousArgsWithOutRef.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue129_AmbiguousArgsWithOutRef.cs @@ -22,7 +22,7 @@ public void Test() }); string outString; - var result =substitute.DoStuff("a", out outString); + var result = substitute.DoStuff("a", out outString); Assert.That(result); Assert.That(outString, Is.EqualTo("test")); @@ -65,7 +65,7 @@ public void WorkAround() }); string outString; - var result =substitute.DoStuff("a", out outString); + var result = substitute.DoStuff("a", out outString); Assert.That(result); Assert.That(outString, Is.EqualTo("test")); diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue225_ConfiguredValueIsUsedInSubsequentSetups.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue225_ConfiguredValueIsUsedInSubsequentSetups.cs index e14eaa1dd..8b240500f 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue225_ConfiguredValueIsUsedInSubsequentSetups.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue225_ConfiguredValueIsUsedInSubsequentSetups.cs @@ -10,7 +10,7 @@ public void ShouldNotUseTheConfiguredValueDuringSubsequentSetup() { // Arrange var target = Substitute.For(); - + // Act target.Echo(Arg.Is(0)).Returns("00", "01", "02"); target.Echo(Arg.Is(1)).Returns("10", "11", "12"); @@ -22,6 +22,6 @@ public void ShouldNotUseTheConfiguredValueDuringSubsequentSetup() Assert.AreEqual("11", target.Echo(1)); Assert.AreEqual("02", target.Echo(0)); Assert.AreEqual("12", target.Echo(1)); - } + } } } \ No newline at end of file diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue262_NonPublicSetterCall.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue262_NonPublicSetterCall.cs index 470f09794..3db4abca3 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue262_NonPublicSetterCall.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue262_NonPublicSetterCall.cs @@ -49,7 +49,7 @@ public abstract class TestClass public abstract int ProtectedSetterProp { get; protected set; } public void SetProtectedSetterProp(int value) => ProtectedSetterProp = value; - + public abstract int ProtectedGetterProp { protected get; set; } public int GetProtectedGetterProp() => ProtectedGetterProp; } diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue291_CannotReconfigureThrowingConfiguration.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue291_CannotReconfigureThrowingConfiguration.cs index 7e3ea06dc..d7ec7d7e2 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue291_CannotReconfigureThrowingConfiguration.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue291_CannotReconfigureThrowingConfiguration.cs @@ -23,7 +23,7 @@ public void ShouldBePossibleToReConfigureThrowingConfiguration() // Arrange var response = new Response(); var deliver = Substitute.For(); - + // Act deliver.Send(Arg.Any()).Throws(); deliver.Send(Arg.Any()).Returns(response); @@ -38,11 +38,11 @@ public void ShouldBePossibleToConfigureConstantAfterThrowForAny() { // Arrange var something = Substitute.For(); - + // Act something.Echo(Arg.Any()).Throws(); something.Echo(Arg.Is(42)).Returns("42"); - + // Assert Assert.Throws(() => something.Echo(100)); Assert.AreEqual("42", something.Echo(42)); diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue47_RaisingEventsWithNullArg.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue47_RaisingEventsWithNullArg.cs index a2a366bf7..8321a7a30 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue47_RaisingEventsWithNullArg.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue47_RaisingEventsWithNullArg.cs @@ -24,7 +24,7 @@ public void Pass_null_when_raising_delegate_event() public void Pass_null_when_raising_eventhandlerish_event() { var sub = Substitute.For(); - sub.OnEventishThing += Raise.Event(new object[] {null}); + sub.OnEventishThing += Raise.Event(new object[] { null }); } } } \ No newline at end of file diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue500_SpecialMethodsWithoutAttribute.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue500_SpecialMethodsWithoutAttribute.cs index 1b4d618ee..b36db2444 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue500_SpecialMethodsWithoutAttribute.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue500_SpecialMethodsWithoutAttribute.cs @@ -19,7 +19,7 @@ static Issue500_SpecialMethodsWithoutAttribute() [Test] public void ShouldCorrectlyConfigureProperty() { - var substitute = Substitute.For(new[] {TypeWithMissingSpecialNameMethodAttributes}, new object[0]); + var substitute = Substitute.For(new[] { TypeWithMissingSpecialNameMethodAttributes }, new object[0]); var fixture = new GeneratedTypeFixture(substitute); fixture.MyProperty = "42"; @@ -31,7 +31,7 @@ public void ShouldCorrectlyConfigureProperty() [Test] public void ShouldCorrectlyConfigureEvent() { - object substitute = Substitute.For(new[] {TypeWithMissingSpecialNameMethodAttributes}, new object[0]); + object substitute = Substitute.For(new[] { TypeWithMissingSpecialNameMethodAttributes }, new object[0]); var fixture = new GeneratedTypeFixture(substitute); bool wasCalled = false; @@ -52,20 +52,20 @@ private static Type GenerateTypeWithMissingSpecialNameAttributes() var module = assembly.DefineDynamicModule(assemblyName); var typeBuilder = module.DefineType("TypeWithMissingSpecialAttributes", TypeAttributes.Public | TypeAttributes.Abstract); - + var evBuilder = typeBuilder.DefineEvent(EventName, EventAttributes.None, typeof(EventHandler)); var evAdder = typeBuilder.DefineMethod( $"add_{EventName}", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.Abstract | MethodAttributes.HideBySig | MethodAttributes.NewSlot /* | MethodAttributes.SpecialName */, typeof(void), - new[] {typeof(EventHandler)}); + new[] { typeof(EventHandler) }); var evRemover = typeBuilder.DefineMethod( $"remove_{EventName}", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.Abstract | MethodAttributes.HideBySig | MethodAttributes.NewSlot /* | MethodAttributes.SpecialName */, typeof(void), - new[] {typeof(EventHandler)}); + new[] { typeof(EventHandler) }); evBuilder.SetAddOnMethod(evAdder); evBuilder.SetRemoveOnMethod(evRemover); @@ -82,7 +82,7 @@ private static Type GenerateTypeWithMissingSpecialNameAttributes() MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.Abstract | MethodAttributes.HideBySig | MethodAttributes.NewSlot /* | MethodAttributes.SpecialName */, typeof(void), - new[] {typeof(object)}); + new[] { typeof(object) }); propBuilder.SetGetMethod(propGetter); propBuilder.SetSetMethod(propSetter); diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue560_RaiseEventWithArrayArg.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue560_RaiseEventWithArrayArg.cs index d5006b27b..54c0792fd 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue560_RaiseEventWithArrayArg.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue560_RaiseEventWithArrayArg.cs @@ -15,7 +15,7 @@ public void Raise_event_declared_as_action_with_ref_array_type() var eventSamples = Substitute.For(); eventSamples.ActionWithRefArrayType += x => arg = x; - eventSamples.ActionWithRefArrayType += Raise.Event>(new[] {w1, w2}); + eventSamples.ActionWithRefArrayType += Raise.Event>(new[] { w1, w2 }); Assert.That(arg, Is.Not.Null); Assert.That(arg.Length, Is.EqualTo(2)); Assert.That(arg[0], Is.EqualTo(w1)); @@ -26,7 +26,7 @@ public void Raise_event_declared_as_action_with_ref_array_type() public void Should_raise_event_for_object_array_arg() { object[] capturedArg = null; - var arg1 = new[] {new object(), new object()}; + var arg1 = new[] { new object(), new object() }; var eventSamples = Substitute.For(); eventSamples.ActionWithParamOfObjectArray += x => capturedArg = x; @@ -39,7 +39,7 @@ public void Should_raise_event_for_object_array_arg() public void Should_raise_event_for_object_array_arg_with_covariance() { object[] capturedArg = null; - var arg1 = new[] {"hello", "world"}; + var arg1 = new[] { "hello", "world" }; var eventSamples = Substitute.For(); eventSamples.ActionWithParamOfObjectArray += x => capturedArg = x; @@ -52,12 +52,12 @@ public void Should_raise_event_for_object_array_arg_with_covariance() public void Should_raise_event_for_object_array_arg_provided_without_using_params_syntax() { object[] capturedArg = null; - var arg1 = new[] {new object(), new object()}; + var arg1 = new[] { new object(), new object() }; var eventSamples = Substitute.For(); eventSamples.ActionWithParamOfObjectArray += x => capturedArg = x; - eventSamples.ActionWithParamOfObjectArray += Raise.Event>(new object[] {arg1}); + eventSamples.ActionWithParamOfObjectArray += Raise.Event>(new object[] { arg1 }); Assert.That(capturedArg, Is.EqualTo(arg1)); } @@ -65,12 +65,12 @@ public void Should_raise_event_for_object_array_arg_provided_without_using_param public void Should_raise_event_for_object_array_arg_provided_without_using_params_syntax_with_covariance() { object[] capturedArg = null; - var arg1 = new[] {"hello", "world"}; + var arg1 = new[] { "hello", "world" }; var eventSamples = Substitute.For(); eventSamples.ActionWithParamOfObjectArray += x => capturedArg = x; - eventSamples.ActionWithParamOfObjectArray += Raise.Event>(new object[] {arg1}); + eventSamples.ActionWithParamOfObjectArray += Raise.Event>(new object[] { arg1 }); Assert.That(capturedArg, Is.EqualTo(arg1)); } @@ -78,8 +78,8 @@ public void Should_raise_event_for_object_array_arg_provided_without_using_param public void Should_raise_event_for_multiple_object_array_args() { Tuple capturedArgs = null; - var arg1 = new[] {new object(), new object()}; - var arg2 = new[] {new object(), new object()}; + var arg1 = new[] { new object(), new object() }; + var arg2 = new[] { new object(), new object() }; var eventSamples = Substitute.For(); eventSamples.ActionWithParamsOfObjectArray += (a1, a2) => capturedArgs = Tuple.Create(a1, a2); diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue577_CannotSetOutValue.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue577_CannotSetOutValue.cs index 671bb97f2..b7fd59244 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue577_CannotSetOutValue.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue577_CannotSetOutValue.cs @@ -18,7 +18,7 @@ public void Should_reassign_out_value_when_type_is_incompatible_with_passed_valu out Arg.Any() ).Returns(info => { - var id = (string) info[0]; + var id = (string)info[0]; if (id != null && id == "a") { info[1] = a; diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue77_EqualsBehaviourOnClassStubs.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue77_EqualsBehaviourOnClassStubs.cs index 3e4189766..be4d28b2a 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue77_EqualsBehaviourOnClassStubs.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue77_EqualsBehaviourOnClassStubs.cs @@ -51,7 +51,7 @@ public void Should_be_able_to_find_a_substitute_that_overrides_equals_in_a_colle { var substitute = Substitute.For(); substitute.Id = 2; - var classes = new [] {new AClassThatOverwritesBaseObjectMethods { Id = 1 }, substitute, new AClassThatOverwritesBaseObjectMethods { Id = 3 }}; + var classes = new[] { new AClassThatOverwritesBaseObjectMethods { Id = 1 }, substitute, new AClassThatOverwritesBaseObjectMethods { Id = 3 } }; Assert.That(classes.Contains(substitute), Is.True); } @@ -137,7 +137,7 @@ public void Should_be_able_to_check_equality_of_substitute_that_overrides_base_o var service = Substitute.For(); var substitute = Substitute.For(); substitute.Id = 1; - + service.ReturnClassOverridingBaseObjectMethods(1).Returns(substitute); Assert.That(service.ReturnClassOverridingBaseObjectMethods(1), Is.EqualTo(substitute)); @@ -214,7 +214,7 @@ public class AClassThatOverridesEquals public override int GetHashCode() { return 0; } } - public class AClassThatDoesntOverrideEquals {} + public class AClassThatDoesntOverrideEquals { } public class AClassThatOverwritesBaseObjectMethods { diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue_RaiseEventOnNonSubstitute.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue_RaiseEventOnNonSubstitute.cs index a1e530553..7bae4d051 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue_RaiseEventOnNonSubstitute.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue_RaiseEventOnNonSubstitute.cs @@ -8,7 +8,7 @@ public class Issue_RaiseEventOnNonSubstitute { public class Button { - public virtual event EventHandler Clicked = (s,e) => { }; + public virtual event EventHandler Clicked = (s, e) => { }; } public interface IController { void Load(); } diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/MigratingToCompatArgs.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/MigratingToCompatArgs.cs index 05eb7555e..2ce13070b 100644 --- a/tests/NSubstitute.Acceptance.Specs/FieldReports/MigratingToCompatArgs.cs +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/MigratingToCompatArgs.cs @@ -3,7 +3,8 @@ using NSubstitute.Compatibility; using NUnit.Framework; -namespace NSubstitute.Acceptance.Specs.FieldReports { +namespace NSubstitute.Acceptance.Specs.FieldReports +{ /// /// Can migrate from the old matchers to by putting a @@ -12,19 +13,24 @@ namespace NSubstitute.Acceptance.Specs.FieldReports { /// /// To migrate back(once project switches to C#7+), just delete the CompatArgInstance field. /// - public class MigratingToCompatArgs { + public class MigratingToCompatArgs + { - public class TestBaseClass { + public class TestBaseClass + { protected static readonly CompatArg Arg = CompatArg.Instance; } - public interface IMessageServer { + public interface IMessageServer + { void SendMessage(int code, string description); } - public class SampleTestFixture : TestBaseClass { + public class SampleTestFixture : TestBaseClass + { [Test] - public void ArgMatcherUsingBaseClass() { + public void ArgMatcherUsingBaseClass() + { var sub = Substitute.For(); sub.SendMessage(42, "meaning of life?"); diff --git a/tests/NSubstitute.Acceptance.Specs/FormattingCallsWhenThrowingReceivedCallsExceptions.cs b/tests/NSubstitute.Acceptance.Specs/FormattingCallsWhenThrowingReceivedCallsExceptions.cs index e66fee154..748ac591e 100644 --- a/tests/NSubstitute.Acceptance.Specs/FormattingCallsWhenThrowingReceivedCallsExceptions.cs +++ b/tests/NSubstitute.Acceptance.Specs/FormattingCallsWhenThrowingReceivedCallsExceptions.cs @@ -267,7 +267,7 @@ public class When_checking_call_to_method_with_params : Context protected override void ConfigureContext() { Sample.ParamsMethod(2, "hello", "everybody"); - Sample.ParamsMethod(1, new[] {"hello", "everybody"}); + Sample.ParamsMethod(1, new[] { "hello", "everybody" }); Sample.ParamsMethod(1, "hello"); Sample.ParamsMethod(3, "1", "2", "3"); Sample.ParamsMethod(1); @@ -300,7 +300,7 @@ public class When_checking_call_to_method_with_valuetype_params : Context protected override void ConfigureContext() { Sample.IntParamsMethod(1, 2, 3); - Sample.IntParamsMethod(new[] {4, 5}); + Sample.IntParamsMethod(new[] { 4, 5 }); Sample.IntParamsMethod(); } @@ -333,7 +333,7 @@ protected override void ConfigureContext() protected override void ExpectedCall() { - Sample.Received().ParamsMethod(1, Arg.Is(new[] {"hello", "world"})); + Sample.Received().ParamsMethod(1, Arg.Is(new[] { "hello", "world" })); } [Test] diff --git a/tests/NSubstitute.Acceptance.Specs/GenericArguments.cs b/tests/NSubstitute.Acceptance.Specs/GenericArguments.cs index 10abd043a..9de31f700 100644 --- a/tests/NSubstitute.Acceptance.Specs/GenericArguments.cs +++ b/tests/NSubstitute.Acceptance.Specs/GenericArguments.cs @@ -81,7 +81,7 @@ public void Is_matcher_works_with_AnyType() public void Any_matcher_works_with_AnyType_and_constraints() { ISomethingWithGenerics something = Substitute.For(); - var state = new[] {3409}; + var state = new[] { 3409 }; something.SomeActionWithGenericConstraints(7, state); something.Received().SomeActionWithGenericConstraints(Arg.Any(), Arg.Any()); @@ -102,7 +102,7 @@ public void When_Do_works_with_AnyType_and_constraints() whenDoCalled = true; }); - var expected = new[] {3409}; + var expected = new[] { 3409 }; something.SomeActionWithGenericConstraints(7, expected); Assert.That(whenDoCalled, Is.True); @@ -116,7 +116,7 @@ public void ArgDo_works_with_AnyType_and_constraints() ISomethingWithGenerics something = Substitute.For(); something.SomeActionWithGenericConstraints(Arg.Any(), Arg.Do(a => argDoResult = ">>" + ((int[])a)[0].ToString("P", CultureInfo.InvariantCulture))); - something.SomeActionWithGenericConstraints(7, new[] {3409}); + something.SomeActionWithGenericConstraints(7, new[] { 3409 }); Assert.That(argDoResult, Is.EqualTo(">>340,900.00 %")); } @@ -128,7 +128,7 @@ public void Is_matcher_works_with_AnyType_and_constraints() something.SomeFunctionWithGenericConstraints(Arg.Any(), Arg.Is(a => ((int[])a)[0] == 3409)).Returns("matched"); - var result = something.SomeFunctionWithGenericConstraints(7, new[] {3409}); + var result = something.SomeFunctionWithGenericConstraints(7, new[] { 3409 }); Assert.That(result, Is.EqualTo("matched")); } diff --git a/tests/NSubstitute.Acceptance.Specs/MatchingDerivedTypesForGenerics.cs b/tests/NSubstitute.Acceptance.Specs/MatchingDerivedTypesForGenerics.cs index ad08a8ea1..521ae4e9f 100644 --- a/tests/NSubstitute.Acceptance.Specs/MatchingDerivedTypesForGenerics.cs +++ b/tests/NSubstitute.Acceptance.Specs/MatchingDerivedTypesForGenerics.cs @@ -2,111 +2,111 @@ namespace NSubstitute.Acceptance.Specs { - [TestFixture] - public class MatchingDerivedTypesForGenerics - { - IGenMethod _sub; - - [SetUp] - public void Setup() - { - _sub = Substitute.For(); - } - - [Test] - public void Calls_to_generic_types_with_derived_parameters_should_be_matched() - { - _sub.Call(new GMParam1()); - _sub.Call(new GMParam2()); - - _sub.Received(2).Call(Arg.Any()); - } - - [Test] - public void Calls_to_generic_types_expecting_specific_argument_type() - { - _sub.Call(new GMParam1()); - _sub.Call(new GMParam2()); - - _sub.Received(1).Call(Arg.Any()); - } - - [Test] - public void Calls_to_generic_types_expecting_specific_argument() - { - var gmParam1 = new GMParam1(); - _sub.Call(gmParam1); - _sub.Call(new GMParam2()); - - _sub.Received(1).Call(gmParam1); - } - - [Test] - public void Stub_generic_method() - { - _sub.IntCall(Arg.Any()).Returns(42); - - Assert.That(_sub.IntCall(new GMParam2()), Is.EqualTo(42)); - } - - [Test] - public void Stub_generic_method_with_specific_subtype() - { - _sub.IntCall(Arg.Any()).Returns(42); - - Assert.That(_sub.IntCall(new GMParam2()), Is.EqualTo(42)); - Assert.That(_sub.IntCall(new GMParam1()), Is.EqualTo(default(int))); - } - - public interface IGenMethod - { - void Call(T param) where T : IGMParam; - int IntCall(T param) where T : IGMParam; - } - public interface IGMParam { } - public class GMParam1 : IGMParam { } - public class GMParam2 : IGMParam { } - } - - [TestFixture] - public class Calls_to_members_on_generic_interface - { - [Test] - public void Calls_to_members_on_generic_interfaces_match_based_on_type_compatibility() - { - var sub = Substitute.For>(); - sub.Call(new GMParam1()); - sub.Call(new GMParam2()); - sub.Call(new GMParam3()); - - sub.Received(2).Call(Arg.Any()); - sub.Received(1).Call(Arg.Any()); - } - - [Test] + [TestFixture] + public class MatchingDerivedTypesForGenerics + { + IGenMethod _sub; + + [SetUp] + public void Setup() + { + _sub = Substitute.For(); + } + + [Test] + public void Calls_to_generic_types_with_derived_parameters_should_be_matched() + { + _sub.Call(new GMParam1()); + _sub.Call(new GMParam2()); + + _sub.Received(2).Call(Arg.Any()); + } + + [Test] + public void Calls_to_generic_types_expecting_specific_argument_type() + { + _sub.Call(new GMParam1()); + _sub.Call(new GMParam2()); + + _sub.Received(1).Call(Arg.Any()); + } + + [Test] + public void Calls_to_generic_types_expecting_specific_argument() + { + var gmParam1 = new GMParam1(); + _sub.Call(gmParam1); + _sub.Call(new GMParam2()); + + _sub.Received(1).Call(gmParam1); + } + + [Test] + public void Stub_generic_method() + { + _sub.IntCall(Arg.Any()).Returns(42); + + Assert.That(_sub.IntCall(new GMParam2()), Is.EqualTo(42)); + } + + [Test] + public void Stub_generic_method_with_specific_subtype() + { + _sub.IntCall(Arg.Any()).Returns(42); + + Assert.That(_sub.IntCall(new GMParam2()), Is.EqualTo(42)); + Assert.That(_sub.IntCall(new GMParam1()), Is.EqualTo(default(int))); + } + + public interface IGenMethod + { + void Call(T param) where T : IGMParam; + int IntCall(T param) where T : IGMParam; + } + public interface IGMParam { } + public class GMParam1 : IGMParam { } + public class GMParam2 : IGMParam { } + } + + [TestFixture] + public class Calls_to_members_on_generic_interface + { + [Test] + public void Calls_to_members_on_generic_interfaces_match_based_on_type_compatibility() + { + var sub = Substitute.For>(); + sub.Call(new GMParam1()); + sub.Call(new GMParam2()); + sub.Call(new GMParam3()); + + sub.Received(2).Call(Arg.Any()); + sub.Received(1).Call(Arg.Any()); + } + + [Test] [Pending, Explicit] - public void Potentially_ambiguous_matches() - { - var sub = Substitute.For>(); - sub.Call(new GMParam1()); - sub.Call(new GMParam2()); - sub.Call(new GMParam4()); - - sub.Received(2).Call(Arg.Any()); - sub.Received(1).Call(Arg.Any()); - } - - public interface IGenInterface - { - void Call(T param); - void Call(GMParam3 param); - void Call(GMParam4 param); - } - - public interface IGMParam { } - public class GMParam1 : IGMParam { } - public class GMParam2 : IGMParam { } - public class GMParam3 { } - public class GMParam4 : IGMParam { } - } + public void Potentially_ambiguous_matches() + { + var sub = Substitute.For>(); + sub.Call(new GMParam1()); + sub.Call(new GMParam2()); + sub.Call(new GMParam4()); + + sub.Received(2).Call(Arg.Any()); + sub.Received(1).Call(Arg.Any()); + } + + public interface IGenInterface + { + void Call(T param); + void Call(GMParam3 param); + void Call(GMParam4 param); + } + + public interface IGMParam { } + public class GMParam1 : IGMParam { } + public class GMParam2 : IGMParam { } + public class GMParam3 { } + public class GMParam4 : IGMParam { } + } } diff --git a/tests/NSubstitute.Acceptance.Specs/MultipleThreads.cs b/tests/NSubstitute.Acceptance.Specs/MultipleThreads.cs index e04da7369..114fa3c4d 100644 --- a/tests/NSubstitute.Acceptance.Specs/MultipleThreads.cs +++ b/tests/NSubstitute.Acceptance.Specs/MultipleThreads.cs @@ -85,7 +85,7 @@ public void Issue_64_check_received_while_calling_from_other_threads() if (!(ex.InnerException is ReceivedCallsException)) throw; var receivedCallsEx = (ReceivedCallsException)ex.InnerException; - Assert.That(receivedCallsEx.Message, Does.Not.Contain("Actually received " + expected + " matching calls"), + Assert.That(receivedCallsEx.Message, Does.Not.Contain("Actually received " + expected + " matching calls"), "Should not throw received calls exception if it actually received the same number of calls as expected. " + "If we get that it means there was a race between checking the expected calls and accessing the calls to put in the exception message."); } @@ -99,7 +99,7 @@ public void Issue_64_check_received_while_calling_from_other_threads() public void Create_Delegate_Substitute_From_Many_Threads() { var tasks = - Enumerable.Range(0, 20).Select( _ => + Enumerable.Range(0, 20).Select(_ => new BackgroundTask(() => { for (var i = 0; i < 1000; ++i) diff --git a/tests/NSubstitute.Acceptance.Specs/NSubContainerTests.cs b/tests/NSubstitute.Acceptance.Specs/NSubContainerTests.cs index 4ffd7c6a0..9e208feaa 100644 --- a/tests/NSubstitute.Acceptance.Specs/NSubContainerTests.cs +++ b/tests/NSubstitute.Acceptance.Specs/NSubContainerTests.cs @@ -258,7 +258,7 @@ public void ShouldDecorateTheExistingRegistration() var result = sutFork.Resolve(); Assert.That(result, Is.TypeOf()); - Assert.That(((TestImplDecorator) result).Inner, Is.TypeOf()); + Assert.That(((TestImplDecorator)result).Inner, Is.TypeOf()); } [Test] @@ -313,7 +313,7 @@ public void ShouldPinDecoratedRegistrationAtRegistrationTime() var result = sutFork.Resolve(); Assert.That(result, Is.TypeOf()); - Assert.That(((TestImplDecorator) result).Inner, Is.TypeOf()); + Assert.That(((TestImplDecorator)result).Inner, Is.TypeOf()); } [Test] @@ -328,7 +328,7 @@ public void ShouldUseSameLifetimeForDecorator_TransientCase() var result2 = scope.Resolve(); Assert.That(result1, Is.Not.SameAs(result2)); - Assert.That(((TestImplDecorator) result1).Inner, Is.Not.SameAs(((TestImplDecorator) result2).Inner)); + Assert.That(((TestImplDecorator)result1).Inner, Is.Not.SameAs(((TestImplDecorator)result2).Inner)); } [Test] @@ -343,7 +343,7 @@ public void ShouldUseSameLifetimeForDecorator_PerScopeCase() var result2 = scope.Resolve(); Assert.That(result1, Is.SameAs(result2)); - Assert.That(((TestImplDecorator) result1).Inner, Is.SameAs(((TestImplDecorator) result2).Inner)); + Assert.That(((TestImplDecorator)result1).Inner, Is.SameAs(((TestImplDecorator)result2).Inner)); } [Test] @@ -357,7 +357,7 @@ public void ShouldUseSameLifetimeForDecorator_SingletonCase() var result2 = sut.Resolve(); Assert.That(result1, Is.SameAs(result2)); - Assert.That(((TestImplDecorator) result1).Inner, Is.SameAs(((TestImplDecorator) result2).Inner)); + Assert.That(((TestImplDecorator)result1).Inner, Is.SameAs(((TestImplDecorator)result2).Inner)); } public interface ITestInterface diff --git a/tests/NSubstitute.Acceptance.Specs/PartialSubs.cs b/tests/NSubstitute.Acceptance.Specs/PartialSubs.cs index ff6aa42a0..92dba3a21 100644 --- a/tests/NSubstitute.Acceptance.Specs/PartialSubs.cs +++ b/tests/NSubstitute.Acceptance.Specs/PartialSubs.cs @@ -201,7 +201,7 @@ public void CallBaseForNonPartialProxyWhenExplicitlyEnabled() substitute.When(x => x.MethodReturnsSameInt(Arg.Any())).CallBase(); substitute.MethodReturnsSameInt(42); - + Assert.That(substitute.CalledTimes, Is.EqualTo(1)); } @@ -213,7 +213,7 @@ public void CallBaseWhenDisabledViaRouterButExplicitlyEnabled() substitute.When(x => x.MethodReturnsSameInt(Arg.Any())).CallBase(); substitute.MethodReturnsSameInt(42); - + Assert.That(substitute.CalledTimes, Is.EqualTo(1)); } @@ -242,7 +242,7 @@ public void CallBaseWhenExplicitlyDisabledAndThenEnabled() Assert.That(substitute.CalledTimes, Is.EqualTo(1)); } - + [Test] public void ShouldThrowExceptionIfTryToNotCallBaseForAbstractMethod() { @@ -262,7 +262,7 @@ public void ShouldThrowExceptionIfTryToNotCallBaseForInterfaceProxy() () => substitute.When(x => x.TestMethodReturnsInt()).DoNotCallBase()); Assert.That(ex.Message, Contains.Substring("base method implementation is missing")); } - + [Test] public void ShouldThrowExceptionIfTryToCallBaseForAbstractMethod() { diff --git a/tests/NSubstitute.Acceptance.Specs/ReceivedCalls.cs b/tests/NSubstitute.Acceptance.Specs/ReceivedCalls.cs index 54f2ab2b1..43e83f277 100644 --- a/tests/NSubstitute.Acceptance.Specs/ReceivedCalls.cs +++ b/tests/NSubstitute.Acceptance.Specs/ReceivedCalls.cs @@ -11,8 +11,8 @@ public class ReceivedCalls { private ICar _car; const int Rpm = 7000; - private static readonly object[] Luggage = new [] { new object(), new object() }; - private static readonly DateTime[] ServiceDates = new[] {new DateTime(2001, 01, 01), new DateTime(2002, 02, 02)}; + private static readonly object[] Luggage = new[] { new object(), new object() }; + private static readonly DateTime[] ServiceDates = new[] { new DateTime(2001, 01, 01), new DateTime(2002, 02, 02) }; [SetUp] public void SetUp() @@ -255,22 +255,28 @@ public void Check_when_call_was_received_with_value_type_params_array() [TestCase(4, true)] [TestCase(5, true)] [TestCase(6, false)] - public void Check_call_was_received_within_a_range_of_times(int numberOfCalls, bool shouldPass) { - for (var i = 0; i < numberOfCalls; i++) { + public void Check_call_was_received_within_a_range_of_times(int numberOfCalls, bool shouldPass) + { + for (var i = 0; i < numberOfCalls; i++) + { _car.Idle(); } - if (shouldPass) { + if (shouldPass) + { _car.Received(Quantity.Within(2, 5)).Idle(); - } else { - Assert.Throws(() => + } + else + { + Assert.Throws(() => _car.Received(Quantity.Within(2, 5)).Idle() ); } } [Test] - public void Throw_when_call_was_not_received_within_a_range_of_times() { + public void Throw_when_call_was_not_received_within_a_range_of_times() + { _car.Idle(); var ex = Assert.Throws(() => _car.Received(Quantity.Within(2, 5)).Idle() @@ -279,7 +285,8 @@ public void Throw_when_call_was_not_received_within_a_range_of_times() { } [Test] - public void Throw_when_call_was_received_too_many_times_within_a_range() { + public void Throw_when_call_was_received_too_many_times_within_a_range() + { _car.Idle(); _car.Idle(); var ex = Assert.Throws(() => @@ -289,7 +296,8 @@ public void Throw_when_call_was_received_too_many_times_within_a_range() { } [Test] - public void Throw_when_invalid_range_given() { + public void Throw_when_invalid_range_given() + { _car.Idle(); _car.Idle(); var ex = Assert.Throws(() => @@ -299,7 +307,8 @@ public void Throw_when_invalid_range_given() { } [Test] - public void Throw_when_negative_min_range_given() { + public void Throw_when_negative_min_range_given() + { _car.Idle(); _car.Idle(); var ex = Assert.Throws(() => diff --git a/tests/NSubstitute.Acceptance.Specs/RecursiveSubs.cs b/tests/NSubstitute.Acceptance.Specs/RecursiveSubs.cs index 5c896f8f6..e5a3a258c 100644 --- a/tests/NSubstitute.Acceptance.Specs/RecursiveSubs.cs +++ b/tests/NSubstitute.Acceptance.Specs/RecursiveSubs.cs @@ -18,7 +18,7 @@ public interface IRequest public interface IIdentity { string Name { get; set; } } [Test] - public void Set_a_return_value_on_a_substitute_of_a_substitute_of_a_substitute () + public void Set_a_return_value_on_a_substitute_of_a_substitute_of_a_substitute() { const string name = "My pet fish Eric"; diff --git a/tests/NSubstitute.Acceptance.Specs/ReturningResults.cs b/tests/NSubstitute.Acceptance.Specs/ReturningResults.cs index 9871d126d..3a363e6fe 100644 --- a/tests/NSubstitute.Acceptance.Specs/ReturningResults.cs +++ b/tests/NSubstitute.Acceptance.Specs/ReturningResults.cs @@ -198,7 +198,7 @@ public void Returns_Null_for_string_parameter() public void Returns_Null_for_method_returning_class() { _something.SomeAction().ReturnsNull(); - + Assert.That(_something.SomeAction(), Is.Null); } diff --git a/tests/NSubstitute.Acceptance.Specs/ReturnsAndDoes.cs b/tests/NSubstitute.Acceptance.Specs/ReturnsAndDoes.cs index 0dba983fc..27ba4baf0 100644 --- a/tests/NSubstitute.Acceptance.Specs/ReturnsAndDoes.cs +++ b/tests/NSubstitute.Acceptance.Specs/ReturnsAndDoes.cs @@ -5,7 +5,7 @@ namespace NSubstitute.Acceptance.Specs { public class ReturnsAndDoes { - public interface IFoo { IBar GetBar(int i); } + public interface IFoo { IBar GetBar(int i); } public interface IBar { } private IFoo sub; @@ -44,7 +44,7 @@ public void Add_multiple_callbacks_and_ignore_args() var result1 = sub.GetBar(42); var result2 = sub.GetBar(9999); Assert.That(wasCalled, Is.True); - Assert.That(argsUsed, Is.EquivalentTo(new[] {42, 9999})); + Assert.That(argsUsed, Is.EquivalentTo(new[] { 42, 9999 })); Assert.AreSame(result1, bar); Assert.AreSame(result2, bar); } diff --git a/tests/NSubstitute.Acceptance.Specs/ReturnsForAll.cs b/tests/NSubstitute.Acceptance.Specs/ReturnsForAll.cs index deb5e248b..1350993d9 100644 --- a/tests/NSubstitute.Acceptance.Specs/ReturnsForAll.cs +++ b/tests/NSubstitute.Acceptance.Specs/ReturnsForAll.cs @@ -29,7 +29,7 @@ public void Return_self_for_single_call() [Test] public void Return_self_for_chained_calls() { - Assert.That(_fluentSomething.Chain().Me().Together(), Is.SameAs(_fluentSomething)); + Assert.That(_fluentSomething.Chain().Me().Together(), Is.SameAs(_fluentSomething)); } [Test] diff --git a/tests/NSubstitute.Acceptance.Specs/ReturnsForAllFromFunc.cs b/tests/NSubstitute.Acceptance.Specs/ReturnsForAllFromFunc.cs index 0334ff448..f42e8a99a 100644 --- a/tests/NSubstitute.Acceptance.Specs/ReturnsForAllFromFunc.cs +++ b/tests/NSubstitute.Acceptance.Specs/ReturnsForAllFromFunc.cs @@ -29,7 +29,7 @@ public void Return_self_for_single_call() [Test] public void Return_self_for_chained_calls() { - Assert.That(_fluentSomething.Chain().Me().Together(), Is.SameAs(_fluentSomething)); + Assert.That(_fluentSomething.Chain().Me().Together(), Is.SameAs(_fluentSomething)); } [Test] diff --git a/tests/NSubstitute.Acceptance.Specs/SequenceChecking.cs b/tests/NSubstitute.Acceptance.Specs/SequenceChecking.cs index 3d26fe129..8fb9eb5b4 100644 --- a/tests/NSubstitute.Acceptance.Specs/SequenceChecking.cs +++ b/tests/NSubstitute.Acceptance.Specs/SequenceChecking.cs @@ -163,7 +163,7 @@ public void Ignore_unrelated_calls() _foo.Finish(); }); } - + [Test] public void Check_auto_subbed_props() { @@ -254,7 +254,7 @@ public void Event_subscription() _foo.OnFoo += Arg.Any(); }); } - + [Test] public void Pass_when_exception_in_first_sequenced_call_is_caught_and_second_call_is_exact() { @@ -269,12 +269,12 @@ public void Pass_when_exception_in_first_sequenced_call_is_caught_and_second_cal { //suppress error } - + _foo.Start(2); _bar.Begin(); _foo.Finish(); _bar.End(); - + Received.InOrder(() => { _foo.Start(2); diff --git a/tests/NSubstitute.Acceptance.Specs/SubbingForConcreteTypesAndMultipleInterfaces.cs b/tests/NSubstitute.Acceptance.Specs/SubbingForConcreteTypesAndMultipleInterfaces.cs index 42efa9875..e2a3809cb 100644 --- a/tests/NSubstitute.Acceptance.Specs/SubbingForConcreteTypesAndMultipleInterfaces.cs +++ b/tests/NSubstitute.Acceptance.Specs/SubbingForConcreteTypesAndMultipleInterfaces.cs @@ -55,8 +55,8 @@ public void Sub_with_constructor_arguments() var expectedString = "from ctor"; var expectedInt = 5; var sub = Substitute.For(expectedString, expectedInt); - Assert.That(sub.StringFromCtorArg, Is.EqualTo(expectedString)); - Assert.That(sub.IntFromCtorArg, Is.EqualTo(expectedInt)); + Assert.That(sub.StringFromCtorArg, Is.EqualTo(expectedString)); + Assert.That(sub.IntFromCtorArg, Is.EqualTo(expectedInt)); } [Test] diff --git a/tests/NSubstitute.Acceptance.Specs/SubstitutingForDelegates.cs b/tests/NSubstitute.Acceptance.Specs/SubstitutingForDelegates.cs index ab2650696..290be7547 100644 --- a/tests/NSubstitute.Acceptance.Specs/SubstitutingForDelegates.cs +++ b/tests/NSubstitute.Acceptance.Specs/SubstitutingForDelegates.cs @@ -13,7 +13,7 @@ public void SubForAction() action(); action.Received()(); } - + [Test] public void SubForActionWith2Parameters() { @@ -21,13 +21,13 @@ public void SubForActionWith2Parameters() action(4, 2); action.Received()(4, 2); } - + [Test] public void SubForFunc() { var func = Substitute.For>(); func(1).Returns("1"); - + Assert.That(func(1), Is.EqualTo("1")); func.Received()(1); } diff --git a/tests/NSubstitute.Acceptance.Specs/ThrowingExceptions.cs b/tests/NSubstitute.Acceptance.Specs/ThrowingExceptions.cs index fdc7eda2c..cfe19dc18 100644 --- a/tests/NSubstitute.Acceptance.Specs/ThrowingExceptions.cs +++ b/tests/NSubstitute.Acceptance.Specs/ThrowingExceptions.cs @@ -13,7 +13,7 @@ public class ThrowingExceptions [Test] public void ThrowException() { - _something.Count().Throws(new Exception()); + _something.Count().Throws(new Exception()); Assert.Catch(() => _something.Count()); } @@ -52,7 +52,7 @@ public void ThrowExceptionWithInnerException() _something.Count().Throws(new Exception("Exception message", innerException)); Exception exceptionThrown = Assert.Catch(() => _something.Count()); - + Assert.IsNotNull(exceptionThrown.InnerException); Assert.IsInstanceOf(exceptionThrown.InnerException); }