diff --git a/Build.fsx b/Build.fsx index 075902278..195c8729f 100644 --- a/Build.fsx +++ b/Build.fsx @@ -202,7 +202,17 @@ Target "EnableSourceLinkGeneration" (fun _ -> enableSourceLink <- true ) -Target "VerifyOnly" (fun _ -> rebuild "Verify") +Target "VerifyOnly" (fun _ -> + try + rebuild "Verify" + with + | BuildException (msg, errors) -> + let msg = sprintf + "%s\r\nHINT: To simplify the fix process it's recommended to switch to the 'Verify' configuration \ + in the IDE. This way you might get Roslyn quick fixes for the violated rules." + msg + raise (BuildException(msg, errors)) +) Target "BuildOnly" (fun _ -> rebuild configuration) Target "TestOnly" (fun _ -> @@ -449,4 +459,4 @@ if buildServer = BuildServer.AppVeyor ActivateFinalTarget "AppVeyor_UpdateVersion" // ========= ENTRY POINT ========= -RunTargetOrDefault "CompleteBuild" \ No newline at end of file +RunTargetOrDefault "CompleteBuild" diff --git a/Src/All.sln b/Src/All.sln index 15783ae7c..53b84ed4b 100644 --- a/Src/All.sln +++ b/Src/All.sln @@ -60,10 +60,13 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F0A01F00-72C7-4CE4-8BA4-9EB178B72329}" ProjectSection(SolutionItems) = preProject ..\.editorconfig = ..\.editorconfig + ..\Build.fsx = ..\Build.fsx + CodeAnalysis.AutoFixture.ruleset = CodeAnalysis.AutoFixture.ruleset + CodeAnalysis.Empty.ruleset = CodeAnalysis.Empty.ruleset + CodeAnalysis.Test.ruleset = CodeAnalysis.Test.ruleset Common.props = Common.props Common.Test.props = Common.Test.props Common.Test.xUnit.props = Common.Test.xUnit.props - ..\Build.fsx = ..\Build.fsx EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoFakeItEasy.FakeItEasy2UnitTest", "AutoFakeItEasy.FakeItEasy2UnitTest\AutoFakeItEasy.FakeItEasy2UnitTest.csproj", "{7F957CC0-79C3-48A1-9A3E-47BED7539248}" diff --git a/Src/All.sln.DotSettings b/Src/All.sln.DotSettings index b2265e1ee..2a198f7a0 100644 --- a/Src/All.sln.DotSettings +++ b/Src/All.sln.DotSettings @@ -1,8 +1,16 @@  + SUGGESTION True + 1 + 1 + 1 + False NEVER + False False True + True + True <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> True True diff --git a/Src/AutoFakeItEasy/AutoFakeItEasyCustomization.cs b/Src/AutoFakeItEasy/AutoFakeItEasyCustomization.cs index 93e15940d..c5c76d84d 100644 --- a/Src/AutoFakeItEasy/AutoFakeItEasyCustomization.cs +++ b/Src/AutoFakeItEasy/AutoFakeItEasyCustomization.cs @@ -10,7 +10,7 @@ namespace AutoFixture.AutoFakeItEasy /// Enables auto-mocking with FakeItEasy. /// /// - /// NOTICE! You can assign the customization properties to tweak the features you would like to enable. Example: + /// NOTICE! You can assign the customization properties to tweak the features you would like to enable. See example. ///
/// new AutoFakeItEasyCustomization { GenerateDelegates = true } ///
diff --git a/Src/AutoFakeItEasy/ConfigureFakeMembersCommand.cs b/Src/AutoFakeItEasy/ConfigureFakeMembersCommand.cs index f51053bfd..be4645439 100644 --- a/Src/AutoFakeItEasy/ConfigureFakeMembersCommand.cs +++ b/Src/AutoFakeItEasy/ConfigureFakeMembersCommand.cs @@ -7,26 +7,26 @@ namespace AutoFixture.AutoFakeItEasy { - /// - /// Sets up a Fake's members so that the return, out, and ref values of virtual members will - /// be retrieved from the fixture, instead of being created directly by FakeItEasy. - /// - /// This will setup virtual methods and properties. - /// - /// + /// + /// Sets up a Fake's members so that the return, out, and ref values of virtual members will + /// be retrieved from the fixture, instead of being created directly by FakeItEasy. + /// + /// This will setup virtual methods and properties. + /// + /// /// This will setup any virtual methods and properties. - /// This includes: - /// - interface's methods/properties; - /// - class's abstract/virtual/overridden/non-sealed methods/properties. - /// + /// This includes: + /// - interface's methods/properties; + /// - class's abstract/virtual/overridden/non-sealed methods/properties. + /// public class ConfigureFakeMembersCommand : ISpecimenCommand { - /// + /// /// Sets up a Fake's members so that the return, out, and ref values will be retrieved - /// from the fixture, instead of being created directly by FakeItEasy. - /// - /// The Fake to setup. - /// The context of the Fake. + /// from the fixture, instead of being created directly by FakeItEasy. + /// + /// The Fake to setup. + /// The context of the Fake. public void Execute(object specimen, ISpecimenContext context) { if (context == null) throw new ArgumentNullException(nameof(context)); diff --git a/Src/AutoFakeItEasy/FakeItEasyMethodQuery.cs b/Src/AutoFakeItEasy/FakeItEasyMethodQuery.cs index f26a6814c..79366381d 100644 --- a/Src/AutoFakeItEasy/FakeItEasyMethodQuery.cs +++ b/Src/AutoFakeItEasy/FakeItEasyMethodQuery.cs @@ -13,7 +13,7 @@ namespace AutoFixture.AutoFakeItEasy /// public class FakeItEasyMethodQuery : IMethodQuery { - private static readonly DelegateSpecification delegateSpecification = new DelegateSpecification(); + private static readonly DelegateSpecification DelegateSpecification = new DelegateSpecification(); /// /// Selects constructors for the supplied type. @@ -36,7 +36,7 @@ public IEnumerable SelectMethods(Type type) } var fakeType = type.GetFakedType(); - if (fakeType.GetTypeInfo().IsInterface || delegateSpecification.IsSatisfiedBy(fakeType)) + if (fakeType.GetTypeInfo().IsInterface || DelegateSpecification.IsSatisfiedBy(fakeType)) { return new[] { new ConstructorMethod(type.GetDefaultConstructor()) }; } @@ -53,7 +53,7 @@ private static class FakeMethod Type type, IEnumerable parameterInfos) { - var constructedType = + var constructedType = typeof(FakeMethod<>).MakeGenericType(type); return (IMethod)Activator.CreateInstance( constructedType, @@ -74,7 +74,7 @@ public FakeMethod(IEnumerable parameterInfos) public object Invoke(IEnumerable parameters) { - var genericFakeType = typeof (Fake<>).MakeGenericType(typeof (T)); + var genericFakeType = typeof(Fake<>).MakeGenericType(typeof(T)); foreach (var constructor in genericFakeType.GetConstructors()) { @@ -86,7 +86,7 @@ public object Invoke(IEnumerable parameters) var parameterType = constructorParameterInfos[0].ParameterType; if (!parameterType.GetTypeInfo().IsGenericType || - parameterType.GetGenericTypeDefinition() != typeof (Action<>)) + parameterType.GetGenericTypeDefinition() != typeof(Action<>)) { continue; } @@ -100,7 +100,7 @@ public object Invoke(IEnumerable parameters) var withArgumentsForConstructorMethod = fakeOptionsType.GetMethod( "WithArgumentsForConstructor", - new[] {typeof (object[])}); + new[] { typeof(object[]) }); if (withArgumentsForConstructorMethod == null) { @@ -108,9 +108,9 @@ public object Invoke(IEnumerable parameters) } Action addConstructorArgumentsToOptionsAction = - options => withArgumentsForConstructorMethod.Invoke(options, new object[] {parameters}); + options => withArgumentsForConstructorMethod.Invoke(options, new object[] { parameters }); - return constructor.Invoke(new object[] {addConstructorArgumentsToOptionsAction}); + return constructor.Invoke(new object[] { addConstructorArgumentsToOptionsAction }); } return null; diff --git a/Src/AutoFakeItEasy/FakeObjectCall.cs b/Src/AutoFakeItEasy/FakeObjectCall.cs index d603a235f..5466db4d3 100644 --- a/Src/AutoFakeItEasy/FakeObjectCall.cs +++ b/Src/AutoFakeItEasy/FakeObjectCall.cs @@ -8,7 +8,7 @@ namespace AutoFixture.AutoFakeItEasy using System.Globalization; /// - /// A bridge class, required because the types representing fake object calls in + /// A bridge class, required because the types representing fake object calls in /// 1.7.4109.1 (which the .NET Framework version of AutoFixture.AutoFakeItEasy is compiled against) /// differ from those in 2.0.0+ in ways that prevent us from using them directly. /// If ever support for FakeItEasy versions below 2.0.0 is dropped, this class may be removed. @@ -28,16 +28,15 @@ public FakeObjectCall(IFakeObjectCall wrappedCall) public MethodInfo Method => this.wrappedCall.Method; - public IEnumerable Arguments => (IEnumerable)InvokeWrappedPropertyGetter(ArgumentsPropertyName); + public IEnumerable Arguments => (IEnumerable)this.InvokeWrappedPropertyGetter(ArgumentsPropertyName); public void SetReturnValue(object value) { - InvokeWrappedMethod(SetReturnValueMethodName, value); + this.InvokeWrappedMethod(SetReturnValueMethodName, value); } public void SetArgumentValue(int index, object value) => - InvokeWrappedMethod(SetArgumentValueMethodName, index, value); - + this.InvokeWrappedMethod(SetArgumentValueMethodName, index, value); private object InvokeWrappedPropertyGetter(string propertyName) { @@ -49,7 +48,7 @@ private object InvokeWrappedPropertyGetter(string propertyName) "Property {0} cannot be found on {1}", propertyName, callType.FullName)); } - return propertyInfo.GetValue(wrappedCall); + return propertyInfo.GetValue(this.wrappedCall); } private void InvokeWrappedMethod(string methodName, params object[] parameters) @@ -62,7 +61,7 @@ private void InvokeWrappedMethod(string methodName, params object[] parameters) "Method {0} cannot be found on {1}", methodName, callType.FullName)); } - methodInfo.Invoke(wrappedCall, parameters); + methodInfo.Invoke(this.wrappedCall, parameters); } } } \ No newline at end of file diff --git a/Src/AutoFakeItEasy/GlobalSuppressions.cs b/Src/AutoFakeItEasy/GlobalSuppressions.cs index b67b17ace..2f687b4a0 100644 --- a/Src/AutoFakeItEasy/GlobalSuppressions.cs +++ b/Src/AutoFakeItEasy/GlobalSuppressions.cs @@ -1,13 +1,13 @@ -// This file is used by Code Analysis to maintain SuppressMessage +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. -// Project-level suppressions either have no target or are given +// Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. // -// To add a suppression to this file, right-click the message in the -// Error List, point to "Suppress Message(s)", and click +// To add a suppression to this file, right-click the message in the +// Error List, point to "Suppress Message(s)", and click // "In Project Suppression File". // You do not need to add suppressions to this file manually. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", - Scope = "namespace", Target = "AutoFixture.AutoFakeItEasy", +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", + Scope = "namespace", Target = "AutoFixture.AutoFakeItEasy", Justification = "This should be a separate assembly because it provides extensions to AutoFixture that are specific to the use of FakeItEasy.")] diff --git a/Src/AutoFakeItEasy/MethodCall.cs b/Src/AutoFakeItEasy/MethodCall.cs index 0c2548399..d127c2ab7 100644 --- a/Src/AutoFakeItEasy/MethodCall.cs +++ b/Src/AutoFakeItEasy/MethodCall.cs @@ -36,15 +36,15 @@ public override int GetHashCode() unchecked { var hashCode = -712421553; - hashCode = hashCode * -1521134295 + this.declaringType.GetHashCode(); - hashCode = hashCode * -1521134295 + this.methodName.GetHashCode(); + hashCode = (hashCode * -1521134295) + this.declaringType.GetHashCode(); + hashCode = (hashCode * -1521134295) + this.methodName.GetHashCode(); foreach (var argument in this.arguments) { - hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(argument); + hashCode = (hashCode * -1521134295) + EqualityComparer.Default.GetHashCode(argument); } foreach (var argumentType in this.parameterTypes) { - hashCode = hashCode * -1521134295 + argumentType.GetHashCode(); + hashCode = (hashCode * -1521134295) + argumentType.GetHashCode(); } return hashCode; } diff --git a/Src/AutoFakeItEasy/MethodCallResult.cs b/Src/AutoFakeItEasy/MethodCallResult.cs index 352c58179..49017f24f 100644 --- a/Src/AutoFakeItEasy/MethodCallResult.cs +++ b/Src/AutoFakeItEasy/MethodCallResult.cs @@ -15,7 +15,7 @@ public MethodCallResult(object returnValue) public void ApplyToCall(FakeObjectCall fakeObjectCall) { fakeObjectCall.SetReturnValue(this.returnValue); - if (outAndRefValues == null) return; + if (this.outAndRefValues == null) return; foreach (var positionedValue in this.outAndRefValues) { @@ -36,6 +36,7 @@ public void AddOutOrRefValue(int i, object value) private class PositionedValue { public int Position { get; } + public object Value { get; } public PositionedValue(int position, object value) diff --git a/Src/AutoFakeItEasy/MethodRule.cs b/Src/AutoFakeItEasy/MethodRule.cs index 3b441427e..bb77b7d01 100644 --- a/Src/AutoFakeItEasy/MethodRule.cs +++ b/Src/AutoFakeItEasy/MethodRule.cs @@ -6,7 +6,7 @@ namespace AutoFixture.AutoFakeItEasy { /// /// A rule that intercepts method calls. Supplies the return and all out and ref values - /// from the fixture. When a method is called repeatedly with the same arguments, the + /// from the fixture. When a method is called repeatedly with the same arguments, the /// same return value and out and ref values will be provided. /// internal class MethodRule : IFakeObjectCallRule @@ -45,7 +45,7 @@ public void Apply(IInterceptedFakeObjectCall interceptedFakeObjectCall) if (interceptedFakeObjectCall == null) throw new ArgumentNullException(nameof(interceptedFakeObjectCall)); var fakeObjectCall = new FakeObjectCall(interceptedFakeObjectCall); - var callResult = this.resultSource.GetOrAdd(CreateMethodCall(fakeObjectCall), () => CreateMethodCallResult(fakeObjectCall)); + var callResult = this.resultSource.GetOrAdd(CreateMethodCall(fakeObjectCall), () => this.CreateMethodCallResult(fakeObjectCall)); callResult.ApplyToCall(fakeObjectCall); } @@ -57,8 +57,8 @@ private static MethodCall CreateMethodCall(FakeObjectCall fakeCall) private MethodCallResult CreateMethodCallResult(FakeObjectCall fakeObjectCall) { - var result = new MethodCallResult(ResolveReturnValue(fakeObjectCall)); - AddOutAndRefValues(result, fakeObjectCall); + var result = new MethodCallResult(this.ResolveReturnValue(fakeObjectCall)); + this.AddOutAndRefValues(result, fakeObjectCall); return result; } diff --git a/Src/AutoFakeItEasy/Properties/AssemblyInfo.cs b/Src/AutoFakeItEasy/Properties/AssemblyInfo.cs index 426c07cc8..b4b2d2133 100644 --- a/Src/AutoFakeItEasy/Properties/AssemblyInfo.cs +++ b/Src/AutoFakeItEasy/Properties/AssemblyInfo.cs @@ -3,13 +3,13 @@ using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFakeItEasy/PropertySetterRule.cs b/Src/AutoFakeItEasy/PropertySetterRule.cs index 405ba70fb..81a477736 100644 --- a/Src/AutoFakeItEasy/PropertySetterRule.cs +++ b/Src/AutoFakeItEasy/PropertySetterRule.cs @@ -6,7 +6,7 @@ namespace AutoFixture.AutoFakeItEasy { /// - /// A rule that intercepts property setter calls. Values will be saved into a result cache to be + /// A rule that intercepts property setter calls. Values will be saved into a result cache to be /// provided as the return value from the matching get methods when the latter are called. /// internal class PropertySetterRule : IFakeObjectCallRule @@ -37,7 +37,7 @@ public bool IsApplicableTo(IFakeObjectCall fakeObjectCall) /// /// Stores the value provided in the property setter to be returned from later - /// calls to the corresponding getter. + /// calls to the corresponding getter. /// /// The call to apply the rule to. public void Apply(IInterceptedFakeObjectCall interceptedFakeObjectCall) diff --git a/Src/AutoFakeItEasy2/FakeItEasyMethodQuery.cs b/Src/AutoFakeItEasy2/FakeItEasyMethodQuery.cs index e88c7a0ca..b071b668a 100644 --- a/Src/AutoFakeItEasy2/FakeItEasyMethodQuery.cs +++ b/Src/AutoFakeItEasy2/FakeItEasyMethodQuery.cs @@ -52,7 +52,7 @@ private static class FakeMethod Type type, IEnumerable parameterInfos) { - var constructedType = + var constructedType = typeof(FakeMethod<>).MakeGenericType(type); return (IMethod)Activator.CreateInstance( constructedType, diff --git a/Src/AutoFakeItEasy2/FakeItEasyType.cs b/Src/AutoFakeItEasy2/FakeItEasyType.cs index 4a2e3fbb6..e48513561 100644 --- a/Src/AutoFakeItEasy2/FakeItEasyType.cs +++ b/Src/AutoFakeItEasy2/FakeItEasyType.cs @@ -10,10 +10,10 @@ internal static class FakeItEasyType { internal static bool IsFake(this Type type) { - return (type != null + return type != null && type.IsGenericType && typeof(Fake<>).IsAssignableFrom(type.GetGenericTypeDefinition()) - && !type.GetFakedType().IsGenericParameter); + && !type.GetFakedType().IsGenericParameter; } internal static ConstructorInfo GetDefaultConstructor(this Type type) diff --git a/Src/AutoFakeItEasy2/GlobalSuppressions.cs b/Src/AutoFakeItEasy2/GlobalSuppressions.cs index 283d3504a..6ce275346 100644 --- a/Src/AutoFakeItEasy2/GlobalSuppressions.cs +++ b/Src/AutoFakeItEasy2/GlobalSuppressions.cs @@ -1,10 +1,10 @@ -// This file is used by Code Analysis to maintain SuppressMessage +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. -// Project-level suppressions either have no target or are given +// Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. // -// To add a suppression to this file, right-click the message in the -// Error List, point to "Suppress Message(s)", and click +// To add a suppression to this file, right-click the message in the +// Error List, point to "Suppress Message(s)", and click // "In Project Suppression File". // You do not need to add suppressions to this file manually. diff --git a/Src/AutoFakeItEasy2/Properties/AssemblyInfo.cs b/Src/AutoFakeItEasy2/Properties/AssemblyInfo.cs index 426c07cc8..b4b2d2133 100644 --- a/Src/AutoFakeItEasy2/Properties/AssemblyInfo.cs +++ b/Src/AutoFakeItEasy2/Properties/AssemblyInfo.cs @@ -3,13 +3,13 @@ using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFakeItEasyUnitTest/FixtureIntegrationTest.cs b/Src/AutoFakeItEasyUnitTest/FixtureIntegrationTest.cs index 100a4629d..c007c02e7 100644 --- a/Src/AutoFakeItEasyUnitTest/FixtureIntegrationTest.cs +++ b/Src/AutoFakeItEasyUnitTest/FixtureIntegrationTest.cs @@ -364,7 +364,7 @@ public void WithConfigureMembers_MethodsWithRefParametersReturnSameValuesWhenCal var result = fixture.Create(); // Act int argument = 42; - var returnValue1 = result.Method(ref argument ); + var returnValue1 = result.Method(ref argument); argument = 42; var returnValue2 = result.Method(ref argument); // Assert @@ -523,7 +523,7 @@ public void WithConfigureMembers_MethodsWithRefParametersReturnValuesFromFixture // Act var result = fixture.Create(); // Assert - string refResult = ""; + string refResult = string.Empty; string returnValue = result.Method(ref refResult); Assert.Equal(frozenString, refResult); Assert.Equal(frozenString, returnValue); @@ -658,7 +658,7 @@ public void WithGenerateDelegatesAndConfigureMembers_ShouldReturnValueForRegular [Fact] public void WithGenerateDelegatesAndConfigureMembers_ShouldReturnSameValueWhenCalledWithSameArguments() - { + { // Arrange var fixture = new Fixture().Customize(new AutoFakeItEasyCustomization { diff --git a/Src/AutoFakeItEasyUnitTest/Properties/AssemblyInfo.cs b/Src/AutoFakeItEasyUnitTest/Properties/AssemblyInfo.cs index 2052e4837..dab2dad8e 100644 --- a/Src/AutoFakeItEasyUnitTest/Properties/AssemblyInfo.cs +++ b/Src/AutoFakeItEasyUnitTest/Properties/AssemblyInfo.cs @@ -1,13 +1,13 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFakeItEasyUnitTest/TestTypes/IInterfaceWithNewMethod.cs b/Src/AutoFakeItEasyUnitTest/TestTypes/IInterfaceWithNewMethod.cs index 645527290..38a33dd7d 100644 --- a/Src/AutoFakeItEasyUnitTest/TestTypes/IInterfaceWithNewMethod.cs +++ b/Src/AutoFakeItEasyUnitTest/TestTypes/IInterfaceWithNewMethod.cs @@ -1,14 +1,14 @@ namespace AutoFixture.AutoFakeItEasy.UnitTest.TestTypes { - public interface IInterfaceWithShadowedMethod - { - // Shadows method. - string Method(int i); - } - public interface IInterfaceWithNewMethod : IInterfaceWithShadowedMethod { // New method. new string Method(int i); } + + public interface IInterfaceWithShadowedMethod + { + // Shadows method. + string Method(int i); + } } diff --git a/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithExplicitlyImplementedProperty.cs b/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithExplicitlyImplementedProperty.cs index ed4500e0a..c56474f46 100644 --- a/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithExplicitlyImplementedProperty.cs +++ b/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithExplicitlyImplementedProperty.cs @@ -1,6 +1,6 @@ namespace AutoFixture.AutoFakeItEasy.UnitTest.TestTypes { - public class TypeWithExplicitlyImplementedProperty: IInterfaceWithProperty + public class TypeWithExplicitlyImplementedProperty : IInterfaceWithProperty { string IInterfaceWithProperty.Property { get; set; } } diff --git a/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithPrivateField.cs b/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithPrivateField.cs index 8c6bf9115..a4a38e314 100644 --- a/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithPrivateField.cs +++ b/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithPrivateField.cs @@ -2,7 +2,7 @@ { public class TypeWithPrivateField { - private string field = ""; + private string field = string.Empty; public string GetPrivateField() { diff --git a/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithReadonlyField.cs b/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithReadonlyField.cs index 1914ec092..37425bdac 100644 --- a/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithReadonlyField.cs +++ b/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithReadonlyField.cs @@ -2,6 +2,6 @@ { public class TypeWithReadonlyField { - public readonly string ReadonlyField = ""; + public readonly string ReadonlyField = string.Empty; } } diff --git a/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithSealedMembers.cs b/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithSealedMembers.cs index eac29a0ed..aa19daf1e 100644 --- a/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithSealedMembers.cs +++ b/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithSealedMembers.cs @@ -1,11 +1,5 @@ namespace AutoFixture.AutoFakeItEasy.UnitTest.TestTypes { - public abstract class TypeWithSealedMembersTemp - { - public abstract string ExplicitlySealedProperty { get; set; } - public abstract string ExplicitlySealedMethod(); - } - public class TypeWithSealedMembers : TypeWithSealedMembersTemp { public sealed override string ExplicitlySealedProperty { get; set; } @@ -21,4 +15,11 @@ public string ImplicitlySealedMethod() return "Awesome string"; } } + + public abstract class TypeWithSealedMembersTemp + { + public abstract string ExplicitlySealedProperty { get; set; } + + public abstract string ExplicitlySealedMethod(); + } } diff --git a/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithStaticField.cs b/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithStaticField.cs index 7e778df16..467346412 100644 --- a/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithStaticField.cs +++ b/Src/AutoFakeItEasyUnitTest/TestTypes/TypeWithStaticField.cs @@ -2,6 +2,6 @@ { public class TypeWithStaticField { - public static string StaticField = ""; + public static string StaticField = string.Empty; } } diff --git a/Src/AutoFixture.NUnit2.UnitTest/AutoDataAttributeTest.cs b/Src/AutoFixture.NUnit2.UnitTest/AutoDataAttributeTest.cs index 02636b72d..31b820c6b 100644 --- a/Src/AutoFixture.NUnit2.UnitTest/AutoDataAttributeTest.cs +++ b/Src/AutoFixture.NUnit2.UnitTest/AutoDataAttributeTest.cs @@ -33,16 +33,16 @@ public void InitializedWithDefaultConstructorHasCorrectFixture() // Assert Assert.IsAssignableFrom(result); } - + [Test] public void InitializedWithFixtureFactoryConstrucorHasCorrectFixture() { // Arrange var fixture = new Fixture(); - + // Act var sut = new DerivedAutoDataAttribute(() => fixture); - + // Assert #pragma warning disable 618 Assert.AreSame(fixture, sut.Fixture); @@ -59,14 +59,14 @@ public void InitializeWithNullFixtureThrows() new DerivedAutoDataAttribute((IFixture)null)); #pragma warning restore 612 } - + [Test] public void InitializeWithNullFixtureFactoryThrows() { // Arrange // Act & Assert Assert.Throws(() => - new DerivedAutoDataAttribute((Func) null)); + new DerivedAutoDataAttribute((Func)null)); } [Test] @@ -82,7 +82,7 @@ public void FixtureFactoryIsNotInvokedImmediately() // Act var sut = new DerivedAutoDataAttribute(fixtureFactory); - + // Assert Assert.False(wasInvoked); } @@ -235,7 +235,7 @@ public void GetDataOrdersCustomizationAttributes(string methodName) Assert.False(customizationLog[0] is FreezeOnMatchCustomization); Assert.True(customizationLog[1] is FreezeOnMatchCustomization); } - + private class TypeWithIParameterCustomizationSourceUsage { public void DecoratedMethod([CustomizationSource] int arg) @@ -249,8 +249,8 @@ public ICustomization GetCustomization(ParameterInfo parameter) return new Customization(); } } - - public class Customization: ICustomization + + public class Customization : ICustomization { public void Customize(IFixture fixture) { @@ -273,13 +273,13 @@ public void ShouldRecognizeAttributesImplementingIParameterCustomizationSource() return fixture; }; var sut = new DerivedAutoDataAttribute(() => fixture); - + // Act sut.GetData(method); // Assert Assert.True(customizationLog[0] is TypeWithIParameterCustomizationSourceUsage.Customization); } - + private class DerivedAutoDataAttribute : AutoDataAttribute { [Obsolete] diff --git a/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeInsufficientArgumentsTest.cs b/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeInsufficientArgumentsTest.cs index cafc0b778..925151115 100644 --- a/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeInsufficientArgumentsTest.cs +++ b/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeInsufficientArgumentsTest.cs @@ -13,7 +13,7 @@ namespace AutoFixture.NUnit2.UnitTest public class CompositeDataAttributeInsufficientArgumentsTest : IEnumerable { private readonly MethodInfo method; - + public CompositeDataAttributeInsufficientArgumentsTest() { this.method = typeof(TypeWithOverloadedMembers) @@ -26,27 +26,25 @@ public void GetArgumentsThrows(IEnumerable attributes) // Arrange // Act & Assert Assert.Throws( - () => { new CompositeDataAttribute(attributes).GetData(this.method).ToList(); } - ); + () => { new CompositeDataAttribute(attributes).GetData(this.method).ToList(); }); } public IEnumerator GetEnumerator() { +#pragma warning disable SA1025 // Code should not contain multiple whitespace in a row yield return CreateTestCase( data: new[] { new FakeDataAttribute(this.method, new[] { new object[] { 1, 2 } }), new FakeDataAttribute(this.method, new[] { new object[] { 3, 4 } }) - } - ); + }); yield return CreateTestCase( data: new[] { new FakeDataAttribute(this.method, new[] { new object[] { 1 } }), new FakeDataAttribute(this.method, new[] { new object[] { 2, 3 } }) - } - ); + }); yield return CreateTestCase( data: new[] @@ -54,8 +52,7 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, new[] { new object[] { 1 } }), new FakeDataAttribute(this.method, new[] { new object[] { } }), new FakeDataAttribute(this.method, new[] { new object[] { 2, 3 } }) - } - ); + }); yield return CreateTestCase( data: new[] @@ -63,16 +60,14 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, new[] { new object[] { 1 } }), new FakeDataAttribute(this.method, new[] { new object[] { 2 } }), new FakeDataAttribute(this.method, new[] { new object[] { 3 } }) - } - ); + }); yield return CreateTestCase( data: new[] { new FakeDataAttribute(this.method, new[] { new object[] { 1, 2 }, new object[] { 3, 4 }, new object[] { 5, 6 } }), new FakeDataAttribute(this.method, new[] { new object[] { 7, 8, 9 }, new object[] { 10, 11, 12 } }) - } - ); + }); yield return CreateTestCase( data: new[] @@ -80,8 +75,8 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, new[] { new object[] { 1, 2 }, new object[] { 3, 4 }, new object[] { 5, 6 } }), new FakeDataAttribute(this.method, new[] { new object[] { 7, 8, 9 }, new object[] { 10, 11, 12 } }), new FakeDataAttribute(this.method, new[] { new object[] { 13, 14, 15 } }) - } - ); + }); +#pragma warning restore SA1025 // Code should not contain multiple whitespace in a row } IEnumerator IEnumerable.GetEnumerator() diff --git a/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeSufficientArgumentsTest.cs b/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeSufficientArgumentsTest.cs index 3dfc78726..fdc3522fb 100644 --- a/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeSufficientArgumentsTest.cs +++ b/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeSufficientArgumentsTest.cs @@ -12,7 +12,7 @@ namespace AutoFixture.NUnit2.UnitTest public class CompositeDataAttributeSufficientArgumentsTest : IEnumerable { private readonly MethodInfo method; - + public CompositeDataAttributeSufficientArgumentsTest() { this.method = typeof(TypeWithOverloadedMembers) @@ -31,16 +31,16 @@ public void GetArgumentsReturnsCorrectResult(IEnumerable attribut public IEnumerator GetEnumerator() { +#pragma warning disable SA1025 // Code should not contain multiple whitespace in a row yield return CreateTestCase( data: new[] { new FakeDataAttribute(this.method, new[] { new object[] { 1, 2, 3 } }) }, - expected: new[] + expected: new[] { - new object[] { 1, 2, 3 } - } - ); + new object[] { 1, 2, 3 } + }); yield return CreateTestCase( data: new[] @@ -48,22 +48,20 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, new[] { new object[] { 1, 2, 3 } }), new FakeDataAttribute(this.method, new[] { new object[] { 4, 5, 6 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 3 } - } - ); + }); yield return CreateTestCase( data: new[] { new FakeDataAttribute(this.method, new[] { new object[] { 1, 2, 3, 4 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 3 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -71,11 +69,10 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, new[] { new object[] { 1 } }), new FakeDataAttribute(this.method, new[] { new object[] { 2, 3, 4 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 3, 4 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -83,22 +80,20 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, new[] { new object[] { 1, 2 } }), new FakeDataAttribute(this.method, new[] { new object[] { 3, 4, 5 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 5 } - } - ); + }); yield return CreateTestCase( data: new[] { new FakeDataAttribute(this.method, new[] { new object[] { 1, 2, 3 }, new object[] { 4, 5, 6 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 3 }, new object[] { 4, 5, 6 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -106,11 +101,10 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, new[] { new object[] { 1, 2, 3 }, new object[] { 4, 5, 6 } }), new FakeDataAttribute(this.method, new[] { new object[] { 7, 8 }, new object[] { 9, 10 }, new object[] { 11, 12 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 3 }, new object[] { 4, 5, 6 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -118,11 +112,11 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, new[] { new object[] { 1, 2 }, new object[] { 3, 4 }, new object[] { 5, 6 } }), new FakeDataAttribute(this.method, new[] { new object[] { 7, 8, 9 }, new object[] { 10, 11, 12 }, new object[] { 13, 14, 15 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 9 }, new object[] { 3, 4, 12 }, new object[] { 5, 6, 15 } - } - ); + }); +#pragma warning restore SA1025 // Code should not contain multiple whitespace in a row } IEnumerator IEnumerable.GetEnumerator() diff --git a/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeTest.cs b/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeTest.cs index 516d1f42d..52af967f4 100644 --- a/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeTest.cs +++ b/Src/AutoFixture.NUnit2.UnitTest/CompositeDataAttributeTest.cs @@ -32,9 +32,9 @@ public void InitializeWithNullArrayThrows() public void AttributesIsCorrectWhenInitializedWithArray() { // Arrange - Action a = delegate { }; + Action a = () => { }; var method = a.Method; - + var attributes = new[] { new FakeDataAttribute(method, Enumerable.Empty()), @@ -62,9 +62,9 @@ public void InitializeWithNullEnumerableThrows() public void AttributesIsCorrectWhenInitializedWithEnumerable() { // Arrange - Action a = delegate { }; + Action a = () => { }; var method = a.Method; - + var attributes = new[] { new FakeDataAttribute(method, Enumerable.Empty()), @@ -93,14 +93,13 @@ public void GetArgumentsWithNullMethodThrows() public void GetArgumentsOnMethodWithNoParametersReturnsNoTheory() { // Arrange - Action a = delegate { }; + Action a = () => { }; var method = a.Method; - + var sut = new CompositeDataAttribute( new FakeDataAttribute(method, Enumerable.Empty()), new FakeDataAttribute(method, Enumerable.Empty()), - new FakeDataAttribute(method, Enumerable.Empty()) - ); + new FakeDataAttribute(method, Enumerable.Empty())); // Act & Assert var result = sut.GetData(a.Method); diff --git a/Src/AutoFixture.NUnit2.UnitTest/CustomizeAttributeTest.cs b/Src/AutoFixture.NUnit2.UnitTest/CustomizeAttributeTest.cs index 7634abd3f..b74b200ce 100644 --- a/Src/AutoFixture.NUnit2.UnitTest/CustomizeAttributeTest.cs +++ b/Src/AutoFixture.NUnit2.UnitTest/CustomizeAttributeTest.cs @@ -25,7 +25,7 @@ public void SutIsAttribute() // Assert Assert.IsInstanceOf(sut); } - + [Test] public void SutImplementsIParameterCustomizationSource() { diff --git a/Src/AutoFixture.NUnit2.UnitTest/FakeDataAttribute.cs b/Src/AutoFixture.NUnit2.UnitTest/FakeDataAttribute.cs index de8cde25e..e58f0f010 100644 --- a/Src/AutoFixture.NUnit2.UnitTest/FakeDataAttribute.cs +++ b/Src/AutoFixture.NUnit2.UnitTest/FakeDataAttribute.cs @@ -19,7 +19,7 @@ public FakeDataAttribute(MethodInfo expectedMethod, IEnumerable output public override IEnumerable GetData(MethodInfo method) { Assert.AreEqual(this.expectedMethod, method); - + return this.output; } } diff --git a/Src/AutoFixture.NUnit2.UnitTest/FavorListsAttributeTest.cs b/Src/AutoFixture.NUnit2.UnitTest/FavorListsAttributeTest.cs index 64420e778..1a2e91d0f 100644 --- a/Src/AutoFixture.NUnit2.UnitTest/FavorListsAttributeTest.cs +++ b/Src/AutoFixture.NUnit2.UnitTest/FavorListsAttributeTest.cs @@ -39,7 +39,7 @@ public void GetCustomizationReturnsCorrectResult() var result = sut.GetCustomization(parameter); // Assert Assert.IsAssignableFrom(result); - var invoker = (ConstructorCustomization) result; + var invoker = (ConstructorCustomization)result; Assert.AreEqual(parameter.ParameterType, invoker.TargetType); Assert.IsAssignableFrom(invoker.Query); } diff --git a/Src/AutoFixture.NUnit2.UnitTest/LocalAddin.cs b/Src/AutoFixture.NUnit2.UnitTest/LocalAddin.cs index 79e2b920a..b0fdbf3f7 100644 --- a/Src/AutoFixture.NUnit2.UnitTest/LocalAddin.cs +++ b/Src/AutoFixture.NUnit2.UnitTest/LocalAddin.cs @@ -5,6 +5,6 @@ namespace AutoFixture.NUnit2.UnitTest { [NUnitAddin] public class LocalAddin : Addin - { + { } } \ No newline at end of file diff --git a/Src/AutoFixture.NUnit2.UnitTest/Properties/AssemblyInfo.cs b/Src/AutoFixture.NUnit2.UnitTest/Properties/AssemblyInfo.cs index f5f646250..bd0da9cc8 100644 --- a/Src/AutoFixture.NUnit2.UnitTest/Properties/AssemblyInfo.cs +++ b/Src/AutoFixture.NUnit2.UnitTest/Properties/AssemblyInfo.cs @@ -1,13 +1,13 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixture.NUnit2.UnitTest/Scenario.cs b/Src/AutoFixture.NUnit2.UnitTest/Scenario.cs index d2f99e411..44e493817 100644 --- a/Src/AutoFixture.NUnit2.UnitTest/Scenario.cs +++ b/Src/AutoFixture.NUnit2.UnitTest/Scenario.cs @@ -91,9 +91,7 @@ public class Obsoleted { [Test, AutoData] public void FreezeFirstParameterAsBaseTypeAssignsSameInstanceToSecondParameterOfThatBaseType( -#pragma warning disable 0618 [Frozen(As = typeof(AbstractType))]ConcreteType p1, -#pragma warning restore 0618 AbstractType p2) { Assert.AreSame(p1, p2); @@ -101,17 +99,13 @@ public class Obsoleted [Test, AutoData] public void FreezeFirstParameterAsNullTypeAssignsSameInstanceToSecondParameterOfSameType( -#pragma warning disable 0618 [Frozen(As = null)]ConcreteType p1, -#pragma warning restore 0618 ConcreteType p2) { Assert.AreSame(p1, p2); } -#pragma warning disable 618 [Test, AutoData(typeof(CustomizedFixture))] -#pragma warning restore 618 public void AutoTestCaseProvidesCustomizedObject(PropertyHolder ph) { Assert.AreEqual("Ploeh", ph.Property); diff --git a/Src/AutoFixture.NUnit2/Addins/Addin.cs b/Src/AutoFixture.NUnit2/Addins/Addin.cs index be3db2e0d..db4ba45c8 100644 --- a/Src/AutoFixture.NUnit2/Addins/Addin.cs +++ b/Src/AutoFixture.NUnit2/Addins/Addin.cs @@ -18,14 +18,14 @@ public class Addin : IAddin /// extension points are supported by the host that is /// passed to it and taking the appropriate action. /// - /// The host in which to install the add-in - /// True if the add-in was installed, otehrwise false + /// The host in which to install the add-in. + /// True if the add-in was installed, otehrwise false. public bool Install(IExtensionHost host) { - if(host == null) throw new ArgumentNullException(nameof(host)); - + if (host == null) throw new ArgumentNullException(nameof(host)); + var providers = host.GetExtensionPoint("TestCaseProviders"); - if (providers == null) + if (providers == null) return false; providers.Install(new Builders.AutoDataProvider()); diff --git a/Src/AutoFixture.NUnit2/Addins/Builders/AutoDataProvider.cs b/Src/AutoFixture.NUnit2/Addins/Builders/AutoDataProvider.cs index b6dfe104c..a44031afe 100644 --- a/Src/AutoFixture.NUnit2/Addins/Builders/AutoDataProvider.cs +++ b/Src/AutoFixture.NUnit2/Addins/Builders/AutoDataProvider.cs @@ -14,7 +14,7 @@ public class AutoDataProvider : ITestCaseProvider2 /// /// Determine whether any test cases are available for a parameterized method. /// - /// A MethodInfo representing a parameterized test + /// A MethodInfo representing a parameterized test. /// True if any cases are available, otherwise false. public bool HasTestCasesFor(MethodInfo method) { @@ -35,8 +35,8 @@ public IEnumerable GetTestCasesFor(MethodInfo method) /// /// Determine whether any test cases are available for a parameterized method. /// - /// A MethodInfo representing a parameterized test - /// A Suite representing a NUnit TestSuite + /// A MethodInfo representing a parameterized test. + /// A Suite representing a NUnit TestSuite. /// True if any cases are available, otherwise false. public bool HasTestCasesFor(MethodInfo method, Test suite) { diff --git a/Src/AutoFixture.NUnit2/Addins/Constants.cs b/Src/AutoFixture.NUnit2/Addins/Constants.cs index 8fa0020ab..8993fef3a 100644 --- a/Src/AutoFixture.NUnit2/Addins/Constants.cs +++ b/Src/AutoFixture.NUnit2/Addins/Constants.cs @@ -1,7 +1,7 @@ namespace AutoFixture.NUnit2.Addins { /// - /// Class to contains all static string constants + /// Class to contains all static string constants. /// public static class Constants { diff --git a/Src/AutoFixture.NUnit2/Addins/DataAttribute.cs b/Src/AutoFixture.NUnit2/Addins/DataAttribute.cs index 327018a35..42bc585c4 100644 --- a/Src/AutoFixture.NUnit2/Addins/DataAttribute.cs +++ b/Src/AutoFixture.NUnit2/Addins/DataAttribute.cs @@ -8,9 +8,9 @@ namespace AutoFixture.NUnit2.Addins /// Abstract attribute which represents a testcase provider for a testcase. /// TestCase providers derive from this attribute and implement GetArguments /// to return the arguments for the testcase. - /// + /// /// - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)] + [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public abstract class DataAttribute : Attribute { /// diff --git a/Src/AutoFixture.NUnit2/AutoDataAttribute.cs b/Src/AutoFixture.NUnit2/AutoDataAttribute.cs index f02a6ce07..a47b4c6f3 100644 --- a/Src/AutoFixture.NUnit2/AutoDataAttribute.cs +++ b/Src/AutoFixture.NUnit2/AutoDataAttribute.cs @@ -72,7 +72,7 @@ protected AutoDataAttribute(IFixture fixture) protected AutoDataAttribute(Func fixtureFactory) { if (fixtureFactory == null) throw new ArgumentNullException(nameof(fixtureFactory)); - + this.fixtureLazy = new Lazy(fixtureFactory, LazyThreadSafetyMode.PublicationOnly); } @@ -97,7 +97,7 @@ public Type FixtureType /// /// Returns the data to be used to test the testcase. /// - /// The method that is being tested + /// The method that is being tested. /// The testcase data generated by . public override IEnumerable GetData(MethodInfo method) { diff --git a/Src/AutoFixture.NUnit2/CompositeDataAttribute.cs b/Src/AutoFixture.NUnit2/CompositeDataAttribute.cs index 3eceffff5..223e4a057 100644 --- a/Src/AutoFixture.NUnit2/CompositeDataAttribute.cs +++ b/Src/AutoFixture.NUnit2/CompositeDataAttribute.cs @@ -12,7 +12,7 @@ namespace AutoFixture.NUnit2 /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)] [CLSCompliant(false)] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "This attribute is the root of a potential attribute hierarchy.")] public class CompositeDataAttribute : DataAttribute { @@ -43,7 +43,7 @@ public CompositeDataAttribute(params DataAttribute[] attributes) /// /// Returns the composition of arguments to be used to test the testcase. Favors the arguments returned - /// by TestCaseDataAttributes in ascending order. + /// by TestCaseDataAttributes in ascending order. /// /// The method that is being tested. /// @@ -127,11 +127,10 @@ public override IEnumerable GetData(MethodInfo method) string.Format( CultureInfo.CurrentCulture, "Expected {0} parameters, got {1} parameters", - numberOfParameters, foundData[iteration].Count - ) - ); + numberOfParameters, foundData[iteration].Count)); } - } while (++iteration < numberOfIterations); + } + while (++iteration < numberOfIterations); } } } diff --git a/Src/AutoFixture.NUnit2/FrozenAttribute.cs b/Src/AutoFixture.NUnit2/FrozenAttribute.cs index ce0f99bca..5d3514f70 100644 --- a/Src/AutoFixture.NUnit2/FrozenAttribute.cs +++ b/Src/AutoFixture.NUnit2/FrozenAttribute.cs @@ -14,7 +14,7 @@ namespace AutoFixture.NUnit2 public sealed class FrozenAttribute : CustomizeAttribute { [Obsolete("The As property is deprecated.")] - private Type _as; + private Type @as; /// /// Initializes a new instance of the class. @@ -48,8 +48,8 @@ public FrozenAttribute(Matching by) [Obsolete("The ability to map a frozen object to a specific type is deprecated and will likely be removed in the future. If you wish to map a frozen type to its implemented interfaces, use [Frozen(Matching.ImplementedInterfaces)]. If you instead wish to map it to its direct base type, use [Frozen(Matching.DirectBaseType)].", true)] public Type As { - get => this._as; - set => this._as = value; + get => this.@as; + set => this.@as = value; } /// @@ -83,7 +83,7 @@ public override ICustomization GetCustomization(ParameterInfo parameter) private bool ShouldMatchBySpecificType() { #pragma warning disable 618 - return this._as != null; + return this.@as != null; #pragma warning restore 618 } @@ -92,7 +92,7 @@ private ICustomization FreezeAsType(Type type) return new FreezingCustomization( type, #pragma warning disable 618 - this._as ?? type); + this.@as ?? type); #pragma warning restore 618 } diff --git a/Src/AutoFixture.NUnit2/GlobalSuppressions.cs b/Src/AutoFixture.NUnit2/GlobalSuppressions.cs index a221e9ece..8e19a1440 100644 --- a/Src/AutoFixture.NUnit2/GlobalSuppressions.cs +++ b/Src/AutoFixture.NUnit2/GlobalSuppressions.cs @@ -1,25 +1,25 @@ -// This file is used by Code Analysis to maintain SuppressMessage +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. -// Project-level suppressions either have no target or are given +// Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. // -// To add a suppression to this file, right-click the message in the -// Code Analysis results, point to "Suppress Message", and click +// To add a suppression to this file, right-click the message in the +// Code Analysis results, point to "Suppress Message", and click // "In Suppression File". // You do not need to add suppressions to this file manually. using System.Diagnostics.CodeAnalysis; -[assembly: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "NUnit", Scope = "namespace", Target = "AutoFixture.NUnit2")] -[assembly: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "NUnit")] +[assembly: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "NUnit", Scope = "namespace", Target = "AutoFixture.NUnit2", Justification ="NUnit is the proper name")] +[assembly: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "NUnit", Justification = "NUnit is the proper name")] [assembly: - SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", + SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "AutoFixture.NUnit2.Addins", Justification = "It has been ported from other project and I don't want to introduce the breaking changes.")] [assembly: - SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", + SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "AutoFixture.NUnit2.Addins.Builders", Justification = "It has been ported from other project and I don't want to introduce the breaking changes.")] \ No newline at end of file diff --git a/Src/AutoFixture.NUnit2/NoAutoPropertiesAttribute.cs b/Src/AutoFixture.NUnit2/NoAutoPropertiesAttribute.cs index 655faeb63..b278a293a 100644 --- a/Src/AutoFixture.NUnit2/NoAutoPropertiesAttribute.cs +++ b/Src/AutoFixture.NUnit2/NoAutoPropertiesAttribute.cs @@ -23,7 +23,7 @@ public sealed class NoAutoPropertiesAttribute : CustomizeAttribute /// public override ICustomization GetCustomization(ParameterInfo parameter) { - if (parameter == null) throw new ArgumentNullException(nameof(parameter)); + if (parameter == null) throw new ArgumentNullException(nameof(parameter)); var targetType = parameter.ParameterType; return new NoAutoPropertiesCustomization(targetType); diff --git a/Src/AutoFixture.NUnit2/Properties/AssemblyInfo.cs b/Src/AutoFixture.NUnit2/Properties/AssemblyInfo.cs index 41a3c5815..fcdd63b02 100644 --- a/Src/AutoFixture.NUnit2/Properties/AssemblyInfo.cs +++ b/Src/AutoFixture.NUnit2/Properties/AssemblyInfo.cs @@ -1,16 +1,15 @@ using System; -using System.Diagnostics.CodeAnalysis; using System.Reflection; -using System.Runtime.InteropServices; using System.Resources; +using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixture.NUnit3.UnitTest/AutoDataAttributeStub.cs b/Src/AutoFixture.NUnit3.UnitTest/AutoDataAttributeStub.cs index dd132dd96..79648e8bd 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/AutoDataAttributeStub.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/AutoDataAttributeStub.cs @@ -3,7 +3,7 @@ namespace AutoFixture.NUnit3.UnitTest { /// - /// A stub of for the benefit of unit testing + /// A stub of for the benefit of unit testing. /// public class AutoDataAttributeStub : AutoDataAttribute { diff --git a/Src/AutoFixture.NUnit3.UnitTest/AutoDataAttributeTest.cs b/Src/AutoFixture.NUnit3.UnitTest/AutoDataAttributeTest.cs index b1b205a4d..7e06fdcd7 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/AutoDataAttributeTest.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/AutoDataAttributeTest.cs @@ -24,16 +24,16 @@ public void IfExtendedWithNullFixtureThenThrows() Assert.Throws(() => new AutoDataAttributeStub((IFixture)null)); #pragma warning restore 612 } - + [Test] public void InitializeWithNullFixtureFactoryThrows() { // Arrange // Act & assert Assert.Throws(() => - new AutoDataAttributeStub((Func) null)); + new AutoDataAttributeStub((Func)null)); } - + [Test] public void FixtureFactoryIsNotInvokedImmediately() { @@ -47,11 +47,11 @@ public void FixtureFactoryIsNotInvokedImmediately() // Assert var sut = new AutoDataAttributeStub(fixtureFactory); - + // Assert Assert.False(wasInvoked); } - + [Test] public void ImplementsITestBuilder() { @@ -81,17 +81,17 @@ public void BuildFromDontActivateFixtureIfArgsValuesAreNotUsedByTestBuilder() { // Arrange bool wasActivated = false; - + var sut = new AutoDataAttributeStub(() => { wasActivated = true; return null; }); sut.TestMethodBuilder = new TestMethodBuilderWithoutParametersUsage(); - + var methodWrapper = new MethodWrapper(this.GetType(), nameof(this.DummyTestMethod)); var testSuite = new TestSuite(this.GetType()); - + // Act var dummy = sut.BuildFrom(methodWrapper, testSuite).ToArray(); @@ -100,7 +100,7 @@ public void BuildFromDontActivateFixtureIfArgsValuesAreNotUsedByTestBuilder() } /// - /// This is used in BuildFromYieldsParameterValues for building a unit test method + /// This is used in BuildFromYieldsParameterValues for building a unit test method. /// public void DummyTestMethod(int anyInt, double anyDouble) { @@ -168,8 +168,8 @@ public void GetDataOrdersCustomizationAttributes(string methodName) Assert.False(customizationLog[0] is FreezeOnMatchCustomization); Assert.True(customizationLog[1] is FreezeOnMatchCustomization); } - - private class TestMethodBuilderWithoutParametersUsage: ITestMethodBuilder + + private class TestMethodBuilderWithoutParametersUsage : ITestMethodBuilder { public TestMethod Build( IMethodInfo method, Test suite, IEnumerable parameterValues, int autoDataStartIndex) diff --git a/Src/AutoFixture.NUnit3.UnitTest/FavorListsAttributeTest.cs b/Src/AutoFixture.NUnit3.UnitTest/FavorListsAttributeTest.cs index b244929a5..e54941e64 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/FavorListsAttributeTest.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/FavorListsAttributeTest.cs @@ -40,7 +40,7 @@ public void GetCustomizationReturnsCorrectResult() var result = sut.GetCustomization(parameter); // Assert Assert.IsAssignableFrom(result); - var invoker = (ConstructorCustomization) result; + var invoker = (ConstructorCustomization)result; Assert.AreEqual(parameter.ParameterType, invoker.TargetType); Assert.IsAssignableFrom(invoker.Query); } diff --git a/Src/AutoFixture.NUnit3.UnitTest/FixedNameTestMethodBuilderTest.cs b/Src/AutoFixture.NUnit3.UnitTest/FixedNameTestMethodBuilderTest.cs index 04678f9d9..c5f5a3e92 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/FixedNameTestMethodBuilderTest.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/FixedNameTestMethodBuilderTest.cs @@ -13,7 +13,7 @@ public void FixedNameTestMethodBuilderIsResilientToParameterEnumeratingException // Arrange var dummyMethod = new MethodWrapper(typeof(TestNameStrategiesFixture), nameof(TestNameStrategiesFixture.FixedNameDecoratedMethod)); var sut = new FixedNameTestMethodBuilder(); - var throwingParameters = Enumerable.Range(0,1).Select(_ => throw new Exception()); + var throwingParameters = Enumerable.Range(0, 1).Select(_ => throw new Exception()); // Act var testMethod = sut.Build(dummyMethod, null, throwingParameters, 0); // Assert diff --git a/Src/AutoFixture.NUnit3.UnitTest/InlineAutoDataAttributeStub.cs b/Src/AutoFixture.NUnit3.UnitTest/InlineAutoDataAttributeStub.cs index 0adc40f07..02d4dba4b 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/InlineAutoDataAttributeStub.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/InlineAutoDataAttributeStub.cs @@ -3,7 +3,7 @@ namespace AutoFixture.NUnit3.UnitTest { /// - /// A stub of for the benefit of unit testing + /// A stub of for the benefit of unit testing. /// public class InlineAutoDataAttributeStub : InlineAutoDataAttribute { diff --git a/Src/AutoFixture.NUnit3.UnitTest/InlineAutoDataAttributeTest.cs b/Src/AutoFixture.NUnit3.UnitTest/InlineAutoDataAttributeTest.cs index b910f2430..6d1880974 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/InlineAutoDataAttributeTest.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/InlineAutoDataAttributeTest.cs @@ -24,16 +24,16 @@ public void IfExtendedWithNullFixtureThenThrows() Assert.Throws(() => new InlineAutoDataAttributeStub((IFixture)null)); #pragma warning restore 612 } - + [Test] public void InitializeWithNullFixtureFactoryThrows() { // Arrange // Act & Assert Assert.Throws(() => - new AutoDataAttributeStub((Func) null)); + new AutoDataAttributeStub((Func)null)); } - + [Test] public void FixtureFactoryIsNotInvokedImmediately() { @@ -47,11 +47,10 @@ public void FixtureFactoryIsNotInvokedImmediately() // Act var sut = new AutoDataAttributeStub(fixtureFactory); - + // Assert Assert.False(wasInvoked); } - [Test] public void IfCreateParametersThrowsExceptionThenReturnsNotRunnableTestMethodWithExceptionInfoAsSkipReason() @@ -74,23 +73,23 @@ public void IfCreateParametersThrowsExceptionThenReturnsNotRunnableTestMethodWit Assert.That(testMethod.Properties.Get(PropertyNames.SkipReason), Is.EqualTo(ExceptionHelper.BuildMessage(new ThrowingStubFixture.DummyException()))); } - + [Test] public void BuildFromDontActivateFixtureIfArgsValuesAreNotUsedByTestBuilder() { // Arrange bool wasActivated = false; - + var sut = new AutoDataAttributeStub(() => { wasActivated = true; return null; }); sut.TestMethodBuilder = new TestMethodBuilderWithoutParametersUsage(); - + var methodWrapper = new MethodWrapper(this.GetType(), nameof(this.DummyTestMethod)); var testSuite = new TestSuite(this.GetType()); - + // Assert var dummy = sut.BuildFrom(methodWrapper, testSuite).ToArray(); @@ -109,7 +108,7 @@ public void InitializedWithArgumentsHasCorrectArguments() // Assert Assert.AreSame(expectedArguments, result); } - + [TestCase("CreateWithFrozenAndFavorArrays")] [TestCase("CreateWithFavorArraysAndFrozen")] [TestCase("CreateWithFrozenAndFavorEnumerables")] @@ -142,13 +141,13 @@ public void GetDataOrdersCustomizationAttributes(string methodName) } /// - /// This is used in BuildFromYieldsParameterValues for building a unit test method + /// This is used in BuildFromYieldsParameterValues for building a unit test method. /// public void DummyTestMethod(int anyInt, double anyDouble) { } - - private class TestMethodBuilderWithoutParametersUsage: ITestMethodBuilder + + private class TestMethodBuilderWithoutParametersUsage : ITestMethodBuilder { public TestMethod Build( IMethodInfo method, Test suite, IEnumerable parameterValues, int autoDataStartIndex) @@ -194,7 +193,7 @@ public void ShouldRecognizeAttributesImplementingIParameterCustomizationSource() customizationLog.Add(c); return fixture; }; - var sut = new InlineAutoDataAttributeStub(() => fixture, new[] {42}); + var sut = new InlineAutoDataAttributeStub(() => fixture, new[] { 42 }); // Act sut.BuildFrom(method, new TestSuite(this.GetType())).ToArray(); diff --git a/Src/AutoFixture.NUnit3.UnitTest/Properties/AssemblyInfo.cs b/Src/AutoFixture.NUnit3.UnitTest/Properties/AssemblyInfo.cs index bfd336872..ba6ee8d91 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/Properties/AssemblyInfo.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/Properties/AssemblyInfo.cs @@ -1,13 +1,13 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixture.NUnit3.UnitTest/Scenario.cs b/Src/AutoFixture.NUnit3.UnitTest/Scenario.cs index 776405faa..d8912e313 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/Scenario.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/Scenario.cs @@ -77,7 +77,7 @@ public void GreedyCreatesParameterWithGreedyConstructor([Greedy]MultiUnorderedCo Assert.False(string.IsNullOrEmpty(p.Text)); Assert.AreNotEqual(0, p.Number); } - + [Test, AutoData] public void BothFrozenAndGreedyAttributesCanBeAppliedToSameParameter([Frozen][Greedy]MultiUnorderedConstructorType p1, MultiUnorderedConstructorType p2) { @@ -85,7 +85,7 @@ public void BothFrozenAndGreedyAttributesCanBeAppliedToSameParameter([Frozen][Gr Assert.AreNotEqual(0, p2.Number); } - //Note that Order of [Greedy] and [Frozen] is reversed than in BothFrozenAndGreedyAttributesCanBeAppliedToSameParameter + // Note that Order of [Greedy] and [Frozen] is reversed than in BothFrozenAndGreedyAttributesCanBeAppliedToSameParameter [Test, AutoData] public void BothFrozenAndGreedyAttributesCanBeAppliedToSameParameterRegardlessOfOrder([Greedy][Frozen]MultiUnorderedConstructorType p1, MultiUnorderedConstructorType p2) { @@ -380,8 +380,7 @@ public void InlineAutoDataCanBeUsedWithFrozen(int p1, int p2, [Frozen]string p3, public void NoAutoPropertiesAttributeLeavesPropertiesUnset( [NoAutoProperties]PropertyHolder ph1, [NoAutoProperties]PropertyHolder ph2, - [NoAutoProperties]PropertyHolder ph3 - ) + [NoAutoProperties]PropertyHolder ph3) { Assert.That(ph1.Property, Is.EqualTo(default(object))); Assert.That(ph2.Property, Is.EqualTo(default(string))); diff --git a/Src/AutoFixture.NUnit3.UnitTest/TestNameStrategiesFixture.cs b/Src/AutoFixture.NUnit3.UnitTest/TestNameStrategiesFixture.cs index 483b074e1..a8cca26bd 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/TestNameStrategiesFixture.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/TestNameStrategiesFixture.cs @@ -21,7 +21,8 @@ public AutoDataFixedNameAttribute() public class AutoDataVolatileNameAttribute : AutoDataAttribute { - public AutoDataVolatileNameAttribute() : base(CreateFixtureWithInjectedValues) + public AutoDataVolatileNameAttribute() + : base(CreateFixtureWithInjectedValues) { this.TestMethodBuilder = new VolatileNameTestMethodBuilder(); } @@ -29,7 +30,7 @@ public AutoDataVolatileNameAttribute() : base(CreateFixtureWithInjectedValues) public class InlineAutoDataFixedNameAttribute : InlineAutoDataAttribute { - public InlineAutoDataFixedNameAttribute(params object[] arguments) + public InlineAutoDataFixedNameAttribute(params object[] arguments) : base(arguments) { this.TestMethodBuilder = new FixedNameTestMethodBuilder(); @@ -38,7 +39,7 @@ public InlineAutoDataFixedNameAttribute(params object[] arguments) public class InlineAutoDataVolatileNameAttribute : InlineAutoDataAttribute { - public InlineAutoDataVolatileNameAttribute(params object[] arguments) + public InlineAutoDataVolatileNameAttribute(params object[] arguments) : base(CreateFixtureWithInjectedValues, arguments) { this.TestMethodBuilder = new VolatileNameTestMethodBuilder(); diff --git a/Src/AutoFixture.NUnit3.UnitTest/TestNameStrategiesTest.cs b/Src/AutoFixture.NUnit3.UnitTest/TestNameStrategiesTest.cs index 2a2542257..9d841fea9 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/TestNameStrategiesTest.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/TestNameStrategiesTest.cs @@ -118,7 +118,8 @@ public void InlineAutoDataVolatileNameUsesRealValuesForFullName() Is.EqualTo(@"AutoFixture.NUnit3.UnitTest.TestNameStrategiesFixture.InlineVolatileNameDecoratedMethod(""alpha"",""beta"",""foo"")")); } - private static TestMethod GetTestMethod(string testName) where TAttribute : Attribute, NUnit.Framework.Interfaces.ITestBuilder + private static TestMethod GetTestMethod(string testName) + where TAttribute : Attribute, NUnit.Framework.Interfaces.ITestBuilder { var method = new MethodWrapper(typeof(TestNameStrategiesFixture), testName); var inlineAttribute = (TAttribute)method.MethodInfo.GetCustomAttribute(typeof(TAttribute)); diff --git a/Src/AutoFixture.NUnit3.UnitTest/ThrowingStubFixture.cs b/Src/AutoFixture.NUnit3.UnitTest/ThrowingStubFixture.cs index 9dca248c6..8f53c7ce0 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/ThrowingStubFixture.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/ThrowingStubFixture.cs @@ -6,8 +6,8 @@ namespace AutoFixture.NUnit3.UnitTest { /// - /// A for the benefit of creating stubs of - /// and for unit testing + /// A for the benefit of creating stubs of + /// and for unit testing. /// public class ThrowingStubFixture : IFixture { @@ -66,7 +66,7 @@ public void Customize(Func, ISpecimenBuilder> compo } /// - /// This throws a unique for testing purpose + /// This throws a unique for testing purpose. /// /// /// @@ -77,7 +77,7 @@ public object Create(object request, ISpecimenContext context) } /// - /// A unique exception for the benefit of unit testing + /// A unique exception for the benefit of unit testing. /// public class DummyException : Exception { diff --git a/Src/AutoFixture.NUnit3.UnitTest/VolatileNameTestMethodBuilderTest.cs b/Src/AutoFixture.NUnit3.UnitTest/VolatileNameTestMethodBuilderTest.cs index 2598fa25d..0f1ee0bcd 100644 --- a/Src/AutoFixture.NUnit3.UnitTest/VolatileNameTestMethodBuilderTest.cs +++ b/Src/AutoFixture.NUnit3.UnitTest/VolatileNameTestMethodBuilderTest.cs @@ -13,8 +13,8 @@ public void VolatileNameTestMethodBuilderIsResilientToParameterEnumerationExcept // Arrange var anyMethod = new MethodWrapper(typeof(TestNameStrategiesFixture), nameof(TestNameStrategiesFixture.VolatileNameDecoratedMethod)); var sut = new VolatileNameTestMethodBuilder(); - var throwingParameters = Enumerable.Range(0,1).Select(_ => throw new Exception()); - + var throwingParameters = Enumerable.Range(0, 1).Select(_ => throw new Exception()); + // Act var testMethod = sut.Build(anyMethod, null, throwingParameters, 0); // Assert diff --git a/Src/AutoFixture.NUnit3/AutoDataAttribute.cs b/Src/AutoFixture.NUnit3/AutoDataAttribute.cs index 5ac2fa74d..4786c5488 100644 --- a/Src/AutoFixture.NUnit3/AutoDataAttribute.cs +++ b/Src/AutoFixture.NUnit3/AutoDataAttribute.cs @@ -10,17 +10,20 @@ namespace AutoFixture.NUnit3 { /// - /// This attribute uses AutoFixture to generate values for unit test parameters. - /// This implementation is based on TestCaseAttribute of NUnit3 + /// This attribute uses AutoFixture to generate values for unit test parameters. + /// This implementation is based on TestCaseAttribute of NUnit3. /// - [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", + [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "This attribute is the root of a potential attribute hierarchy.")] [AttributeUsage(AttributeTargets.Method)] public class AutoDataAttribute : Attribute, ITestBuilder { private readonly Lazy fixtureLazy; + private IFixture Fixture => this.fixtureLazy.Value; + private ITestMethodBuilder testMethodBuilder = new FixedNameTestMethodBuilder(); + /// /// Gets or sets the current strategy. /// @@ -31,7 +34,7 @@ public ITestMethodBuilder TestMethodBuilder } /// - /// Construct a + /// Construct a . /// public AutoDataAttribute() : this(() => new Fixture()) @@ -39,21 +42,20 @@ public AutoDataAttribute() } /// - /// Construct a with an + /// Construct a with an . /// - /// [Obsolete("This constructor overload is deprecated because it offers poor performance, and will be removed in a future version. " + "Please use the AutoDataAttribute(Func fixtureFactory) overload, so fixture will be constructed only if needed.")] protected AutoDataAttribute(IFixture fixture) { - if (null == fixture) + if (fixture == null) { throw new ArgumentNullException(nameof(fixture)); } this.fixtureLazy = new Lazy(() => fixture, LazyThreadSafetyMode.None); } - + /// /// Initializes a new instance of the class /// with the supplied . Fixture will be created @@ -73,7 +75,7 @@ protected AutoDataAttribute(Func fixtureFactory) /// /// The MethodInfo for which tests are to be constructed. /// The suite to which the tests will be added. - /// One or more TestMethods + /// One or more TestMethods. public IEnumerable BuildFrom(IMethodInfo method, Test suite) { var test = this.TestMethodBuilder.Build(method, suite, this.GetParameterValues(method), 0); diff --git a/Src/AutoFixture.NUnit3/FixedNameTestMethodBuilder.cs b/Src/AutoFixture.NUnit3/FixedNameTestMethodBuilder.cs index fefef26f2..095782e30 100644 --- a/Src/AutoFixture.NUnit3/FixedNameTestMethodBuilder.cs +++ b/Src/AutoFixture.NUnit3/FixedNameTestMethodBuilder.cs @@ -71,7 +71,7 @@ private static void EnsureOriginalArgumentsArrayIsNotShared(TestCaseParameters p { var clonedArguments = new object[parameters.OriginalArguments.Length]; Array.Copy(parameters.OriginalArguments, clonedArguments, parameters.OriginalArguments.Length); - + // Unfortunately the property has a private setter, so can be updated via reflection only. // Should use the type where the property is declared as otherwise the private setter is not available. var property = typeof(TestParameters).GetTypeInfo().GetProperty(nameof(TestCaseParameters.OriginalArguments)); diff --git a/Src/AutoFixture.NUnit3/InlineAutoDataAttribute.cs b/Src/AutoFixture.NUnit3/InlineAutoDataAttribute.cs index 6e9ec85f6..2f4ddb2fd 100644 --- a/Src/AutoFixture.NUnit3/InlineAutoDataAttribute.cs +++ b/Src/AutoFixture.NUnit3/InlineAutoDataAttribute.cs @@ -10,8 +10,8 @@ namespace AutoFixture.NUnit3 { /// - /// This attribute acts as a TestCaseAttribute but allow incomplete parameter values, - /// which will be provided by AutoFixture. + /// This attribute acts as a TestCaseAttribute but allow incomplete parameter values, + /// which will be provided by AutoFixture. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] [CLSCompliant(false)] @@ -20,9 +20,11 @@ public class InlineAutoDataAttribute : Attribute, ITestBuilder { private readonly object[] existingParameterValues; private readonly Lazy fixtureLazy; + private IFixture Fixture => this.fixtureLazy.Value; + private ITestMethodBuilder testMethodBuilder = new FixedNameTestMethodBuilder(); - + /// /// Gets or sets the current strategy. /// @@ -33,8 +35,7 @@ public ITestMethodBuilder TestMethodBuilder } /// - /// Construct a - /// with parameter values for test method + /// Construct a with parameter values for test method. /// public InlineAutoDataAttribute(params object[] arguments) : this(() => new Fixture(), arguments) @@ -42,20 +43,19 @@ public InlineAutoDataAttribute(params object[] arguments) } /// - /// Construct a with an - /// and parameter values for test method + /// Construct a with an + /// and parameter values for test method. /// [Obsolete("This constructor overload is deprecated because it offers poor performance, and will be removed in a future version. " + "Please use the overload with a factory method, so fixture will be constructed only if needed.")] protected InlineAutoDataAttribute(IFixture fixture, params object[] arguments) { - if (null == fixture) throw new ArgumentNullException(nameof(fixture)); - if (null == arguments) throw new ArgumentNullException(nameof(arguments)); + if (fixture == null) throw new ArgumentNullException(nameof(fixture)); this.fixtureLazy = new Lazy(() => fixture, LazyThreadSafetyMode.None); - this.existingParameterValues = arguments; + this.existingParameterValues = arguments ?? throw new ArgumentNullException(nameof(arguments)); } - + /// /// Initializes a new instance of the class /// with the supplied . Fixture will be created @@ -63,11 +63,10 @@ protected InlineAutoDataAttribute(IFixture fixture, params object[] arguments) /// protected InlineAutoDataAttribute(Func fixtureFactory, params object[] arguments) { - if (null == fixtureFactory) throw new ArgumentNullException(nameof(fixtureFactory)); - if (null == arguments) throw new ArgumentNullException(nameof(arguments)); + if (fixtureFactory == null) throw new ArgumentNullException(nameof(fixtureFactory)); this.fixtureLazy = new Lazy(fixtureFactory, LazyThreadSafetyMode.PublicationOnly); - this.existingParameterValues = arguments; + this.existingParameterValues = arguments ?? throw new ArgumentNullException(nameof(arguments)); } /// @@ -81,7 +80,7 @@ protected InlineAutoDataAttribute(Func fixtureFactory, params object[] /// /// The MethodInfo for which tests are to be constructed. /// The suite to which the tests will be added. - /// One or more TestMethods + /// One or more TestMethods. public IEnumerable BuildFrom(IMethodInfo method, Test suite) { var test = this.TestMethodBuilder.Build( @@ -91,7 +90,7 @@ public IEnumerable BuildFrom(IMethodInfo method, Test suite) } /// - /// Get values for a collection of + /// Get values for a collection of. /// private IEnumerable GetParameterValues(IMethodInfo method) { @@ -107,7 +106,7 @@ private IEnumerable GetMissingValues(IEnumerable paramet } /// - /// Get value for an + /// Get value for an. /// private object GetValueForParameter(IParameterInfo parameterInfo) { diff --git a/Src/AutoFixture.NUnit3/Properties/AssemblyInfo.cs b/Src/AutoFixture.NUnit3/Properties/AssemblyInfo.cs index 1b36b4b97..62fbcc567 100644 --- a/Src/AutoFixture.NUnit3/Properties/AssemblyInfo.cs +++ b/Src/AutoFixture.NUnit3/Properties/AssemblyInfo.cs @@ -3,13 +3,13 @@ using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixture.NUnit3/VolatileNameTestMethodBuilder.cs b/Src/AutoFixture.NUnit3/VolatileNameTestMethodBuilder.cs index 0a1dc93a1..5d1f016cc 100644 --- a/Src/AutoFixture.NUnit3/VolatileNameTestMethodBuilder.cs +++ b/Src/AutoFixture.NUnit3/VolatileNameTestMethodBuilder.cs @@ -31,7 +31,7 @@ public TestMethod Build(IMethodInfo method, Test suite, IEnumerable para return new NUnitTestCaseBuilder().BuildTestMethod(method, suite, GetParametersForMethod(parameterValues)); } - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "This method is always expected to return an instance of the TestCaseParameters class.")] private static TestCaseParameters GetParametersForMethod(IEnumerable parameterValues) { diff --git a/Src/AutoFixture.SeedExtensions.UnitTest/CreateSeedExtensionsTest.cs b/Src/AutoFixture.SeedExtensions.UnitTest/CreateSeedExtensionsTest.cs index f8492b466..b1ed88c2c 100644 --- a/Src/AutoFixture.SeedExtensions.UnitTest/CreateSeedExtensionsTest.cs +++ b/Src/AutoFixture.SeedExtensions.UnitTest/CreateSeedExtensionsTest.cs @@ -48,14 +48,13 @@ public void CreateSeededManyOnSpecimenBuilderComposerReturnsCorrectResult() return expectedResult.Cast(); }; - //var composer = new DelegatingComposer { OnCreate = specimenBuilder.OnCreate }; + // var composer = new DelegatingComposer { OnCreate = specimenBuilder.OnCreate }; // Act var result = specimenBuilder.CreateMany(seed); // Assert Assert.True(expectedResult.SequenceEqual(result)); } - [Fact] public void CreateSeededManyOnSpecimenBuilderReturnsCorrectResult() { @@ -81,7 +80,6 @@ public void CreateSeededManyOnSpecimenBuilderReturnsCorrectResult() "Sequences not equal."); } - [Fact] public void CreateManyOnNullSpecimenContextWithSeedThrows() { @@ -110,7 +108,6 @@ public void CreateSeededManyOnContainerReturnsCorrectResult() Assert.True(expectedResult.SequenceEqual(result)); } - [Fact] public void CreateManyOnNullSpecimenBuilderWithSeedAndCountThrows() { @@ -125,7 +122,6 @@ public void CreateManyOnNullSpecimenBuilderWithSeedAndCountThrows() dummyCount)); } - [Fact] public void CreateSeededAndCountedManyOnSpecimenBuilderComposerReturnsCorrectResult() { @@ -147,7 +143,6 @@ public void CreateSeededAndCountedManyOnSpecimenBuilderComposerReturnsCorrectRes Assert.True(expectedResult.SequenceEqual(result)); } - [Fact] public void CreateSeededAndCountedManyOnSpecimenBuilderReturnsCorrectResult() { @@ -174,7 +169,6 @@ public void CreateSeededAndCountedManyOnSpecimenBuilderReturnsCorrectResult() "Sequences not equal."); } - [Fact] public void CreateManyOnNullSpecimenContextWithSeedAndCountThrows() { @@ -186,7 +180,6 @@ public void CreateManyOnNullSpecimenContextWithSeedAndCountThrows() CreateSeedExtensions.CreateMany((ISpecimenContext)null, dummySeed, dummyCount)); } - [Fact] public void CreateSeededAndCountedManyOnContainerReturnsCorrectResult() { @@ -206,7 +199,6 @@ public void CreateSeededAndCountedManyOnContainerReturnsCorrectResult() Assert.True(expectedResult.SequenceEqual(result)); } - [Fact] public void CreateFromNullSpecimenBuilderWithSeedThrows() { @@ -217,7 +209,6 @@ public void CreateFromNullSpecimenBuilderWithSeedThrows() CreateSeedExtensions.Create((ISpecimenBuilder)null, dummySeed)); } - [Fact] public void CreateaSeededAnonymousOnSpecimenBuilderComposerReturnsCorrectResult() { @@ -238,7 +229,6 @@ public void CreateaSeededAnonymousOnSpecimenBuilderComposerReturnsCorrectResult( Assert.Equal(expectedResult, result); } - [Fact] public void CreateWithSeedOnSpecimenBuilderReturnsCorrectResult() { diff --git a/Src/AutoFixture.SeedExtensions.UnitTest/Scenario.cs b/Src/AutoFixture.SeedExtensions.UnitTest/Scenario.cs index ab69f258b..31ebe1e2f 100644 --- a/Src/AutoFixture.SeedExtensions.UnitTest/Scenario.cs +++ b/Src/AutoFixture.SeedExtensions.UnitTest/Scenario.cs @@ -32,7 +32,6 @@ public void CreateAnonymousWithSeedReturnsCorrectResult() Assert.Contains("Seed", result); } - [Fact] [Obsolete] public void CreateAnonymousFromNullSpecimenContextWithSeedThrows() @@ -125,7 +124,6 @@ where s.StartsWith(anonymousPrefix) Assert.Equal(expectedItemCount, actualCount); } - [Fact] public void CreateManyWithSeedAndCountReturnsCorrectResult() { @@ -167,7 +165,6 @@ public void CreateAnonymousStringWillAppendGuid() Assert.NotEqual(Guid.Empty, g); } - [Fact] public void CustomizeWithEchoInt32GeneratorWillReturnSeed() { @@ -196,7 +193,6 @@ public void BuildFromSeedWillCreateUsingCorrectSeed() Assert.True(verified, "Mock verified"); } - [Fact] public void CreateWithSeedReturnsCorrectResult() { diff --git a/Src/AutoFixture.SeedExtensions/CreateSeedExtensions.cs b/Src/AutoFixture.SeedExtensions/CreateSeedExtensions.cs index eae314ff2..a8a5e248a 100644 --- a/Src/AutoFixture.SeedExtensions/CreateSeedExtensions.cs +++ b/Src/AutoFixture.SeedExtensions/CreateSeedExtensions.cs @@ -11,7 +11,6 @@ namespace AutoFixture /// public static class CreateSeedExtensions { - /// /// Creates an anonymous object, potentially using the supplied seed as additional /// information when creating the object. @@ -22,14 +21,13 @@ public static class CreateSeedExtensions /// /// The context used to resolve the type request. /// An anonymous object. - /// Obsolete: Please move over to using Create{T}() as this method will be removed in the next release + /// Obsolete: Please move over to using Create{T}() as this method will be removed in the next release. [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] public static T CreateAnonymous(this ISpecimenContext context, T seed) { return Create(context, seed); } - /// Creates many anonymous objects. /// The type of objects to create. /// @@ -67,7 +65,6 @@ private static ISpecimenContext CreateContext(this ISpecimenBuilder builder) return new SpecimenContext(builder); } - /// /// Creates many anonymous objects. /// @@ -102,7 +99,6 @@ public static IEnumerable CreateMany(this ISpecimenContext context, T seed return ((IEnumerable)rawResult).Cast(); } - /// Creates many anonymous objects. /// The type of objects to create. /// @@ -170,7 +166,6 @@ public static IEnumerable CreateMany(this ISpecimenContext context, T seed return ((IEnumerable)rawResult).Cast(); } - /// /// Creates an anonymous object, potentially using the supplied seed as /// additional information when creating the object. diff --git a/Src/AutoFixture.SeedExtensions/FreezeSeedExtensions.cs b/Src/AutoFixture.SeedExtensions/FreezeSeedExtensions.cs index 44ca01012..7fee18d17 100644 --- a/Src/AutoFixture.SeedExtensions/FreezeSeedExtensions.cs +++ b/Src/AutoFixture.SeedExtensions/FreezeSeedExtensions.cs @@ -41,7 +41,7 @@ public static class FreezeSeedExtensions [EditorBrowsable(EditorBrowsableState.Never)] public static T Freeze(this IFixture fixture, T seed) { - if (fixture == null)throw new ArgumentNullException(nameof(fixture)); + if (fixture == null) throw new ArgumentNullException(nameof(fixture)); var value = fixture.Create(seed); fixture.Inject(value); diff --git a/Src/AutoFixture.SeedExtensions/Properties/AssemblyInfo.cs b/Src/AutoFixture.SeedExtensions/Properties/AssemblyInfo.cs index 7f16dcb27..e5ee2436c 100644 --- a/Src/AutoFixture.SeedExtensions/Properties/AssemblyInfo.cs +++ b/Src/AutoFixture.SeedExtensions/Properties/AssemblyInfo.cs @@ -1,12 +1,12 @@ using System; using System.Reflection; -using System.Runtime.InteropServices; using System.Resources; +using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixture.ruleset b/Src/AutoFixture.ruleset deleted file mode 100644 index de68a9c75..000000000 --- a/Src/AutoFixture.ruleset +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Src/AutoFixture.xUnit.UnitTest/AutoDataAttributeTest.cs b/Src/AutoFixture.xUnit.UnitTest/AutoDataAttributeTest.cs index baeaf3114..0957bf671 100644 --- a/Src/AutoFixture.xUnit.UnitTest/AutoDataAttributeTest.cs +++ b/Src/AutoFixture.xUnit.UnitTest/AutoDataAttributeTest.cs @@ -38,10 +38,10 @@ public void InitializedWithFixtureFactoryConstrucorHasCorrectFixture() { // Arrange var fixture = new Fixture(); - + // Act var sut = new DerivedAutoDataAttribute(() => fixture); - + // Assert #pragma warning disable 618 Assert.Same(fixture, sut.Fixture); @@ -65,7 +65,7 @@ public void InitializeWithNullFixtureFactoryThrows() // Arrange // Act & assert Assert.Throws(() => - new DerivedAutoDataAttribute((Func) null)); + new DerivedAutoDataAttribute((Func)null)); } [Fact] @@ -81,7 +81,7 @@ public void FixtureFactoryIsNotInvokedImmediately() // Act var sut = new DerivedAutoDataAttribute(fixtureFactory); - + // Assert Assert.False(wasInvoked); } @@ -243,7 +243,6 @@ public void GetDataOrdersCustomizationAttributes(string methodName) Assert.False(customizationLog[0] is FreezeOnMatchCustomization); Assert.True(customizationLog[1] is FreezeOnMatchCustomization); } - private class TypeWithIParameterCustomizationSourceUsage { @@ -276,7 +275,7 @@ public void ShouldRecognizeAttributesImplementingIParameterCustomizationSource() var parameters = method.GetParameters(); var parameterTypes = parameters.Select(p => p.ParameterType).ToArray(); - + var customizationLog = new List(); var fixture = new DelegatingFixture(); fixture.OnCustomize = c => @@ -285,13 +284,13 @@ public void ShouldRecognizeAttributesImplementingIParameterCustomizationSource() return fixture; }; var sut = new DerivedAutoDataAttribute(() => fixture); - + // Act sut.GetData(method, parameterTypes); // Assert Assert.True(customizationLog[0] is TypeWithIParameterCustomizationSourceUsage.Customization); } - + private class DerivedAutoDataAttribute : AutoDataAttribute { [Obsolete] diff --git a/Src/AutoFixture.xUnit.UnitTest/CompositeDataAttributeSufficientDataTest.cs b/Src/AutoFixture.xUnit.UnitTest/CompositeDataAttributeSufficientDataTest.cs index 80c745365..70dae19e4 100644 --- a/Src/AutoFixture.xUnit.UnitTest/CompositeDataAttributeSufficientDataTest.cs +++ b/Src/AutoFixture.xUnit.UnitTest/CompositeDataAttributeSufficientDataTest.cs @@ -36,16 +36,16 @@ public void GetDataReturnsCorrectResult(IEnumerable attributes, I public IEnumerator GetEnumerator() { +#pragma warning disable SA1025 // Code should not contain multiple whitespace in a row yield return CreateTestCase( data: new[] { new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 1, 2, 3 } }) }, - expected: new[] + expected: new[] { - new object[] { 1, 2, 3 } - } - ); + new object[] { 1, 2, 3 } + }); yield return CreateTestCase( data: new[] @@ -53,11 +53,10 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 1, 2, 3 } }), new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 4, 5, 6 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 3 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -65,11 +64,10 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 1 } }), new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 2, 3, 4 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 3, 4 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -77,22 +75,20 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 1, 2 } }), new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 3, 4, 5 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 5 } - } - ); + }); yield return CreateTestCase( data: new[] { new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 1, 2, 3 }, new object[] { 4, 5, 6 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 3 }, new object[] { 4, 5, 6 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -100,11 +96,10 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 1, 2, 3 }, new object[] { 4, 5, 6 } }), new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 7, 8 }, new object[] { 9, 10 }, new object[] { 11, 12 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 3 }, new object[] { 4, 5, 6 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -112,11 +107,10 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 1, 2 }, new object[] { 3, 4 }, new object[] { 5, 6 } }), new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 7, 8, 9 }, new object[] { 10, 11, 12 }, new object[] { 13, 14, 15 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 9 }, new object[] { 3, 4, 12 }, new object[] { 5, 6, 15 } - } - ); + }); // Second attribute restricts yield return CreateTestCase( @@ -125,11 +119,10 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 1, 2, 3 }, new object[] { 4, 5, 6 } }), new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 7, 8, 9 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 3 } - } - ); + }); // Shortest data provider is limiting factor yield return CreateTestCase( @@ -138,11 +131,10 @@ public IEnumerator GetEnumerator() new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 1, 2, 3 } }), new FakeDataAttribute(this.method, this.parameterTypes, new[] { new object[] { 4, 5, 6 }, new object[] { 7, 8, 9 } }) }, - expected: new[] + expected: new[] { new object[] { 1, 2, 3 } - } - ); + }); // Test incorrect number of parameters - should just return what it's given // and let xUnit deal with counting parameters @@ -155,8 +147,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -167,8 +158,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 3 }, - } - ); + }); yield return CreateTestCase( data: new[] @@ -180,8 +170,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 3 }, - } - ); + }); yield return CreateTestCase( data: new[] @@ -193,8 +182,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -204,8 +192,8 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2, 3, 4 } - } - ); + }); +#pragma warning restore SA1025 // Code should not contain multiple whitespace in a row } IEnumerator IEnumerable.GetEnumerator() diff --git a/Src/AutoFixture.xUnit.UnitTest/CompositeDataAttributeTest.cs b/Src/AutoFixture.xUnit.UnitTest/CompositeDataAttributeTest.cs index cf978d475..365f6bf5c 100644 --- a/Src/AutoFixture.xUnit.UnitTest/CompositeDataAttributeTest.cs +++ b/Src/AutoFixture.xUnit.UnitTest/CompositeDataAttributeTest.cs @@ -31,7 +31,7 @@ public void InitializeWithNullArrayThrows() public void AttributesIsCorrectWhenInitializedWithArray() { // Arrange - Action a = delegate { }; + Action a = () => { }; var method = a.Method; var parameters = method.GetParameters(); var parameterTypes = (from pi in parameters @@ -64,7 +64,7 @@ public void InitializeWithNullEnumerableThrows() public void AttributesIsCorrectWhenInitializedWithEnumerable() { // Arrange - Action a = delegate { }; + Action a = () => { }; var method = a.Method; var parameters = method.GetParameters(); var parameterTypes = (from pi in parameters @@ -100,7 +100,7 @@ public void GetDataWithNullTypesThrows() { // Arrange var sut = new CompositeDataAttribute(); - Action a = delegate { }; + Action a = () => { }; // Act & assert Assert.Throws(() => sut.GetData(a.Method, null).ToList()); @@ -110,7 +110,7 @@ public void GetDataWithNullTypesThrows() public void GetDataOnMethodWithNoParametersReturnsNoTheory() { // Arrange - Action a = delegate { }; + Action a = () => { }; var method = a.Method; var parameters = method.GetParameters(); var parameterTypes = (from pi in parameters @@ -119,8 +119,7 @@ public void GetDataOnMethodWithNoParametersReturnsNoTheory() var sut = new CompositeDataAttribute( new FakeDataAttribute(method, parameterTypes, Enumerable.Empty()), new FakeDataAttribute(method, parameterTypes, Enumerable.Empty()), - new FakeDataAttribute(method, parameterTypes, Enumerable.Empty()) - ); + new FakeDataAttribute(method, parameterTypes, Enumerable.Empty())); // Act & assert var result = sut.GetData(a.Method, Type.EmptyTypes); diff --git a/Src/AutoFixture.xUnit.UnitTest/FakeDataAttribute.cs b/Src/AutoFixture.xUnit.UnitTest/FakeDataAttribute.cs index 16622c871..2dc7ba675 100644 --- a/Src/AutoFixture.xUnit.UnitTest/FakeDataAttribute.cs +++ b/Src/AutoFixture.xUnit.UnitTest/FakeDataAttribute.cs @@ -13,7 +13,7 @@ public class FakeDataAttribute : DataAttribute private readonly Type[] expectedTypes; private readonly IEnumerable output; - public FakeDataAttribute(MethodInfo expectedMethod, + public FakeDataAttribute(MethodInfo expectedMethod, Type[] expectedTypes, IEnumerable output) { this.expectedMethod = expectedMethod; diff --git a/Src/AutoFixture.xUnit.UnitTest/Properties/AssemblyInfo.cs b/Src/AutoFixture.xUnit.UnitTest/Properties/AssemblyInfo.cs index 2ebd497e2..1630cc1cb 100644 --- a/Src/AutoFixture.xUnit.UnitTest/Properties/AssemblyInfo.cs +++ b/Src/AutoFixture.xUnit.UnitTest/Properties/AssemblyInfo.cs @@ -1,13 +1,13 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixture.xUnit.UnitTest/Scenario.cs b/Src/AutoFixture.xUnit.UnitTest/Scenario.cs index 1400e3e6f..ca00dab5b 100644 --- a/Src/AutoFixture.xUnit.UnitTest/Scenario.cs +++ b/Src/AutoFixture.xUnit.UnitTest/Scenario.cs @@ -83,16 +83,16 @@ public void CustomInlineDataSuppliesExtraValues(int x, int y, int z) private class MyCustomInlineAutoDataAttribute : InlineAutoDataAttribute { - public MyCustomInlineAutoDataAttribute(params object[] values) : - base(new MyCustomAutoDataAttribute(), values) + public MyCustomInlineAutoDataAttribute(params object[] values) + : base(new MyCustomAutoDataAttribute(), values) { } } private class MyCustomAutoDataAttribute : AutoDataAttribute { - public MyCustomAutoDataAttribute() : - base(() => new Fixture().Customize(new TheAnswer())) + public MyCustomAutoDataAttribute() + : base(() => new Fixture().Customize(new TheAnswer())) { } @@ -161,9 +161,7 @@ public void FavorArraysCausesArrayConstructorToBeInjectedWithFrozenItems([Frozen [Obsolete] public class Obsoleted { -#pragma warning disable 618 [Theory, AutoData(typeof(CustomizedFixture))] -#pragma warning restore 618 public void AutoDataProvidesCustomizedObject(PropertyHolder ph) { Assert.Equal("Ploeh", ph.Property); @@ -171,9 +169,7 @@ public void AutoDataProvidesCustomizedObject(PropertyHolder ph) [Theory, AutoData] public void FreezeFirstParameterAsBaseTypeAssignsSameInstanceToSecondParameterOfThatBaseType( -#pragma warning disable 0618 [Frozen(As = typeof(AbstractType))] ConcreteType p1, -#pragma warning restore 0618 AbstractType p2) { Assert.Equal(p1, p2); @@ -181,9 +177,7 @@ public void AutoDataProvidesCustomizedObject(PropertyHolder ph) [Theory, AutoData] public void FreezeFirstParameterAsNullTypeAssignsSameInstanceToSecondParameterOfSameType( -#pragma warning disable 0618 [Frozen(As = null)] ConcreteType p1, -#pragma warning restore 0618 ConcreteType p2) { Assert.Equal(p1, p2); diff --git a/Src/AutoFixture.xUnit/AutoDataAttribute.cs b/Src/AutoFixture.xUnit/AutoDataAttribute.cs index 2b0eab874..f3637b12c 100644 --- a/Src/AutoFixture.xUnit/AutoDataAttribute.cs +++ b/Src/AutoFixture.xUnit/AutoDataAttribute.cs @@ -73,7 +73,7 @@ protected AutoDataAttribute(IFixture fixture) protected AutoDataAttribute(Func fixtureFactory) { if (fixtureFactory == null) throw new ArgumentNullException(nameof(fixtureFactory)); - + this.fixtureLazy = new Lazy(fixtureFactory, LazyThreadSafetyMode.PublicationOnly); } @@ -98,8 +98,8 @@ public Type FixtureType /// /// Returns the data to be used to test the theory. /// - /// The method that is being tested - /// The types of the parameters for the test method + /// The method that is being tested. + /// The types of the parameters for the test method. /// The theory data generated by . public override IEnumerable GetData(MethodInfo methodUnderTest, Type[] parameterTypes) { diff --git a/Src/AutoFixture.xUnit/CompositeDataAttribute.cs b/Src/AutoFixture.xUnit/CompositeDataAttribute.cs index 94648b279..89f458261 100644 --- a/Src/AutoFixture.xUnit/CompositeDataAttribute.cs +++ b/Src/AutoFixture.xUnit/CompositeDataAttribute.cs @@ -51,7 +51,7 @@ public CompositeDataAttribute(params DataAttribute[] attributes) /// Returns the composition of the theory data. /// /// - /// The number of combined data sets is restricted to the length of the attribute which provides the fewest data sets + /// The number of combined data sets is restricted to the length of the attribute which provides the fewest data sets. /// public override IEnumerable GetData(MethodInfo methodUnderTest, Type[] parameterTypes) { diff --git a/Src/AutoFixture.xUnit/FrozenAttribute.cs b/Src/AutoFixture.xUnit/FrozenAttribute.cs index dd8c76e38..b78e37e9b 100644 --- a/Src/AutoFixture.xUnit/FrozenAttribute.cs +++ b/Src/AutoFixture.xUnit/FrozenAttribute.cs @@ -14,7 +14,7 @@ namespace AutoFixture.Xunit public sealed class FrozenAttribute : CustomizeAttribute { [Obsolete("The As property is deprecated.")] - private Type _as; + private Type @as; /// /// Initializes a new instance of the class. @@ -50,8 +50,8 @@ public FrozenAttribute(Matching by) "If you instead wish to map it to its direct base type, use [Frozen(Matching.DirectBaseType)].", true)] public Type As { - get => this._as; - set => this._as = value; + get => this.@as; + set => this.@as = value; } /// @@ -85,7 +85,7 @@ public override ICustomization GetCustomization(ParameterInfo parameter) private bool ShouldMatchBySpecificType() { #pragma warning disable 0618 - return this._as != null; + return this.@as != null; #pragma warning restore 0618 } @@ -94,7 +94,7 @@ private ICustomization FreezeAsType(Type type) return new FreezingCustomization( type, #pragma warning disable 0618 - this._as ?? type); + this.@as ?? type); #pragma warning restore 0618 } diff --git a/Src/AutoFixture.xUnit/InlineAutoDataAttribute.cs b/Src/AutoFixture.xUnit/InlineAutoDataAttribute.cs index 9cd675f38..b2dce501d 100644 --- a/Src/AutoFixture.xUnit/InlineAutoDataAttribute.cs +++ b/Src/AutoFixture.xUnit/InlineAutoDataAttribute.cs @@ -7,7 +7,7 @@ namespace AutoFixture.Xunit /// /// Provides a data source for a data theory, with the data coming from inline /// values combined with auto-generated data specimens generated by AutoFixture. - /// + /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] [CLSCompliant(false)] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", @@ -62,7 +62,7 @@ public InlineAutoDataAttribute(params object[] values) /// // y can vary, so we can't express any meaningful assertion for it. /// Assert.Equal(42, z); /// } - /// + /// /// private class MyCustomInlineAutoDataAttribute : InlineAutoDataAttribute /// { /// public MyCustomInlineAutoDataAttribute(params object[] values) : @@ -70,14 +70,14 @@ public InlineAutoDataAttribute(params object[] values) /// { /// } /// } - /// + /// /// private class MyCustomAutoDataAttribute : AutoDataAttribute /// { /// public MyCustomAutoDataAttribute() : /// base(() => new Fixture().Customize(new TheAnswer())) /// { /// } - /// + /// /// private class TheAnswer : ICustomization /// { /// public void Customize(IFixture fixture) diff --git a/Src/AutoFixture.xUnit/Properties/AssemblyInfo.cs b/Src/AutoFixture.xUnit/Properties/AssemblyInfo.cs index d88b70f13..24a6a77ed 100644 --- a/Src/AutoFixture.xUnit/Properties/AssemblyInfo.cs +++ b/Src/AutoFixture.xUnit/Properties/AssemblyInfo.cs @@ -1,14 +1,14 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Runtime.InteropServices; -using System; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixture.xUnit2.UnitTest/AutoDataAttributeTest.cs b/Src/AutoFixture.xUnit2.UnitTest/AutoDataAttributeTest.cs index 97621f2d1..a4b1588c9 100644 --- a/Src/AutoFixture.xUnit2.UnitTest/AutoDataAttributeTest.cs +++ b/Src/AutoFixture.xUnit2.UnitTest/AutoDataAttributeTest.cs @@ -32,16 +32,16 @@ public void InitializedWithDefaultConstructorHasCorrectFixture() // Assert Assert.IsAssignableFrom(result); } - + [Fact] public void InitializedWithFixtureFactoryConstrucorHasCorrectFixture() { // Arrange var fixture = new Fixture(); - + // Act var sut = new DerivedAutoDataAttribute(() => fixture); - + // Assert #pragma warning disable 618 Assert.Same(fixture, sut.Fixture); @@ -58,16 +58,16 @@ public void InitializeWithNullFixtureThrows() new DerivedAutoDataAttribute((IFixture)null)); #pragma warning restore 612 } - + [Fact] public void InitializeWithNullFixtureFactoryThrows() { // Arrange // Act & assert Assert.Throws(() => - new DerivedAutoDataAttribute((Func) null)); + new DerivedAutoDataAttribute((Func)null)); } - + [Fact] public void FixtureFactoryIsNotInvokedImmediately() { @@ -81,7 +81,7 @@ public void FixtureFactoryIsNotInvokedImmediately() // Act var sut = new DerivedAutoDataAttribute(fixtureFactory); - + // Assert Assert.False(wasInvoked); } @@ -228,7 +228,7 @@ public void GetDataOrdersCustomizationAttributes(string methodName) Assert.False(customizationLog[0] is FreezeOnMatchCustomization); Assert.True(customizationLog[1] is FreezeOnMatchCustomization); } - + private class DerivedAutoDataAttribute : AutoDataAttribute { [Obsolete] @@ -242,7 +242,7 @@ public DerivedAutoDataAttribute(Func fixtureFactory) { } } - + private class TypeWithIParameterCustomizationSourceUsage { public void DecoratedMethod([CustomizationSource] int arg) @@ -271,7 +271,7 @@ public void ShouldRecognizeAttributesImplementingIParameterCustomizationSource() // Arrange var method = typeof(TypeWithIParameterCustomizationSourceUsage) .GetMethod(nameof(TypeWithIParameterCustomizationSourceUsage.DecoratedMethod)); - + var customizationLog = new List(); var fixture = new DelegatingFixture(); fixture.OnCustomize = c => @@ -280,7 +280,7 @@ public void ShouldRecognizeAttributesImplementingIParameterCustomizationSource() return fixture; }; var sut = new DerivedAutoDataAttribute(() => fixture); - + // Act sut.GetData(method); // Assert @@ -300,13 +300,12 @@ public void PreDiscoveryShouldBeDisabled() var expectedAssembly = expectedDiscovererType.Assembly.GetName().Name; // Act - var actualType = (string) discovererAttr.ConstructorArguments[0].Value; - var actualAssembly = (string) discovererAttr.ConstructorArguments[1].Value; + var actualType = (string)discovererAttr.ConstructorArguments[0].Value; + var actualAssembly = (string)discovererAttr.ConstructorArguments[1].Value; // Assert Assert.Equal(expectedType, actualType); Assert.Equal(expectedAssembly, actualAssembly); - } } } \ No newline at end of file diff --git a/Src/AutoFixture.xUnit2.UnitTest/CompositeDataAttributeSufficientDataTest.cs b/Src/AutoFixture.xUnit2.UnitTest/CompositeDataAttributeSufficientDataTest.cs index aab871961..24c111d96 100644 --- a/Src/AutoFixture.xUnit2.UnitTest/CompositeDataAttributeSufficientDataTest.cs +++ b/Src/AutoFixture.xUnit2.UnitTest/CompositeDataAttributeSufficientDataTest.cs @@ -32,6 +32,7 @@ public void GetDataReturnsCorrectResult(IEnumerable attributes, I public IEnumerator GetEnumerator() { +#pragma warning disable SA1025 // Code should not contain multiple whitespace in a row yield return CreateTestCase( data: new[] { @@ -40,8 +41,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2, 3 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -52,8 +52,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2, 3 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -64,8 +63,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 3, 4 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -76,8 +74,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2, 5 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -87,8 +84,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2, 3 }, new object[] { 4, 5, 6 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -99,8 +95,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2, 3 }, new object[] { 4, 5, 6 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -111,8 +106,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2, 9 }, new object[] { 3, 4, 12 }, new object[] { 5, 6, 15 } - } - ); + }); // Second attribute restricts yield return CreateTestCase( @@ -124,8 +118,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2, 3 } - } - ); + }); // Shortest data provider is limiting factor yield return CreateTestCase( @@ -137,8 +130,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2, 3 } - } - ); + }); // Test incorrect number of parameters - should just return what it's given // and let xUnit deal with counting parameters @@ -151,8 +143,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -163,8 +154,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 3 }, - } - ); + }); yield return CreateTestCase( data: new[] @@ -176,8 +166,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 3 }, - } - ); + }); yield return CreateTestCase( data: new[] @@ -189,8 +178,7 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1 } - } - ); + }); yield return CreateTestCase( data: new[] @@ -200,8 +188,8 @@ public IEnumerator GetEnumerator() expected: new[] { new object[] { 1, 2, 3, 4 } - } - ); + }); +#pragma warning restore SA1025 // Code should not contain multiple whitespace in a row } IEnumerator IEnumerable.GetEnumerator() diff --git a/Src/AutoFixture.xUnit2.UnitTest/CompositeDataAttributeTest.cs b/Src/AutoFixture.xUnit2.UnitTest/CompositeDataAttributeTest.cs index 1145659f1..489f72f82 100644 --- a/Src/AutoFixture.xUnit2.UnitTest/CompositeDataAttributeTest.cs +++ b/Src/AutoFixture.xUnit2.UnitTest/CompositeDataAttributeTest.cs @@ -32,7 +32,7 @@ public void InitializeWithNullArrayThrows() public void AttributesIsCorrectWhenInitializedWithArray() { // Arrange - Action a = delegate { }; + Action a = () => { }; var method = a.GetMethodInfo(); var attributes = new[] @@ -62,7 +62,7 @@ public void InitializeWithNullEnumerableThrows() public void AttributesIsCorrectWhenInitializedWithEnumerable() { // Arrange - Action a = delegate { }; + Action a = () => { }; var method = a.GetMethodInfo(); var attributes = new[] @@ -93,7 +93,7 @@ public void GetDataWithNullMethodThrows() public void GetDataOnMethodWithNoParametersReturnsNoTheory() { // Arrange - Action a = delegate { }; + Action a = () => { }; var method = a.GetMethodInfo(); var parameters = method.GetParameters(); var parameterTypes = (from pi in parameters @@ -102,8 +102,7 @@ public void GetDataOnMethodWithNoParametersReturnsNoTheory() var sut = new CompositeDataAttribute( new FakeDataAttribute(method, Enumerable.Empty()), new FakeDataAttribute(method, Enumerable.Empty()), - new FakeDataAttribute(method, Enumerable.Empty()) - ); + new FakeDataAttribute(method, Enumerable.Empty())); // Act & assert var result = sut.GetData(a.GetMethodInfo()); diff --git a/Src/AutoFixture.xUnit2.UnitTest/CustomizeAttributeTest.cs b/Src/AutoFixture.xUnit2.UnitTest/CustomizeAttributeTest.cs index 474b4b7aa..13fdf3e71 100644 --- a/Src/AutoFixture.xUnit2.UnitTest/CustomizeAttributeTest.cs +++ b/Src/AutoFixture.xUnit2.UnitTest/CustomizeAttributeTest.cs @@ -24,7 +24,7 @@ public void SutIsAttribute() // Assert Assert.IsAssignableFrom(sut); } - + [Fact] public void SutImplementsIParameterCustomizationSource() { diff --git a/Src/AutoFixture.xUnit2.UnitTest/InlineAutoDataAttributeTest.cs b/Src/AutoFixture.xUnit2.UnitTest/InlineAutoDataAttributeTest.cs index 864fc1b7d..102b68cfc 100644 --- a/Src/AutoFixture.xUnit2.UnitTest/InlineAutoDataAttributeTest.cs +++ b/Src/AutoFixture.xUnit2.UnitTest/InlineAutoDataAttributeTest.cs @@ -116,8 +116,7 @@ public void AutoDataAttributeIsCorrectWhenCreatedExplicitlyByConstructor() // Assert Assert.Equal(expected, result); } - - + [Fact] public void DoesntActivateFixtureImmediately() { @@ -135,8 +134,7 @@ public void DoesntActivateFixtureImmediately() // Assert Assert.False(wasInvoked); } - - + [Fact] public void PreDiscoveryShouldBeDisabled() { @@ -150,15 +148,14 @@ public void PreDiscoveryShouldBeDisabled() var expectedAssembly = expectedDiscovererType.Assembly.GetName().Name; // Act - var actualType = (string) discovererAttr.ConstructorArguments[0].Value; - var actualAssembly = (string) discovererAttr.ConstructorArguments[1].Value; + var actualType = (string)discovererAttr.ConstructorArguments[0].Value; + var actualAssembly = (string)discovererAttr.ConstructorArguments[1].Value; // Assert Assert.Equal(expectedType, actualType); Assert.Equal(expectedAssembly, actualAssembly); - } - + private class DerivedInlineAutoDataAttribute : InlineAutoDataAttribute { public DerivedInlineAutoDataAttribute( @@ -168,7 +165,7 @@ private class DerivedInlineAutoDataAttribute : InlineAutoDataAttribute { } } - + private class DerivedAutoDataAttribute : AutoDataAttribute { public DerivedAutoDataAttribute(Func fixtureFactory) diff --git a/Src/AutoFixture.xUnit2.UnitTest/Properties/AssemblyInfo.cs b/Src/AutoFixture.xUnit2.UnitTest/Properties/AssemblyInfo.cs index a0df669d4..bbe987e3e 100644 --- a/Src/AutoFixture.xUnit2.UnitTest/Properties/AssemblyInfo.cs +++ b/Src/AutoFixture.xUnit2.UnitTest/Properties/AssemblyInfo.cs @@ -1,13 +1,13 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixture.xUnit2.UnitTest/Scenario.cs b/Src/AutoFixture.xUnit2.UnitTest/Scenario.cs index 5df9c25e7..35cdf7290 100644 --- a/Src/AutoFixture.xUnit2.UnitTest/Scenario.cs +++ b/Src/AutoFixture.xUnit2.UnitTest/Scenario.cs @@ -84,16 +84,16 @@ public void CustomInlineDataSuppliesExtraValues(int x, int y, int z) private class MyCustomInlineAutoDataAttribute : InlineAutoDataAttribute { - public MyCustomInlineAutoDataAttribute(params object[] values) : - base(new MyCustomAutoDataAttribute(), values) + public MyCustomInlineAutoDataAttribute(params object[] values) + : base(new MyCustomAutoDataAttribute(), values) { } } private class MyCustomAutoDataAttribute : AutoDataAttribute { - public MyCustomAutoDataAttribute() : - base(() => new Fixture().Customize(new TheAnswer())) + public MyCustomAutoDataAttribute() + : base(() => new Fixture().Customize(new TheAnswer())) { } @@ -163,9 +163,7 @@ public void FavorArraysCausesArrayConstructorToBeInjectedWithFrozenItems([Frozen [Obsolete] public class Obsoleted { -#pragma warning disable 618 [Theory, AutoData(typeof(CustomizedFixture))] -#pragma warning restore 618 public void AutoDataProvidesCustomizedObject(PropertyHolder ph) { Assert.Equal("Ploeh", ph.Property); @@ -173,9 +171,7 @@ public void AutoDataProvidesCustomizedObject(PropertyHolder ph) [Theory, AutoData] public void FreezeFirstParameterAsBaseTypeAssignsSameInstanceToSecondParameterOfThatBaseType( -#pragma warning disable 0618 [Frozen(As = typeof(AbstractType))] ConcreteType p1, -#pragma warning restore 0618 AbstractType p2) { Assert.Same(p1, p2); @@ -183,9 +179,7 @@ public void AutoDataProvidesCustomizedObject(PropertyHolder ph) [Theory, AutoData] public void FreezeFirstParameterAsNullTypeAssignsSameInstanceToSecondParameterOfSameType( -#pragma warning disable 0618 [Frozen(As = null)] ConcreteType p1, -#pragma warning restore 0618 ConcreteType p2) { Assert.Same(p1, p2); diff --git a/Src/AutoFixture.xUnit2/AutoDataAttribute.cs b/Src/AutoFixture.xUnit2/AutoDataAttribute.cs index 8ac916868..df5f44041 100644 --- a/Src/AutoFixture.xUnit2/AutoDataAttribute.cs +++ b/Src/AutoFixture.xUnit2/AutoDataAttribute.cs @@ -102,7 +102,7 @@ public Type FixtureType /// /// Returns the data to be used to test the theory. /// - /// The method that is being tested + /// The method that is being tested. /// The theory data generated by . public override IEnumerable GetData(MethodInfo testMethod) { diff --git a/Src/AutoFixture.xUnit2/CompositeDataAttribute.cs b/Src/AutoFixture.xUnit2/CompositeDataAttribute.cs index c70cd7e48..85d46d030 100644 --- a/Src/AutoFixture.xUnit2/CompositeDataAttribute.cs +++ b/Src/AutoFixture.xUnit2/CompositeDataAttribute.cs @@ -51,7 +51,7 @@ public CompositeDataAttribute(params DataAttribute[] attributes) /// Returns the composition of the theory data. /// /// - /// The number of combined data sets is restricted to the length of the attribute which provides the fewest data sets + /// The number of combined data sets is restricted to the length of the attribute which provides the fewest data sets. /// public override IEnumerable GetData(MethodInfo testMethod) { diff --git a/Src/AutoFixture.xUnit2/FrozenAttribute.cs b/Src/AutoFixture.xUnit2/FrozenAttribute.cs index d4e265a7e..050e5ab1f 100644 --- a/Src/AutoFixture.xUnit2/FrozenAttribute.cs +++ b/Src/AutoFixture.xUnit2/FrozenAttribute.cs @@ -14,7 +14,7 @@ namespace AutoFixture.Xunit2 public sealed class FrozenAttribute : CustomizeAttribute { [Obsolete("The As property is deprecated.")] - private Type _as; + private Type @as; /// /// Initializes a new instance of the class. @@ -48,8 +48,8 @@ public FrozenAttribute(Matching by) [Obsolete("The ability to map a frozen object to a specific type is deprecated and will likely be removed in the future. If you wish to map a frozen type to its implemented interfaces, use [Frozen(Matching.ImplementedInterfaces)]. If you instead wish to map it to its direct base type, use [Frozen(Matching.DirectBaseType)].", true)] public Type As { - get => this._as; - set => this._as = value; + get => this.@as; + set => this.@as = value; } /// @@ -83,7 +83,7 @@ public override ICustomization GetCustomization(ParameterInfo parameter) private bool ShouldMatchBySpecificType() { #pragma warning disable 0618 - return this._as != null; + return this.@as != null; #pragma warning restore 0618 } @@ -92,7 +92,7 @@ private ICustomization FreezeAsType(Type type) return new FreezingCustomization( type, #pragma warning disable 0618 - this._as ?? type); + this.@as ?? type); #pragma warning restore 0618 } diff --git a/Src/AutoFixture.xUnit2/InlineAutoDataAttribute.cs b/Src/AutoFixture.xUnit2/InlineAutoDataAttribute.cs index fa4755e2d..67ef24548 100644 --- a/Src/AutoFixture.xUnit2/InlineAutoDataAttribute.cs +++ b/Src/AutoFixture.xUnit2/InlineAutoDataAttribute.cs @@ -14,7 +14,7 @@ namespace AutoFixture.Xunit2 assemblyName: "AutoFixture.Xunit2")] [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] [CLSCompliant(false)] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "This attribute is the root of a potential attribute hierarchy.")] public class InlineAutoDataAttribute : CompositeDataAttribute { @@ -22,12 +22,12 @@ public class InlineAutoDataAttribute : CompositeDataAttribute /// Gets the attribute used to automatically generate the remaining theory parameters, which are not fixed. /// public DataAttribute AutoDataAttribute { get; } - + /// /// Gets the data values to pass to the theory. /// public IEnumerable Values { get; } - + /// /// Initializes a new instance of the class. /// @@ -66,7 +66,7 @@ public InlineAutoDataAttribute(params object[] values) /// // y can vary, so we can't express any meaningful assertion for it. /// Assert.Equal(42, z); /// } - /// + /// /// private class MyCustomInlineAutoDataAttribute : InlineAutoDataAttribute /// { /// public MyCustomInlineAutoDataAttribute(params object[] values) : @@ -74,14 +74,14 @@ public InlineAutoDataAttribute(params object[] values) /// { /// } /// } - /// + /// /// private class MyCustomAutoDataAttribute : AutoDataAttribute /// { /// public MyCustomAutoDataAttribute() : /// base(() => new Fixture().Customize(new TheAnswer())) /// { /// } - /// + /// /// private class TheAnswer : ICustomization /// { /// public void Customize(IFixture fixture) diff --git a/Src/AutoFixture.xUnit2/NoPreDiscoveryDataDiscoverer.cs b/Src/AutoFixture.xUnit2/NoPreDiscoveryDataDiscoverer.cs index a9135c596..0d16f4f5a 100644 --- a/Src/AutoFixture.xUnit2/NoPreDiscoveryDataDiscoverer.cs +++ b/Src/AutoFixture.xUnit2/NoPreDiscoveryDataDiscoverer.cs @@ -13,9 +13,9 @@ public class NoPreDiscoveryDataDiscoverer : DataDiscoverer /// Always returns 'false', indicating that discovery of tests is /// not supported. /// - /// The attribute - /// The method being discovered - /// false + /// The attribute. + /// The method being discovered. + /// false. public override bool SupportsDiscoveryEnumeration( IAttributeInfo dataAttribute, IMethodInfo testMethod) { diff --git a/Src/AutoFixture.xUnit2/Properties/AssemblyInfo.cs b/Src/AutoFixture.xUnit2/Properties/AssemblyInfo.cs index 98db3287b..3203121cf 100644 --- a/Src/AutoFixture.xUnit2/Properties/AssemblyInfo.cs +++ b/Src/AutoFixture.xUnit2/Properties/AssemblyInfo.cs @@ -1,14 +1,14 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Runtime.InteropServices; -using System; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixture/AutoPropertiesTarget.cs b/Src/AutoFixture/AutoPropertiesTarget.cs index e5ac7a730..dbf8e2acf 100644 --- a/Src/AutoFixture/AutoPropertiesTarget.cs +++ b/Src/AutoFixture/AutoPropertiesTarget.cs @@ -35,7 +35,7 @@ public AutoPropertiesTarget(ISpecimenBuilder builder) { this.Builder = builder ?? throw new ArgumentNullException(nameof(builder)); } - + /// Composes the supplied builders. /// The builders to compose. /// diff --git a/Src/AutoFixture/BooleanSwitch.cs b/Src/AutoFixture/BooleanSwitch.cs index d04753bce..32710ed5f 100644 --- a/Src/AutoFixture/BooleanSwitch.cs +++ b/Src/AutoFixture/BooleanSwitch.cs @@ -4,7 +4,7 @@ namespace AutoFixture { /// - /// Creates an alternating sequence of and , + /// Creates an alternating sequence of and . /// public class BooleanSwitch : ISpecimenBuilder { @@ -24,8 +24,7 @@ public BooleanSwitch() /// every other time it is invoked. /// /// - /// , followed by at the next invocation, and - /// so on. + /// , followed by at the next invocation, and so on. /// [Obsolete("Please use the Create(request, context) method as this overload will be removed to make API uniform.")] public bool Create() @@ -45,7 +44,7 @@ public bool Create() /// , followed by at the next invocation, and /// so on. /// - /// Obsolete: Please move over to using Create() as this method will be removed in the next release + /// Obsolete: Please move over to using Create() as this method will be removed in the next release. [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] public bool CreateAnonymous() { diff --git a/Src/AutoFixture/ByteSequenceGenerator.cs b/Src/AutoFixture/ByteSequenceGenerator.cs index dd063f1bd..7172b6506 100644 --- a/Src/AutoFixture/ByteSequenceGenerator.cs +++ b/Src/AutoFixture/ByteSequenceGenerator.cs @@ -36,7 +36,7 @@ public byte Create() /// Creates an anonymous number. /// /// The next number in a consecutive sequence. - /// Obsolete: Please move over to using Create() as this method will be removed in the next release + /// Obsolete: Please move over to using Create() as this method will be removed in the next release. [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] public byte CreateAnonymous() { diff --git a/Src/AutoFixture/ConstrainedStringGenerator.cs b/Src/AutoFixture/ConstrainedStringGenerator.cs index 64df9e903..1e42a8f66 100644 --- a/Src/AutoFixture/ConstrainedStringGenerator.cs +++ b/Src/AutoFixture/ConstrainedStringGenerator.cs @@ -39,7 +39,7 @@ private static string Create(int minimumLength, int maximumLength, ISpecimenCont sb.Append(context.Resolve(typeof(string))); } while (sb.Length < minimumLength); - + if (sb.Length > maximumLength) { return sb.ToString().Substring(0, maximumLength); diff --git a/Src/AutoFixture/CustomizationNode.cs b/Src/AutoFixture/CustomizationNode.cs index e5ba9bfe8..5436d9454 100644 --- a/Src/AutoFixture/CustomizationNode.cs +++ b/Src/AutoFixture/CustomizationNode.cs @@ -38,7 +38,7 @@ public CustomizationNode(ISpecimenBuilder builder) this.Builder = builder; } - + /// Composes the supplied builders. /// The builders to compose. /// diff --git a/Src/AutoFixture/DataAnnotations/DataAnnotationsSupportNode.cs b/Src/AutoFixture/DataAnnotations/DataAnnotationsSupportNode.cs index 3c9d8f17b..c9bc44e89 100644 --- a/Src/AutoFixture/DataAnnotations/DataAnnotationsSupportNode.cs +++ b/Src/AutoFixture/DataAnnotations/DataAnnotationsSupportNode.cs @@ -23,7 +23,7 @@ public class DataAnnotationsSupportNode : ISpecimenBuilderNode public ISpecimenBuilder Builder { get; } /// - /// Initializes a new instance of + /// Initializes a new instance of . /// /// Builder that handles all the data annotation related requests. public DataAnnotationsSupportNode(ISpecimenBuilder builder) diff --git a/Src/AutoFixture/DataAnnotations/MinAndMaxLengthAttributeRelay.cs b/Src/AutoFixture/DataAnnotations/MinAndMaxLengthAttributeRelay.cs index 0e2f122f0..892546c55 100644 --- a/Src/AutoFixture/DataAnnotations/MinAndMaxLengthAttributeRelay.cs +++ b/Src/AutoFixture/DataAnnotations/MinAndMaxLengthAttributeRelay.cs @@ -129,6 +129,7 @@ private static object ToArray(IEnumerable elements, Type elementType) private class Range { public int Min { get; } + public int Max { get; } private Range(int min, int max) diff --git a/Src/AutoFixture/DataAnnotations/NumericRangedRequestRelay.cs b/Src/AutoFixture/DataAnnotations/NumericRangedRequestRelay.cs index 7ebe1ac95..d36f9aafc 100644 --- a/Src/AutoFixture/DataAnnotations/NumericRangedRequestRelay.cs +++ b/Src/AutoFixture/DataAnnotations/NumericRangedRequestRelay.cs @@ -4,7 +4,7 @@ namespace AutoFixture.DataAnnotations { /// - /// Handles the for the number type by forwarding it + /// Handles the for the number type by forwarding it /// to the . /// public class NumericRangedRequestRelay : ISpecimenBuilder diff --git a/Src/AutoFixture/DataAnnotations/RangeAttributeRelay.cs b/Src/AutoFixture/DataAnnotations/RangeAttributeRelay.cs index eafa44d4c..2ca1ed000 100644 --- a/Src/AutoFixture/DataAnnotations/RangeAttributeRelay.cs +++ b/Src/AutoFixture/DataAnnotations/RangeAttributeRelay.cs @@ -41,7 +41,7 @@ public object Create(object request, ISpecimenContext context) return new NoSpecimen(); } - var memberType = GetMemberType(rangeAttribute, request); + var memberType = this.GetMemberType(rangeAttribute, request); var rangedRequest = new RangedRequest( memberType, diff --git a/Src/AutoFixture/DataAnnotations/RangedRequest.cs b/Src/AutoFixture/DataAnnotations/RangedRequest.cs index 165945018..5ebea5e3f 100644 --- a/Src/AutoFixture/DataAnnotations/RangedRequest.cs +++ b/Src/AutoFixture/DataAnnotations/RangedRequest.cs @@ -15,7 +15,7 @@ public class RangedRequest : IEquatable /// /// Initializes a new instance of the class. /// - /// Type of the member the range is specified for + /// Type of the member the range is specified for. /// Type of the operand. /// The minimum. /// The maximum. @@ -139,7 +139,6 @@ private static object GetConvertedRangeBoundary(object attributeValue, Type conv { // Mimic RangeAttribute conversion behavior: // https://github.com/Microsoft/referencesource/blob/b31308b03e8bd5bf779fb80fda71f31eb959fe0b/System.ComponentModel.DataAnnotations/DataAnnotations/RangeAttribute.cs#L140 - if (attributeValue.GetType() == conversionType) return attributeValue; @@ -153,7 +152,7 @@ private static object GetConvertedRangeBoundary(object attributeValue, Type conv // https://stackoverflow.com/a/30877647/2009373 // That's why we resort to Convert.ChangeType() if we detect that we cannot convert. var converter = TypeDescriptor.GetConverter(conversionType); - if(converter.CanConvertFrom(attributeValue.GetType())) + if (converter.CanConvertFrom(attributeValue.GetType())) return converter.ConvertFrom(attributeValue); return Convert.ChangeType(attributeValue, conversionType, CultureInfo.CurrentCulture); @@ -181,8 +180,7 @@ private static object GetConvertedRangeBoundary(object attributeValue, Type conv "RangeAttribute(typeof(long), \"0\", \"9223372036854775807\")", Environment.NewLine, attributeValue.GetType().FullName, - conversionType.FullName - ), + conversionType.FullName), ex); } } diff --git a/Src/AutoFixture/DataAnnotations/TimeSpanRangedRequestRelay.cs b/Src/AutoFixture/DataAnnotations/TimeSpanRangedRequestRelay.cs index 124b8b21a..dbbf22bd5 100644 --- a/Src/AutoFixture/DataAnnotations/TimeSpanRangedRequestRelay.cs +++ b/Src/AutoFixture/DataAnnotations/TimeSpanRangedRequestRelay.cs @@ -10,7 +10,7 @@ namespace AutoFixture.DataAnnotations /// public class TimeSpanRangedRequestRelay : ISpecimenBuilder { - /// + /// public object Create(object request, ISpecimenContext context) { if (context == null) throw new ArgumentNullException(nameof(context)); @@ -58,6 +58,7 @@ private static object RandomizeTimeSpanInRange(TimeSpanRange range, ISpecimenCon private struct TimeSpanRange { public TimeSpan Min { get; set; } + public TimeSpan Max { get; set; } } } diff --git a/Src/AutoFixture/DecimalSequenceGenerator.cs b/Src/AutoFixture/DecimalSequenceGenerator.cs index 680e29168..78620e7d0 100644 --- a/Src/AutoFixture/DecimalSequenceGenerator.cs +++ b/Src/AutoFixture/DecimalSequenceGenerator.cs @@ -22,7 +22,6 @@ public DecimalSequenceGenerator() /// /// Creates an anonymous number. /// - /// The next number in a consecutive sequence. [Obsolete("Please use the Create(request, context) method as this overload will be removed to make API uniform.")] public decimal Create() { @@ -35,23 +34,13 @@ public decimal Create() /// /// Creates an anonymous number. /// - /// The next number in a consecutive sequence. - /// Obsolete: Please move over to using Create() as this method will be removed in the next release [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] public decimal CreateAnonymous() { return this.Create(); } - /// - /// Creates an anonymous number. - /// - /// The request that describes what to create. - /// Not used. - /// - /// The next number in a consecutive sequence, if is a request - /// for a decimal number; otherwise, a instance. - /// + /// public object Create(object request, ISpecimenContext context) { if (!typeof(decimal).Equals(request)) diff --git a/Src/AutoFixture/DefaultRelays.cs b/Src/AutoFixture/DefaultRelays.cs index 2c1ffd5f2..c0a65c7ff 100644 --- a/Src/AutoFixture/DefaultRelays.cs +++ b/Src/AutoFixture/DefaultRelays.cs @@ -24,7 +24,7 @@ public virtual IEnumerator GetEnumerator() yield return new MultidimensionalArrayRelay(); yield return new ArrayRelay(); yield return new ParameterRequestRelay(); - yield return new PropertyRequestRelay(); + yield return new PropertyRequestRelay(); yield return new FieldRequestRelay(); yield return new FiniteSequenceRelay(); yield return new SeedIgnoringRelay(); diff --git a/Src/AutoFixture/DictionaryFiller.cs b/Src/AutoFixture/DictionaryFiller.cs index 02401b16f..ab4ab6854 100644 --- a/Src/AutoFixture/DictionaryFiller.cs +++ b/Src/AutoFixture/DictionaryFiller.cs @@ -76,8 +76,10 @@ public void Execute(object specimen, ISpecimenContext context) ISpecimenContext context) { foreach (var kvp in GetValues(context)) + { if (!dictionary.ContainsKey(kvp.Key)) dictionary.Add(kvp); + } } private static IEnumerable> GetValues( diff --git a/Src/AutoFixture/DomainName.cs b/Src/AutoFixture/DomainName.cs index 1493314b4..7bbf31b5e 100644 --- a/Src/AutoFixture/DomainName.cs +++ b/Src/AutoFixture/DomainName.cs @@ -22,10 +22,10 @@ public DomainName(string domainName) public string Domain { get; } /// - /// Returns a that represents the domain name for this instance. + /// Returns a that represents the domain name for this instance. /// /// - /// A that represents the domain name for this instance. + /// A that represents the domain name for this instance. /// public override string ToString() { @@ -33,12 +33,12 @@ public override string ToString() } /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// - /// The to compare with this instance. + /// The to compare with this instance. /// /// - /// true if the specified is equal to this instance; + /// true if the specified is equal to this instance; /// otherwise, false. /// /// @@ -57,8 +57,8 @@ public override bool Equals(object obj) /// Returns a hash code for this instance. /// /// - /// A hash code for this instance, suitable for use in hashing algorithms and data - /// structures like a hash table. + /// A hash code for this instance, suitable for use in hashing algorithms and data + /// structures like a hash table. /// public override int GetHashCode() { diff --git a/Src/AutoFixture/DomainNameGenerator.cs b/Src/AutoFixture/DomainNameGenerator.cs index 4df9bfcb9..6193ab62b 100644 --- a/Src/AutoFixture/DomainNameGenerator.cs +++ b/Src/AutoFixture/DomainNameGenerator.cs @@ -11,8 +11,7 @@ public class DomainNameGenerator : ISpecimenBuilder private readonly ElementsBuilder fictitiousDomainBuilder = new ElementsBuilder( "example.com", "example.net", - "example.org" - ); + "example.org"); /// public object Create(object request, ISpecimenContext context) diff --git a/Src/AutoFixture/DoubleSequenceGenerator.cs b/Src/AutoFixture/DoubleSequenceGenerator.cs index 1f519cfab..48e41c004 100644 --- a/Src/AutoFixture/DoubleSequenceGenerator.cs +++ b/Src/AutoFixture/DoubleSequenceGenerator.cs @@ -22,7 +22,6 @@ public DoubleSequenceGenerator() /// /// Creates an anonymous number. /// - /// The next number in a consecutive sequence. [Obsolete("Please use the Create(request, context) method as this overload will be removed to make API uniform.")] public double Create() { @@ -35,24 +34,13 @@ public double Create() /// /// Creates an anonymous number. /// - /// The next number in a consecutive sequence. - /// Obsolete: Please move over to using Create() as this method will be removed in the next release [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] public double CreateAnonymous() { return this.Create(); } - - /// - /// Creates an anonymous number. - /// - /// The request that describes what to create. - /// Not used. - /// - /// The next number in a consecutive sequence, if is a request - /// for a ; otherwise, a instance. - /// + /// public object Create(object request, ISpecimenContext context) { if (!typeof(double).Equals(request)) diff --git a/Src/AutoFixture/Dsl/CompositeNodeComposer.cs b/Src/AutoFixture/Dsl/CompositeNodeComposer.cs index b55058d9d..99db70885 100644 --- a/Src/AutoFixture/Dsl/CompositeNodeComposer.cs +++ b/Src/AutoFixture/Dsl/CompositeNodeComposer.cs @@ -19,7 +19,7 @@ namespace AutoFixture.Dsl /// /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "The main responsibility of this class isn't to be a 'collection' (which, by the way, it isn't - it's just an Iterator).")] - public class CompositeNodeComposer : + public class CompositeNodeComposer : ICustomizationComposer, ISpecimenBuilderNode { @@ -31,7 +31,7 @@ public class CompositeNodeComposer : /// A node which may contain sub-nodes. /// /// - /// node is null + /// node is null. /// /// public CompositeNodeComposer(ISpecimenBuilderNode node) diff --git a/Src/AutoFixture/Dsl/CompositePostprocessComposer.cs b/Src/AutoFixture/Dsl/CompositePostprocessComposer.cs index 5bb374afd..d35bcdd14 100644 --- a/Src/AutoFixture/Dsl/CompositePostprocessComposer.cs +++ b/Src/AutoFixture/Dsl/CompositePostprocessComposer.cs @@ -24,7 +24,7 @@ public CompositePostprocessComposer(IEnumerable> compose /// /// Initializes a new instance of the - /// class with an array of instances. + /// class with an array of instances. /// /// The composers to aggregate. public CompositePostprocessComposer(params IPostprocessComposer[] composers) diff --git a/Src/AutoFixture/Dsl/NodeComposer.cs b/Src/AutoFixture/Dsl/NodeComposer.cs index 470301f5c..c44867c29 100644 --- a/Src/AutoFixture/Dsl/NodeComposer.cs +++ b/Src/AutoFixture/Dsl/NodeComposer.cs @@ -13,7 +13,7 @@ namespace AutoFixture.Dsl /// The type of specimen. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "The main responsibility of this class isn't to be a 'collection' (which, by the way, it isn't - it's just an Iterator).")] - public class NodeComposer : + public class NodeComposer : ICustomizationComposer, ISpecimenBuilderNode { @@ -226,7 +226,7 @@ public IPostprocessComposer Do(Action action) var filter = FindContainer(graphWithDoNode); return (NodeComposer)graphWithDoNode.ReplaceNodes( - with: n => n.Compose(n.Concat(new [] { new SeedIgnoringRelay() })), + with: n => n.Compose(n.Concat(new[] { new SeedIgnoringRelay() })), when: filter.Equals); } @@ -262,10 +262,10 @@ public IPostprocessComposer OmitAutoProperties() // We disable postprocessor rather than delete it. // The reason is that it's the only holder of which properties/fields should not be populated. - // If user later decide to enable properties population, we'll need this information + // If user later decide to enable properties population, we'll need this information // (e.g. if user does smth like fixture.Build().Without(x => x.P).OmitAutoProperties().WithAutoProperties() // the information from "Without" should not be missed) - return (NodeComposer) this.ReplaceNodes( + return (NodeComposer)this.ReplaceNodes( with: n => new Postprocessor( autoPropertiesNode.Builder, autoPropertiesNode.Command, @@ -293,7 +293,7 @@ public IPostprocessComposer OmitAutoProperties() Expression> propertyPicker) { ExpressionReflector.VerifyIsNonNestedWritableMemberExpression(propertyPicker); - + var targetToDecorate = this.FindFirstNode(n => n is NoSpecimenOutputGuard); return (NodeComposer)this.ReplaceNodes( @@ -327,12 +327,12 @@ public IPostprocessComposer OmitAutoProperties() Expression> propertyPicker, TProperty value) { ExpressionReflector.VerifyIsNonNestedWritableMemberExpression(propertyPicker); - + var graphWithAutoPropertiesNode = this.GetGraphWithAutoPropertiesNode(); var graphWithoutSeedIgnoringRelay = WithoutSeedIgnoringRelay(graphWithAutoPropertiesNode); var container = FindContainer(graphWithoutSeedIgnoringRelay); - + var graphWithProperty = graphWithoutSeedIgnoringRelay.ReplaceNodes( with: n => n.Compose( new ISpecimenBuilder[] @@ -346,7 +346,7 @@ public IPostprocessComposer OmitAutoProperties() when: container.Equals); var member = propertyPicker.GetWritableMember().Member; - return (NodeComposer) ExcludeMemberFromAutoProperties(member, graphWithProperty); + return (NodeComposer)ExcludeMemberFromAutoProperties(member, graphWithProperty); } /// @@ -361,7 +361,7 @@ public IPostprocessComposer WithAutoProperties() var g = this.GetGraphWithAutoPropertiesNode(); var autoProperties = FindAutoPropertiesNode(g); - return (NodeComposer) g.ReplaceNodes( + return (NodeComposer)g.ReplaceNodes( with: n => new Postprocessor( autoProperties.Builder, autoProperties.Command, @@ -387,11 +387,11 @@ public IPostprocessComposer WithAutoProperties() Expression> propertyPicker) { ExpressionReflector.VerifyIsNonNestedWritableMemberExpression(propertyPicker); - + var member = propertyPicker.GetWritableMember().Member; var graphWithAutoPropertiesNode = this.GetGraphWithAutoPropertiesNode(); - return (NodeComposer) ExcludeMemberFromAutoProperties(member, graphWithAutoPropertiesNode); + return (NodeComposer)ExcludeMemberFromAutoProperties(member, graphWithAutoPropertiesNode); } /// @@ -418,7 +418,7 @@ private NodeComposer WithFactory(ISpecimenBuilder factory) return (NodeComposer)this.ReplaceNodes( with: n => n.Compose(new[] { factory }), when: n => n is NoSpecimenOutputGuard); - } + } private static IRequestSpecification CreateSpecification() { @@ -500,12 +500,12 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() private NodeComposer GetGraphWithAutoPropertiesNode() { var existingNode = FindAutoPropertiesNode(this); - if(existingNode != null) return this; - + if (existingNode != null) return this; + var g = WithoutSeedIgnoringRelay(this); var filter = FindContainer(g); - //Create AutoProperties node in inactive state + // Create AutoProperties node in inactive state return (NodeComposer)g.ReplaceNodes( with: n => n.Compose( new ISpecimenBuilder[] @@ -521,22 +521,22 @@ private NodeComposer GetGraphWithAutoPropertiesNode() private static Postprocessor FindAutoPropertiesNode(ISpecimenBuilderNode graph) { - return (Postprocessor) graph + return (Postprocessor)graph .FindFirstNodeOrDefault(n => n is Postprocessor postprocessor && postprocessor.Command is AutoPropertiesCommand); } - + /// /// Adjusts the AutoProperties postprocessor and changes rule to avoid the specified member population. - /// If AutoProperties node is missing, nothing is done. + /// If AutoProperties node is missing, nothing is done. /// - private static ISpecimenBuilderNode ExcludeMemberFromAutoProperties(MemberInfo member, + private static ISpecimenBuilderNode ExcludeMemberFromAutoProperties(MemberInfo member, ISpecimenBuilderNode graph) { var autoPropertiesNode = FindAutoPropertiesNode(graph); if (autoPropertiesNode == null) return graph; - var currentSpecification = ((AutoPropertiesCommand) autoPropertiesNode.Command).Specification; + var currentSpecification = ((AutoPropertiesCommand)autoPropertiesNode.Command).Specification; var newRule = new InverseRequestSpecification( new EqualRequestSpecification( member, @@ -550,7 +550,7 @@ private static Postprocessor FindAutoPropertiesNode(ISpecimenBuilderNode graph) } else if (currentSpecification is AndRequestSpecification andSpec) { - specification = new AndRequestSpecification(andSpec.Specifications.Concat(new[] {newRule})); + specification = new AndRequestSpecification(andSpec.Specifications.Concat(new[] { newRule })); } else { @@ -564,7 +564,7 @@ private static Postprocessor FindAutoPropertiesNode(ISpecimenBuilderNode graph) autoPropertiesNode.Specification), when: autoPropertiesNode.Equals); } - + private static ISpecimenBuilderNode WithoutSeedIgnoringRelay(ISpecimenBuilderNode graph) { var g = graph.ReplaceNodes( diff --git a/Src/AutoFixture/Dsl/NullComposer.cs b/Src/AutoFixture/Dsl/NullComposer.cs index aee79a9ba..5702031cb 100644 --- a/Src/AutoFixture/Dsl/NullComposer.cs +++ b/Src/AutoFixture/Dsl/NullComposer.cs @@ -17,12 +17,6 @@ public class NullComposer : ICustomizationComposer /// /// Initializes a new instance of the class. /// - /// - /// - /// Initialized in this way, will return an empty - /// . - /// - /// public NullComposer() : this(new CompositeSpecimenBuilder()) { @@ -30,12 +24,8 @@ public NullComposer() /// /// Initializes a new instance of the class with an - /// that will be returned by the - /// method. + /// that will be returned by the method. /// - /// - /// The builder to return by the method. - /// public NullComposer(ISpecimenBuilder builder) { if (builder == null) throw new ArgumentNullException(nameof(builder)); @@ -47,9 +37,6 @@ public NullComposer(ISpecimenBuilder builder) /// Initializes a new instance of the class with a /// function used to implement the method. /// - /// - /// The function that will be used to implement . - /// public NullComposer(Func factory) { this.compose = factory ?? throw new ArgumentNullException(nameof(factory)); @@ -58,8 +45,6 @@ public NullComposer(Func factory) /// /// Does nothing. /// - /// Ignored. - /// The current instance. public IPostprocessComposer FromSeed(Func factory) { return this; @@ -68,117 +53,94 @@ public IPostprocessComposer FromSeed(Func factory) /// /// Does nothing. /// - /// Ignored. - /// The current instance. public IPostprocessComposer FromFactory(ISpecimenBuilder factory) { return this; } /// - /// Does nothing + /// Does nothing. /// - /// Ignored. - /// The current instance. public IPostprocessComposer FromFactory(Func factory) { return this; } /// - /// Does nothing + /// Does nothing. /// - /// Ignored. - /// The current instance. public IPostprocessComposer FromFactory(Func factory) { return this; } /// - /// Does nothing + /// Does nothing. /// - /// Ignored. - /// The current instance. public IPostprocessComposer FromFactory(Func factory) { return this; } /// - /// Does nothing + /// Does nothing. /// - /// Ignored. - /// The current instance. public IPostprocessComposer FromFactory(Func factory) { return this; } /// - /// Does nothing + /// Does nothing. /// - /// Ignored. - /// The current instance. public IPostprocessComposer FromFactory(Func factory) { return this; } /// - /// Does nothing + /// Does nothing. /// - /// Ignored. - /// The current instance. public IPostprocessComposer Do(Action action) { return this; } /// - /// Does nothing + /// Does nothing. /// - /// The current instance. public IPostprocessComposer OmitAutoProperties() { return this; } /// - /// Does nothing + /// Does nothing. /// - /// Ignored. - /// The current instance. public IPostprocessComposer With(Expression> propertyPicker) { return this; } /// - /// Does nothing + /// Does nothing. /// - /// Ignored. - /// Ignored. - /// The current instance. public IPostprocessComposer With(Expression> propertyPicker, TProperty value) { return this; } /// - /// Does nothing + /// Does nothing. /// - /// The current instance. public IPostprocessComposer WithAutoProperties() { return this; } /// - /// Does nothing + /// Does nothing. /// - /// Ignored. - /// The current instance. public IPostprocessComposer Without(Expression> propertyPicker) { return this; @@ -187,9 +149,6 @@ public IPostprocessComposer Without(Expression> /// /// Composes a new instance. /// - /// - /// An instance. - /// /// /// /// Which is returned depends on how the @@ -201,23 +160,7 @@ public ISpecimenBuilder Compose() return this.compose(); } - /// Creates a new specimen based on a request. - /// - /// The request that describes what to create. - /// - /// - /// A context that can be used to create other specimens. - /// - /// - /// The requested specimen if possible; otherwise a - /// instance. - /// - /// - /// - /// The can be any object, but will often be a - /// or other instances. - /// - /// + /// public object Create(object request, ISpecimenContext context) { return this.compose().Create(request, context); diff --git a/Src/AutoFixture/ElementsBuilder.cs b/Src/AutoFixture/ElementsBuilder.cs index 624b125b5..e74c7c75c 100644 --- a/Src/AutoFixture/ElementsBuilder.cs +++ b/Src/AutoFixture/ElementsBuilder.cs @@ -6,9 +6,8 @@ namespace AutoFixture { /// - /// Draws a random element from the given collection + /// Draws a random element from the given collection. /// - /// public sealed class ElementsBuilder : ISpecimenBuilder { private readonly T[] elements; @@ -17,16 +16,14 @@ public sealed class ElementsBuilder : ISpecimenBuilder /// /// Initializes a new instance of the class. /// - /// The elements from which to draw from. - public ElementsBuilder(params T[] elements) : this(elements.AsEnumerable()) + public ElementsBuilder(params T[] elements) + : this(elements.AsEnumerable()) { } /// /// Initializes a new instance of the class. /// - /// The collection from which elements should be drawn from. - /// It must contain at least one element. public ElementsBuilder(IEnumerable elements) { if (elements == null) throw new ArgumentNullException(nameof(elements)); @@ -34,13 +31,15 @@ public ElementsBuilder(IEnumerable elements) this.elements = elements.ToArray(); if (this.elements.Length < 1) + { throw new ArgumentException( "The supplied collection of elements must contain at least one element. " + "This collection is expected to contain the elements from which the randomized algorithm will draw; " + "if the collection is empty, there are no elements to draw.", nameof(elements)); + } - //The RandomNumericSequenceGenerator is only created for collections of minimum 2 elements + // The RandomNumericSequenceGenerator is only created for collections of minimum 2 elements if (this.elements.Length > 1) this.sequence = new RandomNumericSequenceGenerator(0, this.elements.Length - 1); } diff --git a/Src/AutoFixture/EmailAddressLocalPart.cs b/Src/AutoFixture/EmailAddressLocalPart.cs index 94fc4c10a..09e574a96 100644 --- a/Src/AutoFixture/EmailAddressLocalPart.cs +++ b/Src/AutoFixture/EmailAddressLocalPart.cs @@ -4,15 +4,15 @@ namespace AutoFixture { #if SYSTEM_NET_MAIL /// - /// Represents the local part of the email address, defined as everything up to, but not including, the @ sign. + /// Represents the local part of the email address, defined as everything up to, but not including, the @ sign. /// Since EmailAddressLocalPart is used in constructing MailAddress, enforcement of rules on a valid email address - /// is performed by and not EmailAddressLocalPart other than as noted. + /// is performed by and not EmailAddressLocalPart other than as noted. /// #else /// - /// Represents the local part of the email address, defined as everything up to, but not including, the @ sign. + /// Represents the local part of the email address, defined as everything up to, but not including, the @ sign. /// Since EmailAddressLocalPart is used in constructing MailAddress, enforcement of rules on a valid email address - /// is performed by System.Net.Mail.MailAddress and not EmailAddressLocalPart other than as noted. + /// is performed by System.Net.Mail.MailAddress and not EmailAddressLocalPart other than as noted. /// #endif public class EmailAddressLocalPart @@ -21,7 +21,7 @@ public class EmailAddressLocalPart /// Initializes a new instance of the class. Throws ArgumentNullException /// if localPart is null. Throws ArgumentException if localPart is empty. /// - /// The local part. + /// The local part. public EmailAddressLocalPart(string localPart) { if (localPart == null) throw new ArgumentNullException(nameof(localPart)); @@ -36,12 +36,12 @@ public EmailAddressLocalPart(string localPart) public string LocalPart { get; } /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// - /// The to compare with this instance. + /// The to compare with this instance. /// /// - /// true if the specified is equal to this instance; + /// true if the specified is equal to this instance; /// otherwise, false. /// /// @@ -61,8 +61,8 @@ public override bool Equals(object obj) /// Returns a hash code for this instance. /// /// - /// A hash code for this instance, suitable for use in hashing algorithms and data - /// structures like a hash table. + /// A hash code for this instance, suitable for use in hashing algorithms and data + /// structures like a hash table. /// public override int GetHashCode() { @@ -70,10 +70,10 @@ public override int GetHashCode() } /// - /// Returns a that represents the local part for this instance. + /// Returns a that represents the local part for this instance. /// /// - /// A that represents the local part for this instance. + /// A that represents the local part for this instance. /// public override string ToString() { diff --git a/Src/AutoFixture/EmailAddressLocalPartGenerator.cs b/Src/AutoFixture/EmailAddressLocalPartGenerator.cs index 25788d802..d8fc03b0e 100644 --- a/Src/AutoFixture/EmailAddressLocalPartGenerator.cs +++ b/Src/AutoFixture/EmailAddressLocalPartGenerator.cs @@ -11,7 +11,7 @@ public class EmailAddressLocalPartGenerator : ISpecimenBuilder /// /// Creates a new specimen based on a request. /// - /// The request that describes what to create + /// The request that describes what to create. /// A context that can be used to create other specimens. /// /// The requested specimen if possible; otherwise a instance. @@ -33,6 +33,6 @@ public object Create(object request, ISpecimenContext context) } return new EmailAddressLocalPart(localPart); - } + } } } diff --git a/Src/AutoFixture/EnumGenerator.cs b/Src/AutoFixture/EnumGenerator.cs index a3dd286b3..3f66dfd17 100644 --- a/Src/AutoFixture/EnumGenerator.cs +++ b/Src/AutoFixture/EnumGenerator.cs @@ -46,7 +46,7 @@ public EnumGenerator() public object Create(object request, ISpecimenContext context) { var type = request as Type; - if(type == null) + if (type == null) return new NoSpecimen(); if (!type.GetTypeInfo().IsEnum) @@ -76,7 +76,7 @@ private IEnumerator EnsureGenerator(Type t) return enumerator; } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "This is not a usual enumerable and for our purpose generic interface is not required.")] private class RoundRobinEnumEnumerable : IEnumerable { diff --git a/Src/AutoFixture/Fixture.cs b/Src/AutoFixture/Fixture.cs index 8075200ff..2126d4f02 100644 --- a/Src/AutoFixture/Fixture.cs +++ b/Src/AutoFixture/Fixture.cs @@ -15,7 +15,7 @@ namespace AutoFixture /// /// Provides object creation services. /// - [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", + [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Fixture is coupled to many other types, because it embodies rules for creating various well-known types from the base class library.")] [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "The main purpose of Fixture isn't to be a collection of anything." + @@ -57,7 +57,7 @@ public Fixture(DefaultRelays engineParts) /// /// The engine. /// The definition and implementation of 'many'. - [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", + [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "This is the Façade that binds everything else together, so being coupled to many other types must follow.")] public Fixture(ISpecimenBuilder engine, MultipleRelay multiple) { @@ -79,9 +79,7 @@ public Fixture(ISpecimenBuilder engine, MultipleRelay multiple) typeof(IFixture)), new ExactTypeSpecification( typeof(ISpecimenBuilder)))), - new StableFiniteSequenceRelay(), - MakeQueryBasedBuilderForMatchingType( typeof(Dictionary<,>), new ModestConstructorQuery(), @@ -109,21 +107,18 @@ public Fixture(ISpecimenBuilder engine, MultipleRelay multiple) MakeQueryBasedBuilderForMatchingType( typeof(ObservableCollection<>), new EnumerableFavoringConstructorQuery()), - new FilteringSpecimenBuilder( new MethodInvoker( new ModestConstructorQuery()), new NullableEnumRequestSpecification()), new EnumGenerator(), new LambdaExpressionGenerator(), - MakeFixedBuilder( CultureInfo.InvariantCulture), MakeFixedBuilder( Encoding.UTF8), MakeFixedBuilder( IPAddress.Loopback), - new DataAnnotationsSupportNode( new CompositeSpecimenBuilder( new RangeAttributeRelay(), @@ -172,7 +167,7 @@ public Fixture(ISpecimenBuilder engine, MultipleRelay multiple) new NoConstructorsSpecification()))))); this.UpdateGraphAndSetupAdapters(newGraph, Enumerable.Empty()); - + this.Behaviors.Add(new ThrowingRecursionBehavior()); } @@ -204,11 +199,11 @@ public bool OmitAutoProperties set { IRequestSpecification newSpecification = value - ? (IRequestSpecification) new FalseRequestSpecification() + ? (IRequestSpecification)new FalseRequestSpecification() : new AnyTypeSpecification(); var existingPostProcessor = this.FindAutoPropertiesPostProcessor(); - + // Optimization. Do nothing if no change is required (i.e. you set property to its current value). if (existingPostProcessor.Specification.GetType() == newSpecification.GetType()) return; @@ -241,7 +236,7 @@ public int RepeatCount public IList ResidueCollectors => this.residueCollector; /// - [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", + [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "This method is required to be generic by design, so there is no way to refactor it.")] public ICustomizationComposer Build() { @@ -348,8 +343,8 @@ private void UpdateBehaviors(ISpecimenBuilderTransformation[] existingTransforma private Postprocessor FindAutoPropertiesPostProcessor() { - var postprocessorHolder = (AutoPropertiesTarget) this.graph.FindFirstNode(b => b is AutoPropertiesTarget); - return (Postprocessor) postprocessorHolder.Builder; + var postprocessorHolder = (AutoPropertiesTarget)this.graph.FindFirstNode(b => b is AutoPropertiesTarget); + return (Postprocessor)postprocessorHolder.Builder; } private static ISpecimenBuilder MakeFixedBuilder(T value) diff --git a/Src/AutoFixture/FixtureRegistrar.cs b/Src/AutoFixture/FixtureRegistrar.cs index e63978bec..0cb72cc87 100644 --- a/Src/AutoFixture/FixtureRegistrar.cs +++ b/Src/AutoFixture/FixtureRegistrar.cs @@ -58,10 +58,10 @@ public static class FixtureRegistrar /// var fixture = new Fixture(); /// var original = new MyClass(); /// fixture.Inject(original); - /// + /// /// var actual1 = fixture.Create<MyClass>(); /// var actual2 = fixture.Create<MyClass>(); - /// + /// /// // actual1 and actual2 are equal, and equal to original /// Assert.Same(actual1, actual2); /// Assert.Same(original, actual1); diff --git a/Src/AutoFixture/FixtureRepeater.cs b/Src/AutoFixture/FixtureRepeater.cs index ca16de620..09d557028 100644 --- a/Src/AutoFixture/FixtureRepeater.cs +++ b/Src/AutoFixture/FixtureRepeater.cs @@ -16,7 +16,7 @@ public static class FixtureRepeater /// The type of object that creates. /// /// - /// The to use + /// The to use. /// /// /// A function that creates an instance of . diff --git a/Src/AutoFixture/FreezingCustomization.cs b/Src/AutoFixture/FreezingCustomization.cs index 98f09e9f8..a27ee75cd 100644 --- a/Src/AutoFixture/FreezingCustomization.cs +++ b/Src/AutoFixture/FreezingCustomization.cs @@ -43,7 +43,7 @@ public FreezingCustomization(Type targetType, Type registeredType) if (!registeredType.GetTypeInfo().IsAssignableFrom(targetType)) { - var message = String.Format( + var message = string.Format( CultureInfo.CurrentCulture, "The type '{0}' cannot be frozen as '{1}' because the two types are not compatible.", targetType, @@ -84,7 +84,7 @@ public void Customize(IFixture fixture) var types = new[] { this.TargetType, - this.RegisteredType + this.RegisteredType }; var builder = new CompositeSpecimenBuilder( diff --git a/Src/AutoFixture/Generator.cs b/Src/AutoFixture/Generator.cs index 44651d299..1622f4170 100644 --- a/Src/AutoFixture/Generator.cs +++ b/Src/AutoFixture/Generator.cs @@ -31,7 +31,7 @@ public class Generator : IEnumerable /// A builder which is used to generate items. /// /// - /// is null + /// is null. /// public Generator(ISpecimenBuilder builder) { diff --git a/Src/AutoFixture/GlobalSuppressions.cs b/Src/AutoFixture/GlobalSuppressions.cs index dc2de8b21..364369634 100644 --- a/Src/AutoFixture/GlobalSuppressions.cs +++ b/Src/AutoFixture/GlobalSuppressions.cs @@ -1,10 +1,10 @@ -// This file is used by Code Analysis to maintain SuppressMessage +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. -// Project-level suppressions either have no target or are given +// Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. // -// To add a suppression to this file, right-click the message in the -// Error List, point to "Suppress Message(s)", and click +// To add a suppression to this file, right-click the message in the +// Error List, point to "Suppress Message(s)", and click // "In Project Suppression File". // You do not need to add suppressions to this file manually. diff --git a/Src/AutoFixture/GuidGenerator.cs b/Src/AutoFixture/GuidGenerator.cs index 1f84b0c2f..e4e43691c 100644 --- a/Src/AutoFixture/GuidGenerator.cs +++ b/Src/AutoFixture/GuidGenerator.cs @@ -11,7 +11,6 @@ public class GuidGenerator : ISpecimenBuilder /// /// Creates a new instance. /// - /// A new instance. [Obsolete("Please use the Create(request, context) method as this overload will be removed to make API uniform.")] public static Guid Create() { @@ -21,23 +20,13 @@ public static Guid Create() /// /// Creates a new instance. /// - /// Obsolete Please move over to using Create() as this method will be removed in the next release - /// A new instance. [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] public static Guid CreateAnonymous() { return Create(); } - /// - /// Creates a new instance. - /// - /// The request that describes what to create. - /// Not used. - /// - /// A new instance, if is a request for a - /// ; otherwise, a instance. - /// + /// public object Create(object request, ISpecimenContext context) { if (!typeof(Guid).Equals(request)) diff --git a/Src/AutoFixture/IFixture.cs b/Src/AutoFixture/IFixture.cs index 188c4dc9b..93a1b66ef 100644 --- a/Src/AutoFixture/IFixture.cs +++ b/Src/AutoFixture/IFixture.cs @@ -34,7 +34,7 @@ public interface IFixture : ISpecimenBuilder IList Customizations { get; } /// - /// Gets or sets if writable properties should generally be assigned a value when + /// Gets or sets if writable properties should generally be assigned a value when /// generating an anonymous object. /// bool OmitAutoProperties { get; set; } @@ -43,7 +43,7 @@ public interface IFixture : ISpecimenBuilder /// Gets or sets a number that controls how many objects are created when a /// creates more than one anonymous objects. /// - /// + /// /// /// int RepeatCount { get; set; } diff --git a/Src/AutoFixture/Int16SequenceGenerator.cs b/Src/AutoFixture/Int16SequenceGenerator.cs index bf1807a39..6908bc876 100644 --- a/Src/AutoFixture/Int16SequenceGenerator.cs +++ b/Src/AutoFixture/Int16SequenceGenerator.cs @@ -36,7 +36,7 @@ public short Create() /// Creates an anonymous number. /// /// The next number in a consecutive sequence. - /// /// Obsolete: Please move over to using Create() as this method will be removed in the next release + /// /// Obsolete: Please move over to using Create() as this method will be removed in the next release. [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] public short CreateAnonymous() { diff --git a/Src/AutoFixture/Int32SequenceGenerator.cs b/Src/AutoFixture/Int32SequenceGenerator.cs index 4ae6cdf25..17c2ba7dc 100644 --- a/Src/AutoFixture/Int32SequenceGenerator.cs +++ b/Src/AutoFixture/Int32SequenceGenerator.cs @@ -24,7 +24,7 @@ public int Create() /// /// Creates an anonymous number. /// - /// Obsolete: Please move over to using Create() as this method will be removed in the next release + /// Obsolete: Please move over to using Create() as this method will be removed in the next release. /// The next number in a consecutive sequence. [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] public int CreateAnonymous() diff --git a/Src/AutoFixture/Int64SequenceGenerator.cs b/Src/AutoFixture/Int64SequenceGenerator.cs index a4d8f032e..ded5ec4a4 100644 --- a/Src/AutoFixture/Int64SequenceGenerator.cs +++ b/Src/AutoFixture/Int64SequenceGenerator.cs @@ -24,7 +24,7 @@ public long Create() /// /// Creates an anonymous number. /// - /// Obsolete: Please move over to using Create() as this method will be removed in the next release + /// Obsolete: Please move over to using Create() as this method will be removed in the next release. /// The next number in a consecutive sequence. [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] public long CreateAnonymous() diff --git a/Src/AutoFixture/InvariantCultureGenerator.cs b/Src/AutoFixture/InvariantCultureGenerator.cs index b6ceb99de..aa83c0947 100644 --- a/Src/AutoFixture/InvariantCultureGenerator.cs +++ b/Src/AutoFixture/InvariantCultureGenerator.cs @@ -5,14 +5,14 @@ namespace AutoFixture { /// - /// Handles creation requests for instances, + /// Handles creation requests for instances, /// returning always the same . /// [Obsolete("Please use a 'AutoFixture.Kernel.FilteringSpecimenBuilder' instead.", true)] public class InvariantCultureGenerator : ISpecimenBuilder { - private readonly ExactTypeSpecification cultureTypeSpecification - = new ExactTypeSpecification(typeof (CultureInfo)); + private readonly ExactTypeSpecification cultureTypeSpecification + = new ExactTypeSpecification(typeof(CultureInfo)); /// /// Generates a CultureInfo specimen based on a type request. @@ -31,7 +31,7 @@ public object Create(object request, ISpecimenContext context) return new NoSpecimen(); if (!this.cultureTypeSpecification.IsSatisfiedBy(request)) - return new NoSpecimen(); ; + return new NoSpecimen(); return CultureInfo.InvariantCulture; } diff --git a/Src/AutoFixture/Kernel/ActionSpecimenCommand.cs b/Src/AutoFixture/Kernel/ActionSpecimenCommand.cs index 1d0f0d253..52138c608 100644 --- a/Src/AutoFixture/Kernel/ActionSpecimenCommand.cs +++ b/Src/AutoFixture/Kernel/ActionSpecimenCommand.cs @@ -3,7 +3,7 @@ namespace AutoFixture.Kernel { /// - /// Adapts an action delegate to + /// Adapts an action delegate to . /// /// /// The type of specimen operated on by the adapted action delegate. diff --git a/Src/AutoFixture/Kernel/ArrayRelay.cs b/Src/AutoFixture/Kernel/ArrayRelay.cs index 9b23ef99b..377e06a76 100644 --- a/Src/AutoFixture/Kernel/ArrayRelay.cs +++ b/Src/AutoFixture/Kernel/ArrayRelay.cs @@ -54,7 +54,7 @@ private static object ToArray(IEnumerable elements, Type elementType) var count = (collection != null) ? collection.Count : elements.Cast().Count(); var array = Array.CreateInstance(elementType, count); int index = 0; - foreach(var element in elements) + foreach (var element in elements) { array.SetValue(element, index); index++; diff --git a/Src/AutoFixture/Kernel/AutoPropertiesCommand.cs b/Src/AutoFixture/Kernel/AutoPropertiesCommand.cs index e500903e4..6e9cd4cd0 100644 --- a/Src/AutoFixture/Kernel/AutoPropertiesCommand.cs +++ b/Src/AutoFixture/Kernel/AutoPropertiesCommand.cs @@ -5,6 +5,7 @@ namespace AutoFixture.Kernel { +#pragma warning disable SA1402 // File may only contain a single type /// /// A command that assigns anonymous values to all writable properties and fields of a type. /// @@ -13,7 +14,7 @@ public class AutoPropertiesCommand : AutoPropertiesCommand #pragma warning restore 618 { /// - /// The explicitly specified that should be used to resolve fields and properties + /// The explicitly specified that should be used to resolve fields and properties /// to populate for the specimen. /// /// @@ -23,7 +24,7 @@ public class AutoPropertiesCommand : AutoPropertiesCommand /// /// public Type ExplicitSpecimenType { get; } - + /// /// Initializes a new instance of the class. /// @@ -140,7 +141,7 @@ public AutoPropertiesCommand(IRequestSpecification specification) } /// - /// Assigns anonymous values to properties and fields on a specimen + /// Assigns anonymous values to properties and fields on a specimen. /// /// /// The specimen on which property and field values will be assigned. @@ -239,15 +240,8 @@ private IEnumerable GetProperties(object specimen) } /// - /// Assigns anonymous values to properties and fields on a specimen + /// Assigns anonymous values to properties and fields on a specimen. /// - /// - /// The specimen on which property and field values will be assigned. - /// - /// - /// An that is used to create property - /// and field values. - /// public void Execute(object specimen, ISpecimenContext context) { if (specimen == null) @@ -270,4 +264,5 @@ public void Execute(object specimen, ISpecimenContext context) } } } +#pragma warning restore SA1402 // File may only contain a single type } diff --git a/Src/AutoFixture/Kernel/BindingCommand.cs b/Src/AutoFixture/Kernel/BindingCommand.cs index eda5f859d..5a98aecb2 100644 --- a/Src/AutoFixture/Kernel/BindingCommand.cs +++ b/Src/AutoFixture/Kernel/BindingCommand.cs @@ -165,7 +165,7 @@ private TProperty CreateAnonymousValue(ISpecimenContext container) /// /// /// - /// This method assigns a value to the property or field identified by + /// This method assigns a value to the property or field identified by /// the expression supplied to the class' constructor. If no value (or /// creator) was supplied to the constructor, /// will be used to create the value. @@ -180,19 +180,23 @@ public void Execute(object specimen, ISpecimenContext context) var pi = this.Member as PropertyInfo; if (pi != null) + { TrySetValue( specimen, bindingValue, pi.PropertyType, (s, v) => pi.SetValue(s, v, null)); + } var fi = this.Member as FieldInfo; if (fi != null) + { TrySetValue( specimen, bindingValue, fi.FieldType, (s, v) => fi.SetValue(s, v)); + } } private static void TrySetValue( @@ -207,15 +211,15 @@ public void Execute(object specimen, ISpecimenContext context) } catch (ArgumentException) { - if (value is IConvertible) - setValue( - specimen, - Convert.ChangeType( - value, - targetType, - CultureInfo.CurrentCulture)); - else + if (!(value is IConvertible)) throw; + + setValue( + specimen, + Convert.ChangeType( + value, + targetType, + CultureInfo.CurrentCulture)); } } } diff --git a/Src/AutoFixture/Kernel/CollectionRelay.cs b/Src/AutoFixture/Kernel/CollectionRelay.cs index 2702c8755..766886252 100644 --- a/Src/AutoFixture/Kernel/CollectionRelay.cs +++ b/Src/AutoFixture/Kernel/CollectionRelay.cs @@ -39,8 +39,8 @@ public object Create(object request, ISpecimenContext context) var typeArguments = type.GetTypeInfo().GetGenericArguments(); if (typeArguments.Length != 1) return new NoSpecimen(); var gtd = type.GetGenericTypeDefinition(); - if (gtd != typeof (ICollection<>)) return new NoSpecimen(); - return context.Resolve(typeof (List<>).MakeGenericType(typeArguments)); + if (gtd != typeof(ICollection<>)) return new NoSpecimen(); + return context.Resolve(typeof(List<>).MakeGenericType(typeArguments)); } } } diff --git a/Src/AutoFixture/Kernel/CompositeSpecimenBuilder.cs b/Src/AutoFixture/Kernel/CompositeSpecimenBuilder.cs index 67968dd26..90397935d 100644 --- a/Src/AutoFixture/Kernel/CompositeSpecimenBuilder.cs +++ b/Src/AutoFixture/Kernel/CompositeSpecimenBuilder.cs @@ -52,7 +52,7 @@ public object Create(object request, ISpecimenContext context) var result = this.composedBuilders[i].Create(request, context); if (!(result is NoSpecimen)) return result; } - + return new NoSpecimen(); } @@ -97,7 +97,6 @@ internal static ISpecimenBuilder ComposeIfMultiple(IEnumerable // It's optimized to not perform unnecessary allocations and do not enumerate builders more than once. // Code is written expecting that single builder is the most common case. // See more detail here: https://github.com/AutoFixture/AutoFixture/pull/793 - ISpecimenBuilder singleItem = null; List multipleItems = null; bool hasItems = false; @@ -115,9 +114,9 @@ internal static ISpecimenBuilder ComposeIfMultiple(IEnumerable // When we create collection for multiple items, we add the already enumerated one as well. if (multipleItems == null) { - multipleItems = new List {singleItem}; + multipleItems = new List { singleItem }; } - + multipleItems.Add(enumerator.Current); } } diff --git a/Src/AutoFixture/Kernel/ConstrainedStringRequest.cs b/Src/AutoFixture/Kernel/ConstrainedStringRequest.cs index 8d7378660..19077e45c 100644 --- a/Src/AutoFixture/Kernel/ConstrainedStringRequest.cs +++ b/Src/AutoFixture/Kernel/ConstrainedStringRequest.cs @@ -53,11 +53,11 @@ public ConstrainedStringRequest(int maximumLength) public int MaximumLength { get; } /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// - /// The to compare with this instance. + /// The to compare with this instance. /// - /// true if the specified is equal to this instance; otherwise, false. + /// true if the specified is equal to this instance; otherwise, false. /// /// /// The parameter is null. @@ -80,7 +80,7 @@ public override bool Equals(object obj) /// public override int GetHashCode() { - return this.MinimumLength.GetHashCode() + return this.MinimumLength.GetHashCode() ^ this.MaximumLength.GetHashCode(); } diff --git a/Src/AutoFixture/Kernel/ConstructorMethod.cs b/Src/AutoFixture/Kernel/ConstructorMethod.cs index a02a13a59..0e7ea03d2 100644 --- a/Src/AutoFixture/Kernel/ConstructorMethod.cs +++ b/Src/AutoFixture/Kernel/ConstructorMethod.cs @@ -29,7 +29,7 @@ public ConstructorMethod(ConstructorInfo constructor) public ConstructorInfo Constructor { get; } /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// /// The to compare with this instance. /// @@ -50,7 +50,7 @@ public override bool Equals(object obj) /// /// /// A hash code for this instance, suitable for use in hashing algorithms and data - /// structures like a hash table. + /// structures like a hash table. /// public override int GetHashCode() { @@ -92,10 +92,7 @@ class TestDouble : AbstractClassWithPublicConstructor typeof(TestDouble))); This will cause AutoFixture to create an instance of TestDouble every time AbstractClassWithPublicConstructor is requested. However, please keep in mind that this is only a workaround for the case where you can't address the root cause, which is that an abstract class has a public constructor.", - this.Constructor.DeclaringType.Name - ) - ); - + this.Constructor.DeclaringType.Name)); } return this.Constructor.Invoke(parameters.ToArray()); } diff --git a/Src/AutoFixture/Kernel/Criterion.cs b/Src/AutoFixture/Kernel/Criterion.cs index 94fc4a52f..cee131a04 100644 --- a/Src/AutoFixture/Kernel/Criterion.cs +++ b/Src/AutoFixture/Kernel/Criterion.cs @@ -5,7 +5,7 @@ namespace AutoFixture.Kernel { /// /// Serves as a criterion against which a value can be compared. When a - /// given value equals the criterion, it can be said to match the + /// given value equals the criterion, it can be said to match the /// criterion; otherwise not. /// /// The type of values being compared. diff --git a/Src/AutoFixture/Kernel/DelegateGenerator.cs b/Src/AutoFixture/Kernel/DelegateGenerator.cs index 784c5df7b..c275b78c2 100644 --- a/Src/AutoFixture/Kernel/DelegateGenerator.cs +++ b/Src/AutoFixture/Kernel/DelegateGenerator.cs @@ -19,7 +19,8 @@ public class DelegateGenerator : ISpecimenBuilder /// /// Creates a new instance of the type. /// - public DelegateGenerator() : this(new DelegateSpecification()) + public DelegateGenerator() + : this(new DelegateSpecification()) { } @@ -49,7 +50,7 @@ public object Create(object request, ISpecimenContext context) if (delegateType == null) return new NoSpecimen(); - if(!this.Specification.IsSatisfiedBy(delegateType)) + if (!this.Specification.IsSatisfiedBy(delegateType)) return new NoSpecimen(); var delegateMethod = delegateType.GetTypeInfo().GetMethod("Invoke"); diff --git a/Src/AutoFixture/Kernel/DisposableTracker.cs b/Src/AutoFixture/Kernel/DisposableTracker.cs index be7db787c..d1b7b5f02 100644 --- a/Src/AutoFixture/Kernel/DisposableTracker.cs +++ b/Src/AutoFixture/Kernel/DisposableTracker.cs @@ -138,7 +138,7 @@ protected virtual void Dispose(bool disposing) { if (disposing) { - foreach(var d in this.Disposables) + foreach (var d in this.Disposables) { d.Dispose(); } diff --git a/Src/AutoFixture/Kernel/EnumerableRelay.cs b/Src/AutoFixture/Kernel/EnumerableRelay.cs index 62c4e7cd0..489981b82 100644 --- a/Src/AutoFixture/Kernel/EnumerableRelay.cs +++ b/Src/AutoFixture/Kernel/EnumerableRelay.cs @@ -38,7 +38,7 @@ public object Create(object request, ISpecimenContext context) if (type == null) return new NoSpecimen(); - if(!type.TryGetSingleGenericTypeArgument(typeof(IEnumerable<>), out Type enumerableType)) + if (!type.TryGetSingleGenericTypeArgument(typeof(IEnumerable<>), out Type enumerableType)) return new NoSpecimen(); var specimen = context.Resolve(new MultipleRequest(enumerableType)); @@ -67,8 +67,10 @@ public ConvertedEnumerable(IEnumerable enumerable) public IEnumerator GetEnumerator() { foreach (var item in this.enumerable) + { if (item is T variable) yield return variable; + } } IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator(); diff --git a/Src/AutoFixture/Kernel/EnumeratorRelay.cs b/Src/AutoFixture/Kernel/EnumeratorRelay.cs index bdb597636..77c80e965 100644 --- a/Src/AutoFixture/Kernel/EnumeratorRelay.cs +++ b/Src/AutoFixture/Kernel/EnumeratorRelay.cs @@ -5,7 +5,7 @@ namespace AutoFixture.Kernel { /// - /// Relays a request for to + /// Relays a request for to /// and converts the result to an enumerator /// of a sequence of the requested type. /// @@ -21,12 +21,12 @@ public class EnumeratorRelay : ISpecimenBuilder /// A context that can be used to create other specimens. /// /// - /// An enumerator of the requested type if possible; otherwise a + /// An enumerator of the requested type if possible; otherwise a /// instance. /// /// /// - /// If is a request for an + /// If is a request for an /// and can /// satisfy an request for the /// element type, the return value is an enumerator of the @@ -45,35 +45,28 @@ public object Create(object request, ISpecimenContext context) if (!type.TryGetSingleGenericTypeArgument(typeof(IEnumerator<>), out Type enumeratorType)) return new NoSpecimen(); - var specimenBuilder = (ISpecimenBuilder) Activator.CreateInstance( - typeof (EnumeratorRelay<>).MakeGenericType(enumeratorType)); - return specimenBuilder.Create(request, context); + var specimenBuilder = (IEnumeratorBuilder)Activator.CreateInstance( + typeof(GenericEnumeratorRelay<>).MakeGenericType(enumeratorType)); + return specimenBuilder.Create(context); } - } - [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", - Justification = "It's activated via reflection.")] - internal class EnumeratorRelay : ISpecimenBuilder - { - public object Create(object request, ISpecimenContext context) + private interface IEnumeratorBuilder { - if (context == null) throw new ArgumentNullException(nameof(context)); - - var t = request as Type; - if (t == null) - return new NoSpecimen(); - - if (t != typeof(IEnumerator)) - return new NoSpecimen(); + object Create(ISpecimenContext context); + } - var enumerable = - context.Resolve(typeof (IEnumerable)) as IEnumerable; + [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", + Justification = "It's activated via reflection.")] + private class GenericEnumeratorRelay : IEnumeratorBuilder + { + public object Create(ISpecimenContext context) + { + var result = context.Resolve(typeof(IEnumerable)); + if (result is IEnumerable enumerable) + return enumerable.GetEnumerator(); - if (enumerable == null) return new NoSpecimen(); - - return enumerable.GetEnumerator(); + } } } } - diff --git a/Src/AutoFixture/Kernel/EqualRequestSpecification.cs b/Src/AutoFixture/Kernel/EqualRequestSpecification.cs index 2400a3464..9775310f8 100644 --- a/Src/AutoFixture/Kernel/EqualRequestSpecification.cs +++ b/Src/AutoFixture/Kernel/EqualRequestSpecification.cs @@ -10,31 +10,16 @@ namespace AutoFixture.Kernel public class EqualRequestSpecification : IRequestSpecification { /// - /// Initializes a new instance of the - /// class. + /// Initializes a new instance of the class. /// - /// The expected target. - /// - /// - /// target public EqualRequestSpecification(object target) : this(target, EqualityComparer.Default) { } /// - /// Initializes a new instance of the - /// class. + /// Initializes a new instance of the class. /// - /// The expected target. - /// - /// The comparer used to evaluate whether a request is equal to - /// . - /// - /// - /// - /// target - /// comparer public EqualRequestSpecification(object target, IEqualityComparer comparer) { this.Target = target ?? throw new ArgumentNullException(nameof(target)); @@ -42,14 +27,8 @@ public EqualRequestSpecification(object target, IEqualityComparer comparer) } /// - /// Evaluates whether a request for a specimen is equal to the expected - /// target. + /// Evaluates whether a request for a specimen is equal to the expected target. /// - /// The specimen request. - /// - /// if is equal to - /// ; otherwise, . - /// public bool IsSatisfiedBy(object request) { return this.Comparer.Equals(this.Target, request); @@ -58,21 +37,11 @@ public bool IsSatisfiedBy(object request) /// /// Gets the expected target. /// - /// - /// The expected target, originally supplied via the constructor. - /// - /// - /// public object Target { get; } /// - /// Gets the equality comparer used to compare a request to the - /// expected target. + /// Gets the equality comparer used to compare a request to the expected target. /// - /// - /// The equality comparer, optionally supplied via a constructor. - /// - /// public IEqualityComparer Comparer { get; } } } diff --git a/Src/AutoFixture/Kernel/ExactTypeSpecification.cs b/Src/AutoFixture/Kernel/ExactTypeSpecification.cs index ecfac723f..cec6f836b 100644 --- a/Src/AutoFixture/Kernel/ExactTypeSpecification.cs +++ b/Src/AutoFixture/Kernel/ExactTypeSpecification.cs @@ -4,7 +4,7 @@ namespace AutoFixture.Kernel { /// - /// A specification that evaluates requests for types against a target type. + /// A specification that evaluates requests for types against a target type. /// Also matches generic type requests agains the specified open generic. /// public class ExactTypeSpecification : IRequestSpecification diff --git a/Src/AutoFixture/Kernel/ExpressionReflector.cs b/Src/AutoFixture/Kernel/ExpressionReflector.cs index 7a05a64c5..c7e83e41c 100644 --- a/Src/AutoFixture/Kernel/ExpressionReflector.cs +++ b/Src/AutoFixture/Kernel/ExpressionReflector.cs @@ -16,10 +16,12 @@ internal static MemberExpression GetWritableMember(this LambdaExpression propert // expression may be (x => Convert(x.Property)) and we need to unwrap it. var memberExpr = bodyExpr.UnwrapIfConversionExpression() as MemberExpression; if (memberExpr == null) + { throw new ArgumentException( "The expression's Body is not a MemberExpression. " + "Most likely this is because it does not represent access to a property or field.", nameof(propertyPicker)); + } if (memberExpr.Member is PropertyInfo pi && pi.GetSetMethod() == null) { @@ -43,10 +45,12 @@ internal static void VerifyIsNonNestedWritableMemberExpression(LambdaExpression var parameterExpression = argExpression as ParameterExpression; if (parameterExpression == null) + { throw new ArgumentException( "The expression contains access to a nested property or field. " + "Configuration API doesn't support this feature, therefore please rewrite the expression to avoid nested fields or properties.", nameof(expression)); + } } /// diff --git a/Src/AutoFixture/Kernel/FactoryMethodQuery.cs b/Src/AutoFixture/Kernel/FactoryMethodQuery.cs index c399a511c..cc62c1fdc 100644 --- a/Src/AutoFixture/Kernel/FactoryMethodQuery.cs +++ b/Src/AutoFixture/Kernel/FactoryMethodQuery.cs @@ -29,7 +29,7 @@ public class FactoryMethodQuery : IMethodQuery /// unspecified. /// /// - /// Factory methods that contain parameters of the requested + /// Factory methods that contain parameters of the requested /// are skipped in order to avoid circular references. /// /// diff --git a/Src/AutoFixture/Kernel/FieldTypeAndNameCriterion.cs b/Src/AutoFixture/Kernel/FieldTypeAndNameCriterion.cs index fd8b6ad21..3f23b3a6d 100644 --- a/Src/AutoFixture/Kernel/FieldTypeAndNameCriterion.cs +++ b/Src/AutoFixture/Kernel/FieldTypeAndNameCriterion.cs @@ -91,7 +91,6 @@ public bool Equals(FieldInfo other) /// public override bool Equals(object obj) { - var other = obj as FieldTypeAndNameCriterion; if (other == null) return base.Equals(obj); @@ -103,10 +102,10 @@ public override bool Equals(object obj) /// /// Returns the hash code for the object. /// - /// The hash code + /// The hash code. public override int GetHashCode() { - return + return this.TypeCriterion.GetHashCode() ^ this.NameCriterion.GetHashCode(); } diff --git a/Src/AutoFixture/Kernel/FiniteSequenceRequest.cs b/Src/AutoFixture/Kernel/FiniteSequenceRequest.cs index 3792f50f7..ce21e60f1 100644 --- a/Src/AutoFixture/Kernel/FiniteSequenceRequest.cs +++ b/Src/AutoFixture/Kernel/FiniteSequenceRequest.cs @@ -29,11 +29,11 @@ public FiniteSequenceRequest(object request, int count) } /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// - /// The to compare with this instance. + /// The to compare with this instance. /// - /// if the specified is equal to this instance; + /// if the specified is equal to this instance; /// otherwise, . /// /// @@ -53,7 +53,7 @@ public override bool Equals(object obj) /// /// /// A hash code for this instance, suitable for use in hashing algorithms and data - /// structures like a hash table. + /// structures like a hash table. /// public override int GetHashCode() { diff --git a/Src/AutoFixture/Kernel/GenericMethod.cs b/Src/AutoFixture/Kernel/GenericMethod.cs index 9167ea9da..883d115c4 100644 --- a/Src/AutoFixture/Kernel/GenericMethod.cs +++ b/Src/AutoFixture/Kernel/GenericMethod.cs @@ -41,7 +41,7 @@ public GenericMethod(MethodInfo method, IMethodFactory factory) public MethodInfo Method { get; } /// - /// Gets information about the factory to create from + /// Gets information about the factory to create from. /// /// public IMethodFactory Factory { get; } diff --git a/Src/AutoFixture/Kernel/IMethodFactory.cs b/Src/AutoFixture/Kernel/IMethodFactory.cs index d83d99c7e..6550bcba3 100644 --- a/Src/AutoFixture/Kernel/IMethodFactory.cs +++ b/Src/AutoFixture/Kernel/IMethodFactory.cs @@ -1,12 +1,12 @@ using System.Reflection; namespace AutoFixture.Kernel -{ +{ /// /// Creates a new Method from a . /// public interface IMethodFactory - { + { /// /// Creates the method for the supplied methodInfo. /// diff --git a/Src/AutoFixture/Kernel/IllegalRequestException.cs b/Src/AutoFixture/Kernel/IllegalRequestException.cs index 83cd72ba1..169627faf 100644 --- a/Src/AutoFixture/Kernel/IllegalRequestException.cs +++ b/Src/AutoFixture/Kernel/IllegalRequestException.cs @@ -18,7 +18,7 @@ namespace AutoFixture.Kernel /// #if SYSTEM_RUNTIME_SERIALIZATION [Serializable] -#endif +#endif public class IllegalRequestException : Exception { /// diff --git a/Src/AutoFixture/Kernel/InstanceMethod.cs b/Src/AutoFixture/Kernel/InstanceMethod.cs index 9ca4170a1..182cec2ba 100644 --- a/Src/AutoFixture/Kernel/InstanceMethod.cs +++ b/Src/AutoFixture/Kernel/InstanceMethod.cs @@ -50,11 +50,11 @@ public InstanceMethod(MethodInfo instanceMethod, object owner) public object Owner { get; } /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// - /// The to compare with this instance. + /// The to compare with this instance. /// - /// if the specified is equal to this + /// if the specified is equal to this /// instance; otherwise, . /// /// @@ -74,7 +74,7 @@ public override bool Equals(object obj) /// /// /// A hash code for this instance, suitable for use in hashing algorithms and data - /// structures like a hash table. + /// structures like a hash table. /// public override int GetHashCode() { @@ -111,7 +111,7 @@ public bool Equals(InstanceMethod other) return false; } - return object.Equals(this.Method, other.Method) + return object.Equals(this.Method, other.Method) && object.Equals(this.Owner, other.Owner); } } diff --git a/Src/AutoFixture/Kernel/MemberInfoEqualityComparer.cs b/Src/AutoFixture/Kernel/MemberInfoEqualityComparer.cs index 84a92d9c9..33ea3a038 100644 --- a/Src/AutoFixture/Kernel/MemberInfoEqualityComparer.cs +++ b/Src/AutoFixture/Kernel/MemberInfoEqualityComparer.cs @@ -67,7 +67,7 @@ public bool Equals(MemberInfo x, MemberInfo y) /// The object. /// /// A hash code for the supplied instance, suitable for use in hashing algorithms and data - /// structures like a hash table. + /// structures like a hash table. /// /// /// The type of is a reference type and is @@ -125,7 +125,7 @@ int IEqualityComparer.GetHashCode(object obj) private static bool AreTypesRelated(Type x, Type y) { return x.GetTypeInfo().IsAssignableFrom(y) - || (y.GetTypeInfo().IsAssignableFrom(x)); + || y.GetTypeInfo().IsAssignableFrom(x); } } } diff --git a/Src/AutoFixture/Kernel/MissingParametersSupplyingMethod.cs b/Src/AutoFixture/Kernel/MissingParametersSupplyingMethod.cs index f5185ac43..c7db25fdb 100644 --- a/Src/AutoFixture/Kernel/MissingParametersSupplyingMethod.cs +++ b/Src/AutoFixture/Kernel/MissingParametersSupplyingMethod.cs @@ -6,21 +6,20 @@ namespace AutoFixture.Kernel { /// - /// Decorates another method invoking it supplying missing parameters + /// Decorates another method invoking it supplying missing parameters. /// public class MissingParametersSupplyingMethod : IMethod, IEquatable { /// /// Initializes a new instance of the class. /// - /// The to decorate. public MissingParametersSupplyingMethod(IMethod method) { this.Method = method ?? throw new ArgumentNullException(nameof(method)); } /// - /// Gets the decorated method + /// Gets the decorated method. /// public IMethod Method { get; } @@ -29,45 +28,20 @@ public MissingParametersSupplyingMethod(IMethod method) /// public IEnumerable Parameters => this.Method.Parameters; - /// - /// Determines whether the specified is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - /// - /// The parameter is null. - /// + /// public override bool Equals(object obj) { - if (obj is MissingParametersSupplyingMethod other) - { - return this.Equals(other); - } - return base.Equals(obj); + return obj is MissingParametersSupplyingMethod other && this.Equals(other); } - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data - /// structures like a hash table. - /// + /// public override int GetHashCode() { return this.Method.GetHashCode() ^ this.Parameters.Aggregate(0, (current, parameter) => current + parameter.GetHashCode()); } - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// An object to compare with this object. - /// - /// true if the current object is equal to the parameter; otherwise, false. - /// + /// public bool Equals(MissingParametersSupplyingMethod other) { if (other == null) @@ -79,8 +53,7 @@ public bool Equals(MissingParametersSupplyingMethod other) && this.Parameters.SequenceEqual(other.Parameters); } - private static IEnumerable GetArguments(IEnumerable parameters, - object[] arguments) + private static IEnumerable GetArguments(IEnumerable parameters, object[] arguments) { return parameters.Select((p, i) => arguments.Length > i ? arguments[i] : GetDefault(p)); } @@ -90,12 +63,12 @@ private static object GetDefault(ParameterInfo parameter) if (parameter.IsOptional) return parameter.DefaultValue; - if (parameter.IsDefined(typeof(ParamArrayAttribute), true) && + if (parameter.IsDefined(typeof(ParamArrayAttribute), true) && parameter.ParameterType.IsArray) return Array.CreateInstance(parameter.ParameterType.GetElementType(), 0); return parameter.ParameterType.GetTypeInfo().IsValueType ? - Activator.CreateInstance(parameter.ParameterType) : + Activator.CreateInstance(parameter.ParameterType) : null; } diff --git a/Src/AutoFixture/Kernel/MissingParametersSupplyingMethodFactory.cs b/Src/AutoFixture/Kernel/MissingParametersSupplyingMethodFactory.cs index 93ce0f951..3e3a29829 100644 --- a/Src/AutoFixture/Kernel/MissingParametersSupplyingMethodFactory.cs +++ b/Src/AutoFixture/Kernel/MissingParametersSupplyingMethodFactory.cs @@ -4,13 +4,13 @@ namespace AutoFixture.Kernel { /// - /// Creates a new for an + /// Creates a new for an /// instance . /// public class MissingParametersSupplyingMethodFactory : IMethodFactory { /// - /// Initializes a new instance of the + /// Initializes a new instance of the /// class. /// /// The owner. @@ -26,7 +26,7 @@ public MissingParametersSupplyingMethodFactory(object owner) public object Owner { get; } /// - /// Creates a decorated with + /// Creates a decorated with /// for the supplied methodInfo. /// /// The methodInfo. diff --git a/Src/AutoFixture/Kernel/MissingParametersSupplyingStaticMethodFactory.cs b/Src/AutoFixture/Kernel/MissingParametersSupplyingStaticMethodFactory.cs index fa3014b9f..f33c35f0a 100644 --- a/Src/AutoFixture/Kernel/MissingParametersSupplyingStaticMethodFactory.cs +++ b/Src/AutoFixture/Kernel/MissingParametersSupplyingStaticMethodFactory.cs @@ -1,7 +1,7 @@ using System.Reflection; namespace AutoFixture.Kernel -{ +{ /// /// Creates a new for a static /// . @@ -9,7 +9,7 @@ namespace AutoFixture.Kernel public class MissingParametersSupplyingStaticMethodFactory : IMethodFactory { /// - /// Creates a decorated with + /// Creates a decorated with /// for the supplied methodInfo. /// /// The methodInfo. diff --git a/Src/AutoFixture/Kernel/MultidimensionalArrayRelay.cs b/Src/AutoFixture/Kernel/MultidimensionalArrayRelay.cs index c1a2093c4..b4a77e15b 100644 --- a/Src/AutoFixture/Kernel/MultidimensionalArrayRelay.cs +++ b/Src/AutoFixture/Kernel/MultidimensionalArrayRelay.cs @@ -61,7 +61,7 @@ private static Type MakeJaggedArrayType(Type elementType, int dimension) Type jaggedArrayType = elementType; for (int i = 0; i < dimension; i++) jaggedArrayType = jaggedArrayType.MakeArrayType(); - + return jaggedArrayType; } diff --git a/Src/AutoFixture/Kernel/MultipleRequest.cs b/Src/AutoFixture/Kernel/MultipleRequest.cs index d9a75def4..527761460 100644 --- a/Src/AutoFixture/Kernel/MultipleRequest.cs +++ b/Src/AutoFixture/Kernel/MultipleRequest.cs @@ -35,10 +35,10 @@ public MultipleRequest(object request) public object Request { get; } /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// /// - /// The to compare with this instance. + /// The to compare with this instance. /// /// /// if is a diff --git a/Src/AutoFixture/Kernel/MultipleToEnumerableRelay.cs b/Src/AutoFixture/Kernel/MultipleToEnumerableRelay.cs index 172e4988c..038dcd2b8 100644 --- a/Src/AutoFixture/Kernel/MultipleToEnumerableRelay.cs +++ b/Src/AutoFixture/Kernel/MultipleToEnumerableRelay.cs @@ -25,13 +25,13 @@ public class MultipleToEnumerableRelay : ISpecimenBuilder /// instance. /// /// - /// context is null + /// context is null. /// /// /// /// The can be any object, but will often /// be a or other - /// instances. This + /// instances. This /// particular implementation only handles /// instances. /// must either be a Type @@ -44,7 +44,7 @@ public class MultipleToEnumerableRelay : ISpecimenBuilder public object Create(object request, ISpecimenContext context) { if (context == null) throw new ArgumentNullException(nameof(context)); - + var multipleRequest = request as MultipleRequest; if (multipleRequest == null) return new NoSpecimen(); diff --git a/Src/AutoFixture/Kernel/MutableValueTypeWarningThrower.cs b/Src/AutoFixture/Kernel/MutableValueTypeWarningThrower.cs index eff9603a7..06ef8dfc5 100644 --- a/Src/AutoFixture/Kernel/MutableValueTypeWarningThrower.cs +++ b/Src/AutoFixture/Kernel/MutableValueTypeWarningThrower.cs @@ -39,9 +39,7 @@ public object Create(object request, ISpecimenContext context) customization.Customize(fixture); For more information about mutable value types please refer to: http://tinyurl.com/pegtw57", - request, typeof(SupportMutableValueTypesCustomization).Name - ) - ); + request, typeof(SupportMutableValueTypesCustomization).Name)); } } } \ No newline at end of file diff --git a/Src/AutoFixture/Kernel/NoSpecimenOutputGuard.cs b/Src/AutoFixture/Kernel/NoSpecimenOutputGuard.cs index a11692a28..f86b78c18 100644 --- a/Src/AutoFixture/Kernel/NoSpecimenOutputGuard.cs +++ b/Src/AutoFixture/Kernel/NoSpecimenOutputGuard.cs @@ -12,7 +12,7 @@ namespace AutoFixture.Kernel public class NoSpecimenOutputGuard : ISpecimenBuilderNode { /// - /// Initializes a new instance of the class with an + /// Initializes a new instance of the class with an /// to decorate. /// /// The builder to decorate. @@ -70,7 +70,7 @@ public NoSpecimenOutputGuard(ISpecimenBuilder builder, IRequestSpecification spe public object Create(object request, ISpecimenContext context) { var result = this.Builder.Create(request, context); - if (result is NoSpecimen + if (result is NoSpecimen && this.Specification.IsSatisfiedBy(request)) { throw new ObjectCreationException(string.Format(CultureInfo.CurrentCulture, "The decorated ISpecimenBuilder could not create a specimen based on the request: {0}. This can happen if the request represents an interface or abstract class; if this is the case, register an ISpecimenBuilder that can create specimens based on the request. If this happens in a strongly typed Build expression, try supplying a factory using one of the IFactoryComposer methods.", request)); diff --git a/Src/AutoFixture/Kernel/OmitArrayParameterRequestRelay.cs b/Src/AutoFixture/Kernel/OmitArrayParameterRequestRelay.cs index 4a0d4b9e6..7952b4d13 100644 --- a/Src/AutoFixture/Kernel/OmitArrayParameterRequestRelay.cs +++ b/Src/AutoFixture/Kernel/OmitArrayParameterRequestRelay.cs @@ -47,7 +47,7 @@ public class OmitArrayParameterRequestRelay : ISpecimenBuilder /// /// /// - /// is + /// is . /// public object Create(object request, ISpecimenContext context) { @@ -66,9 +66,11 @@ public object Create(object request, ISpecimenContext context) pi.Name)); if (returnValue is OmitSpecimen) + { return Array.CreateInstance( pi.ParameterType.GetElementType(), 0); + } return returnValue; } diff --git a/Src/AutoFixture/Kernel/OmitEnumerableParameterRequestRelay.cs b/Src/AutoFixture/Kernel/OmitEnumerableParameterRequestRelay.cs index e4d449de0..4baa35c4c 100644 --- a/Src/AutoFixture/Kernel/OmitEnumerableParameterRequestRelay.cs +++ b/Src/AutoFixture/Kernel/OmitEnumerableParameterRequestRelay.cs @@ -48,7 +48,7 @@ public class OmitEnumerableParameterRequestRelay : ISpecimenBuilder /// /// /// - /// is + /// is . /// public object Create(object request, ISpecimenContext context) { diff --git a/Src/AutoFixture/Kernel/OmitOnRecursionHandler.cs b/Src/AutoFixture/Kernel/OmitOnRecursionHandler.cs index 509b467c4..6f9230bc4 100644 --- a/Src/AutoFixture/Kernel/OmitOnRecursionHandler.cs +++ b/Src/AutoFixture/Kernel/OmitOnRecursionHandler.cs @@ -10,7 +10,7 @@ namespace AutoFixture.Kernel public class OmitOnRecursionHandler : IRecursionHandler { /// - /// Handles a recursive request by instructing AutoFixture to ignore + /// Handles a recursive request by instructing AutoFixture to ignore. /// /// /// The request causing the recursion. diff --git a/Src/AutoFixture/Kernel/OmitSpecimen.cs b/Src/AutoFixture/Kernel/OmitSpecimen.cs index fad7e8127..665dc476d 100644 --- a/Src/AutoFixture/Kernel/OmitSpecimen.cs +++ b/Src/AutoFixture/Kernel/OmitSpecimen.cs @@ -22,14 +22,14 @@ namespace AutoFixture.Kernel public class OmitSpecimen : IEquatable { /// - /// Determines whether the specified is equal to this + /// Determines whether the specified is equal to this /// instance. /// /// - /// The to compare with this instance. + /// The to compare with this instance. /// /// - /// if the specified is an instance of + /// if the specified is an instance of /// ; otherwise, . /// /// @@ -37,7 +37,7 @@ public override bool Equals(object obj) { if (obj is OmitSpecimen other) return this.Equals(other); - + return base.Equals(obj); } @@ -69,7 +69,7 @@ public bool Equals(OmitSpecimen other) /// /// /// A hash code for this instance, suitable for use in hashing algorithms and data - /// structures like a hash table. + /// structures like a hash table. /// public override int GetHashCode() { diff --git a/Src/AutoFixture/Kernel/Omitter.cs b/Src/AutoFixture/Kernel/Omitter.cs index b797a541f..1321106b7 100644 --- a/Src/AutoFixture/Kernel/Omitter.cs +++ b/Src/AutoFixture/Kernel/Omitter.cs @@ -25,7 +25,7 @@ public Omitter() /// instance should be issued. /// /// - /// specification + /// specification. /// /// public Omitter(IRequestSpecification specification) @@ -43,7 +43,7 @@ public Omitter(IRequestSpecification specification) /// allows it; otherwise a /// instance. /// - /// request + /// request. /// /// /// The can be any object, but will often be a @@ -56,7 +56,7 @@ public object Create(object request, ISpecimenContext context) if (this.Specification.IsSatisfiedBy(request)) return new OmitSpecimen(); - + return new NoSpecimen(); } diff --git a/Src/AutoFixture/Kernel/ParameterScore.cs b/Src/AutoFixture/Kernel/ParameterScore.cs index 9ad4f7faf..4576ffb3b 100644 --- a/Src/AutoFixture/Kernel/ParameterScore.cs +++ b/Src/AutoFixture/Kernel/ParameterScore.cs @@ -57,7 +57,7 @@ private static int CalculateScore(Type parentType, Type targetType, IEnumerable< if (polymorphismScore > 0) return polymorphismScore; - return parameters.Count() * -1; + return parameters.Count() * -1; } private static bool IsExactMatch(Type targetType, ParameterInfo p) diff --git a/Src/AutoFixture/Kernel/ParameterTypeAndNameCriterion.cs b/Src/AutoFixture/Kernel/ParameterTypeAndNameCriterion.cs index 479bbcf66..6697449ed 100644 --- a/Src/AutoFixture/Kernel/ParameterTypeAndNameCriterion.cs +++ b/Src/AutoFixture/Kernel/ParameterTypeAndNameCriterion.cs @@ -104,7 +104,7 @@ public override bool Equals(object obj) /// /// Returns the hash code for the object. /// - /// The hash code + /// The hash code. public override int GetHashCode() { return diff --git a/Src/AutoFixture/Kernel/Postprocessor.cs b/Src/AutoFixture/Kernel/Postprocessor.cs index 5ee3ecf0c..8f72a07d7 100644 --- a/Src/AutoFixture/Kernel/Postprocessor.cs +++ b/Src/AutoFixture/Kernel/Postprocessor.cs @@ -4,10 +4,11 @@ namespace AutoFixture.Kernel { +#pragma warning disable SA1402 // File may only contain a single type /// /// Performs post-processing on a created specimen. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "The main responsibility of this class isn't to be a 'collection' (which, by the way, it isn't - it's just an Iterator).")] #pragma warning disable 618 public class Postprocessor : Postprocessor @@ -203,7 +204,7 @@ public Postprocessor(ISpecimenBuilder builder, Action actio /// should be performed for a request. /// /// - /// builder, command, or specification is null + /// builder, command, or specification is null. /// public Postprocessor( ISpecimenBuilder builder, @@ -279,8 +280,11 @@ public object Create(object request, ISpecimenContext context) return specimen; if (!(specimen is T)) + { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "The specimen returned by the decorated ISpecimenBuilder is not compatible with {0}.", typeof(T))); + } + this.Command.Execute(specimen, context); return specimen; } @@ -316,4 +320,5 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() return this.GetEnumerator(); } } +#pragma warning restore SA1402 // File may only contain a single type } diff --git a/Src/AutoFixture/Kernel/PropertyTypeAndNameCriterion.cs b/Src/AutoFixture/Kernel/PropertyTypeAndNameCriterion.cs index 513907687..444cc2373 100644 --- a/Src/AutoFixture/Kernel/PropertyTypeAndNameCriterion.cs +++ b/Src/AutoFixture/Kernel/PropertyTypeAndNameCriterion.cs @@ -104,10 +104,10 @@ public override bool Equals(object obj) /// /// Returns the hash code for the object. /// - /// The hash code + /// The hash code. public override int GetHashCode() { - return + return this.TypeCriterion.GetHashCode() ^ this.NameCriterion.GetHashCode(); } diff --git a/Src/AutoFixture/Kernel/RangedNumberRequest.cs b/Src/AutoFixture/Kernel/RangedNumberRequest.cs index f8d37c7a8..d7c9c1146 100644 --- a/Src/AutoFixture/Kernel/RangedNumberRequest.cs +++ b/Src/AutoFixture/Kernel/RangedNumberRequest.cs @@ -50,11 +50,11 @@ public RangedNumberRequest(Type operandType, object minimum, object maximum) public object Maximum { get; } /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// - /// The to compare with this instance. + /// The to compare with this instance. /// - /// true if the specified is equal to this instance; otherwise, false. + /// true if the specified is equal to this instance; otherwise, false. /// /// /// The parameter is null. @@ -73,7 +73,7 @@ public override bool Equals(object obj) /// Returns a hash code for this instance. /// /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// public override int GetHashCode() { diff --git a/Src/AutoFixture/Kernel/RecursionGuard.cs b/Src/AutoFixture/Kernel/RecursionGuard.cs index d0d67bad0..040eb6ddb 100644 --- a/Src/AutoFixture/Kernel/RecursionGuard.cs +++ b/Src/AutoFixture/Kernel/RecursionGuard.cs @@ -10,7 +10,7 @@ namespace AutoFixture.Kernel /// Base class for recursion handling. Tracks requests and reacts when a recursion point in the /// specimen creation process is detected. /// - [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", + [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "The main responsibility of this class isn't to be a 'collection' (which, by the way, it isn't - it's just an Iterator).")] [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Fixture doesn't support disposal, so we cannot dispose current builder somehow.")] @@ -24,7 +24,6 @@ public class RecursionGuard : ISpecimenBuilderNode /// /// Initializes a new instance of the class. /// - /// The intercepted builder to decorate. [Obsolete("This constructor overload is obsolete and will be removed in a future version of AutoFixture. Please use RecursionGuard(ISpecimenBuilder, IRecursionHandler) instead.", true)] public RecursionGuard(ISpecimenBuilder builder) : this(builder, EqualityComparer.Default) @@ -32,19 +31,13 @@ public RecursionGuard(ISpecimenBuilder builder) } /// - /// Initializes a new instance of the - /// class. + /// Initializes a new instance of the class. /// - /// The intercepted builder to decorate. - /// - /// An that will handle a recursion - /// situation, if one is detected. - /// public RecursionGuard( ISpecimenBuilder builder, IRecursionHandler recursionHandler) : this( - builder, + builder, recursionHandler, EqualityComparer.Default, 1) @@ -52,22 +45,14 @@ public RecursionGuard(ISpecimenBuilder builder) } /// - /// Initializes a new instance of the - /// class. + /// Initializes a new instance of the class. /// - /// The intercepted builder to decorate. - /// - /// An that will handle a recursion - /// situation, if one is detected. - /// - /// The recursion depth at which the request will be treated as a recursive - /// request public RecursionGuard( ISpecimenBuilder builder, IRecursionHandler recursionHandler, int recursionDepth) : this( - builder, + builder, recursionHandler, EqualityComparer.Default, recursionDepth) @@ -77,10 +62,6 @@ public RecursionGuard(ISpecimenBuilder builder) /// /// Initializes a new instance of the class. /// - /// The intercepted builder to decorate. - /// - /// An IEqualityComparer implementation to use when comparing requests to determine recursion. - /// [Obsolete("This constructor overload is obsolete and will be removed in a future version of AutoFixture. Please use RecursionGuard(ISpecimenBuilder, IRecursionHandler, IEqualityComparer, int) instead.", true)] public RecursionGuard(ISpecimenBuilder builder, IEqualityComparer comparer) { @@ -90,76 +71,37 @@ public RecursionGuard(ISpecimenBuilder builder, IEqualityComparer comparer) } /// - /// Initializes a new instance of the - /// class. + /// Initializes a new instance of the class. /// - /// The intercepted builder to decorate. - /// - /// An that will handle a recursion - /// situation, if one is detected. - /// - /// - /// An implementation to use when - /// comparing requests to determine recursion. - /// - /// - /// builder - /// or - /// recursionHandler - /// or - /// comparer - /// [Obsolete("This constructor overload is obsolete and will be removed in a future version of AutoFixture. Please use RecursionGuard(ISpecimenBuilder, IRecursionHandler, IEqualityComparer, int) instead.", true)] public RecursionGuard( ISpecimenBuilder builder, IRecursionHandler recursionHandler, IEqualityComparer comparer) : this( - builder, - recursionHandler, - comparer, + builder, + recursionHandler, + comparer, 1) { - } - + } + /// /// Initializes a new instance of the /// class. /// - /// The intercepted builder to decorate. - /// - /// An that will handle a recursion - /// situation, if one is detected. - /// - /// - /// An implementation to use when - /// comparing requests to determine recursion. - /// - /// The recursion depth at which the request will be treated as a recursive - /// request. - /// - /// builder - /// or - /// recursionHandler - /// or - /// comparer - /// - /// recursionDepth is less than one. public RecursionGuard( ISpecimenBuilder builder, IRecursionHandler recursionHandler, IEqualityComparer comparer, int recursionDepth) { - if (builder == null) throw new ArgumentNullException(nameof(builder)); - if (recursionHandler == null) throw new ArgumentNullException(nameof(recursionHandler)); - if (comparer == null) throw new ArgumentNullException(nameof(comparer)); if (recursionDepth < 1) throw new ArgumentOutOfRangeException(nameof(recursionDepth), "Recursion depth must be greater than 0."); - this.Builder = builder; - this.RecursionHandler = recursionHandler; - this.Comparer = comparer; + this.Builder = builder ?? throw new ArgumentNullException(nameof(builder)); + this.RecursionHandler = recursionHandler ?? throw new ArgumentNullException(nameof(recursionHandler)); + this.Comparer = comparer ?? throw new ArgumentNullException(nameof(comparer)); this.RecursionDepth = recursionDepth; } @@ -169,34 +111,24 @@ public RecursionGuard(ISpecimenBuilder builder, IEqualityComparer comparer) public ISpecimenBuilder Builder { get; } /// - /// Gets the recursion handler originally supplied as a constructor - /// argument. + /// Gets the recursion handler originally supplied as a constructor argument. /// - /// - /// The recursion handler used to handle recursion situations. - /// - /// public IRecursionHandler RecursionHandler { get; } /// - /// The recursion depth at which the request will be treated as a - /// recursive request + /// The recursion depth at which the request will be treated as a recursive request. /// public int RecursionDepth { get; } - /// Gets the comparer supplied via the constructor. + /// Gets the comparer supplied via the constructor. public IEqualityComparer Comparer { get; } - /// - /// Gets the recorded requests so far. - /// + /// Gets the recorded requests so far. protected IEnumerable RecordedRequests => this.GetMonitoredRequestsForCurrentThread(); /// /// Handles a request that would cause recursion. /// - /// The recursion causing request. - /// The specimen to return. [Obsolete("This method will be removed in a future version of AutoFixture. Use IRecursionHandler.HandleRecursiveRequest instead.", true)] public virtual object HandleRecursiveRequest(object request) { @@ -205,20 +137,7 @@ public virtual object HandleRecursiveRequest(object request) this.GetMonitoredRequestsForCurrentThread()); } - /// - /// Creates a new specimen based on a request. - /// - /// The request that describes what to create. - /// A container that can be used to create other specimens. - /// - /// The requested specimen if possible; otherwise a instance. - /// - /// - /// - /// The can be any object, but will often be a - /// or other instances. - /// - /// + /// public object Create(object request, ISpecimenContext context) { var requestsForCurrentThread = this.GetMonitoredRequestsForCurrentThread(); @@ -256,29 +175,7 @@ public object Create(object request, ISpecimenContext context) } } - /// Composes the supplied builders. - /// The builders to compose. - /// A instance. - /// - /// - /// Note to implementers: - /// - /// - /// The intent of this method is to compose the supplied - /// into a new instance of the type - /// implementing . Thus, the - /// concrete return type is expected to the same type as the type - /// implementing the method. However, it is not considered a failure to - /// deviate from this idiom - it would just not be a mainstream - /// implementation. - /// - /// - /// The returned instance is normally expected to contain the builders - /// supplied as an argument, but again this is not strictly required. - /// The implementation may decide to filter the sequence or add to it - /// during composition. - /// - /// + /// public virtual ISpecimenBuilderNode Compose( IEnumerable builders) { @@ -291,18 +188,13 @@ public object Create(object request, ISpecimenContext context) this.RecursionDepth); } - /// - /// Returns an enumerator that iterates through the collection. - /// - /// - /// A that can be used to - /// iterate through the collection. - /// + /// public virtual IEnumerator GetEnumerator() { yield return this.Builder; } + /// IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); diff --git a/Src/AutoFixture/Kernel/RegularExpressionRequest.cs b/Src/AutoFixture/Kernel/RegularExpressionRequest.cs index 73cdd1d03..c35fe707a 100644 --- a/Src/AutoFixture/Kernel/RegularExpressionRequest.cs +++ b/Src/AutoFixture/Kernel/RegularExpressionRequest.cs @@ -22,11 +22,11 @@ public RegularExpressionRequest(string pattern) public string Pattern { get; } /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// - /// The to compare with this instance. + /// The to compare with this instance. /// - /// true if the specified is equal to this instance; otherwise, false. + /// true if the specified is equal to this instance; otherwise, false. /// /// /// The parameter is null. diff --git a/Src/AutoFixture/Kernel/RequestTraceEventArgs.cs b/Src/AutoFixture/Kernel/RequestTraceEventArgs.cs index a5220266d..c8e552d9e 100644 --- a/Src/AutoFixture/Kernel/RequestTraceEventArgs.cs +++ b/Src/AutoFixture/Kernel/RequestTraceEventArgs.cs @@ -3,7 +3,7 @@ namespace AutoFixture.Kernel { /// - /// Event args about a request for a specimen + /// Event args about a request for a specimen. /// public class RequestTraceEventArgs : EventArgs { @@ -11,12 +11,12 @@ public class RequestTraceEventArgs : EventArgs /// Initializes a new instance of the class with the /// supplied values. /// - /// A request for a specimen + /// A request for a specimen. /// /// The recursion depth at which occurred. /// public RequestTraceEventArgs(object request, int depth) - { + { this.Request = request; this.Depth = depth; } @@ -27,7 +27,7 @@ public RequestTraceEventArgs(object request, int depth) public int Depth { get; } /// - /// Gets the original request for a specimen + /// Gets the original request for a specimen. /// public object Request { get; } } diff --git a/Src/AutoFixture/Kernel/SeededRequest.cs b/Src/AutoFixture/Kernel/SeededRequest.cs index 2ec1617d5..e668d8c55 100644 --- a/Src/AutoFixture/Kernel/SeededRequest.cs +++ b/Src/AutoFixture/Kernel/SeededRequest.cs @@ -68,7 +68,7 @@ public bool Equals(SeededRequest other) { return false; } - + return this.Request == other.Request && object.Equals(this.Seed, other.Seed); } diff --git a/Src/AutoFixture/Kernel/SpecimenBuilderNode.cs b/Src/AutoFixture/Kernel/SpecimenBuilderNode.cs index f9901ac85..046f7aaac 100644 --- a/Src/AutoFixture/Kernel/SpecimenBuilderNode.cs +++ b/Src/AutoFixture/Kernel/SpecimenBuilderNode.cs @@ -11,22 +11,8 @@ namespace AutoFixture.Kernel public static class SpecimenBuilderNode { /// - /// Determines whether two - /// instances are define the same graph. + /// Determines whether two instances are define the same graph. /// - /// - /// An to compare against - /// . - /// - /// - /// An to compare against - /// . - /// - /// - /// if the two - /// define the same graph; - /// otherwise, . - /// /// /// /// Two instances define the same @@ -34,9 +20,6 @@ public static class SpecimenBuilderNode /// child nodes recursively are equal to each other. /// /// - /// first - /// second - /// public static bool GraphEquals(this ISpecimenBuilderNode first, ISpecimenBuilderNode second) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -46,25 +29,8 @@ public static bool GraphEquals(this ISpecimenBuilderNode first, ISpecimenBuilder } /// - /// Determines whether two - /// instances are define the same graph. + /// Determines whether two instances are define the same graph. /// - /// - /// An to compare against - /// . - /// - /// - /// An to compare against - /// . - /// - /// - /// The comparer used to compare each node to another node. - /// - /// - /// if the two - /// define the same graph; - /// otherwise, . - /// /// /// /// Two instances define the same @@ -73,10 +39,6 @@ public static bool GraphEquals(this ISpecimenBuilderNode first, ISpecimenBuilder /// defined by . /// /// - /// first - /// second - /// comparer - /// public static bool GraphEquals(this ISpecimenBuilderNode first, ISpecimenBuilderNode second, IEqualityComparer comparer) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -86,8 +48,7 @@ public static bool GraphEquals(this ISpecimenBuilderNode first, ISpecimenBuilder if (!comparer.Equals(first, second)) return false; - using (IEnumerator e1 = first.GetEnumerator(), - e2 = second.GetEnumerator()) + using (IEnumerator e1 = first.GetEnumerator(), e2 = second.GetEnumerator()) { while (e1.MoveNext()) { @@ -169,8 +130,7 @@ internal static ISpecimenBuilderNode FindFirstNodeOrDefault(this ISpecimenBuilde foreach (var builder in graph) { - var builderNode = builder as ISpecimenBuilderNode; - if (builderNode != null) + if (builder is ISpecimenBuilderNode builderNode) { var result = FindFirstNodeOrDefault(builderNode, predicate); if (result != null) return result; diff --git a/Src/AutoFixture/Kernel/SpecimenCreatedEventArgs.cs b/Src/AutoFixture/Kernel/SpecimenCreatedEventArgs.cs index 05632b19e..a8a253b58 100644 --- a/Src/AutoFixture/Kernel/SpecimenCreatedEventArgs.cs +++ b/Src/AutoFixture/Kernel/SpecimenCreatedEventArgs.cs @@ -9,7 +9,7 @@ public class SpecimenCreatedEventArgs : RequestTraceEventArgs /// Initializes a new instance of the class with the /// supplied values. /// - /// A request for a specimen + /// A request for a specimen. /// /// The specimen that was created base on . /// diff --git a/Src/AutoFixture/Kernel/SpecimenFactory.cs b/Src/AutoFixture/Kernel/SpecimenFactory.cs index a4148fc60..72604afce 100644 --- a/Src/AutoFixture/Kernel/SpecimenFactory.cs +++ b/Src/AutoFixture/Kernel/SpecimenFactory.cs @@ -2,6 +2,7 @@ namespace AutoFixture.Kernel { +#pragma warning disable SA1402 // File may only contain a single type /// /// Creates a new specimen using a . /// @@ -99,7 +100,7 @@ public object Create(object request, ISpecimenContext context) /// The type of the first parameter provided to the Func. /// The type of the second parameter provided to the Func. /// The type of specimen to create. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes", + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes", Justification = "Necessary to wrap the corresponding Func. However, this particular API is only intended " + "to be used to implement the fluent API, and is not targeted at the typical end-user.")] public class SpecimenFactory : ISpecimenBuilder @@ -157,7 +158,7 @@ public object Create(object request, ISpecimenContext context) /// The type of the second parameter provided to the Func. /// The type of the third parameter provided to the Func. /// The type of specimen to create. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes", + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes", Justification = "Necessary to wrap the corresponding Func. However, this particular API is only intended to be " + "used to implement the fluent API, and is not targeted at the typical end-user.")] public class SpecimenFactory : ISpecimenBuilder @@ -217,7 +218,7 @@ public object Create(object request, ISpecimenContext context) /// The type of the third parameter provided to the Func. /// The type of the fourth parameter provided to the Func. /// The type of specimen to create. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes", + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes", Justification = "Necessary to wrap the corresponding Func. However, this particular API is only intended " + "to be used to implement the fluent API, and is not targeted at the typical end-user.")] public class SpecimenFactory : ISpecimenBuilder @@ -269,4 +270,5 @@ public object Create(object request, ISpecimenContext context) return this.Factory(p1, p2, p3, p4); } } +#pragma warning restore SA1402 // File may only contain a single type } diff --git a/Src/AutoFixture/Kernel/StaticMethod.cs b/Src/AutoFixture/Kernel/StaticMethod.cs index 99614acaf..194a5fce9 100644 --- a/Src/AutoFixture/Kernel/StaticMethod.cs +++ b/Src/AutoFixture/Kernel/StaticMethod.cs @@ -43,11 +43,11 @@ public StaticMethod(MethodInfo methodInfo, ParameterInfo[] methodParameters) public IEnumerable Parameters => this.paramInfos; /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// - /// The to compare with this instance. + /// The to compare with this instance. /// - /// true if the specified is equal to this instance; otherwise, false. + /// true if the specified is equal to this instance; otherwise, false. /// /// /// The parameter is null. @@ -66,7 +66,7 @@ public override bool Equals(object obj) /// /// /// A hash code for this instance, suitable for use in hashing algorithms and data - /// structures like a hash table. + /// structures like a hash table. /// public override int GetHashCode() { @@ -98,7 +98,7 @@ public bool Equals(StaticMethod other) return false; } - return this.Method.Equals(other.Method) + return this.Method.Equals(other.Method) && this.Parameters.SequenceEqual(other.Parameters); } diff --git a/Src/AutoFixture/Kernel/TemplateMethodQuery.cs b/Src/AutoFixture/Kernel/TemplateMethodQuery.cs index adfb511c9..b37d95e52 100644 --- a/Src/AutoFixture/Kernel/TemplateMethodQuery.cs +++ b/Src/AutoFixture/Kernel/TemplateMethodQuery.cs @@ -108,8 +108,10 @@ private bool Compare(Type parameterType, Type templateParameterType) return true; if (parameterType.IsGenericParameter) + { return templateParameterType.IsGenericParameter && parameterType.GenericParameterPosition == templateParameterType.GenericParameterPosition; + } var genericArguments = GetTypeArguments(parameterType); var templateGenericArguments = GetTypeArguments(templateParameterType); @@ -131,7 +133,7 @@ private class LateBindingParameterScore : IComparable { private readonly int score; - internal LateBindingParameterScore(IEnumerable methodParameters, + internal LateBindingParameterScore(IEnumerable methodParameters, IEnumerable templateParameters) { if (methodParameters == null) @@ -140,7 +142,7 @@ private class LateBindingParameterScore : IComparable if (templateParameters == null) throw new ArgumentNullException(nameof(templateParameters)); - this.score = CalculateScore(methodParameters.Select(p => p.ParameterType), + this.score = CalculateScore(methodParameters.Select(p => p.ParameterType), templateParameters.Select(p => p.ParameterType)); } @@ -152,7 +154,7 @@ public int CompareTo(LateBindingParameterScore other) return this.score.CompareTo(other.score); } - private static int CalculateScore(IEnumerable methodParameters, + private static int CalculateScore(IEnumerable methodParameters, IEnumerable templateParameters) { var parametersScore = templateParameters.Zip(methodParameters, @@ -170,9 +172,9 @@ private static int CalculateScore(Type methodParameterType, Type templateParamet return 100; var hierarchy = GetHierarchy(templateParameterType).ToList(); - + var matches = methodParameterType.GetTypeInfo().IsClass ? - hierarchy.Count(t => t.GetTypeInfo().IsAssignableFrom(methodParameterType)) : + hierarchy.Count(t => t.GetTypeInfo().IsAssignableFrom(methodParameterType)) : hierarchy.Count(t => t.GetTypeInfo().GetInterfaces().Any(i => i.GetTypeInfo().IsAssignableFrom(methodParameterType))); var score = 50 * -(hierarchy.Count - matches); @@ -185,15 +187,17 @@ private static int CalculateScore(Type methodParameterType, Type templateParamet if (methodParameterType.GetTypeInfo().IsClass) score += 5; - + return score; } private static IEnumerable GetHierarchy(Type type) { if (!type.GetTypeInfo().IsClass) + { foreach (var interfaceType in type.GetTypeInfo().GetInterfaces()) yield return interfaceType; + } while (type != null) { @@ -203,5 +207,4 @@ private static IEnumerable GetHierarchy(Type type) } } } - } \ No newline at end of file diff --git a/Src/AutoFixture/Kernel/TerminatingSpecimenBuilder.cs b/Src/AutoFixture/Kernel/TerminatingSpecimenBuilder.cs index cd6c49e53..a873718c9 100644 --- a/Src/AutoFixture/Kernel/TerminatingSpecimenBuilder.cs +++ b/Src/AutoFixture/Kernel/TerminatingSpecimenBuilder.cs @@ -32,9 +32,7 @@ public object Create(object request, ISpecimenContext context) string.Format( CultureInfo.CurrentCulture, "AutoFixture was unable to create an instance from {0}, most likely because it has no public constructor, is an abstract or non-public type.", - request - ) - ); + request)); } } } diff --git a/Src/AutoFixture/Kernel/TerminatingWithPathSpecimenBuilder.cs b/Src/AutoFixture/Kernel/TerminatingWithPathSpecimenBuilder.cs index bc1b45a36..f92ffb101 100644 --- a/Src/AutoFixture/Kernel/TerminatingWithPathSpecimenBuilder.cs +++ b/Src/AutoFixture/Kernel/TerminatingWithPathSpecimenBuilder.cs @@ -11,7 +11,7 @@ namespace AutoFixture.Kernel { /// /// Decorates an with a node which tracks specimen requests, and - /// when is detected or creation fails with exception, throws an + /// when is detected or creation fails with exception, throws an /// , which includes a description of the request path. /// [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", @@ -74,7 +74,7 @@ public object Create(object request, ISpecimenContext context) } catch (ObjectCreationExceptionWithPath) { - // Do not modify exception thrown before as it already contains the full requests path. + // Do not modify exception thrown before as it already contains the full requests path. throw; } catch (Exception ex) @@ -97,14 +97,17 @@ public object Create(object request, ISpecimenContext context) private static string BuildCoreMessageTemplate(object request, Exception innerException) { if (innerException != null) + { return "AutoFixture was unable to create an instance from {0} " + "because creation unexpectedly failed with exception. " + "Please refer to the inner exception to investigate the root cause of the failure."; + } var t = request as Type; if (t != null && t.GetTypeInfo().IsInterface) + { return "AutoFixture was unable to create an instance from {0} " + "because it's an interface. There's no single, most " + @@ -115,8 +118,10 @@ private static string BuildCoreMessageTemplate(object request, Exception innerEx "If you have a concrete class implementing the " + "interface, you can map the interface to that class:" + TypeMappingOptionsHelp; + } if (t != null && t.GetTypeInfo().IsAbstract) + { return "AutoFixture was unable to create an instance from {0} " + "because it's an abstract class. There's no single, " + @@ -125,9 +130,10 @@ private static string BuildCoreMessageTemplate(object request, Exception innerEx "{1}" + "{1}" + "If you have a concrete class deriving from the abstract " + - "class, you can map the abstract class to that derived " + + "class, you can map the abstract class to that derived " + "class:" + TypeMappingOptionsHelp; + } return "AutoFixture was unable to create an instance from {0}, " + diff --git a/Src/AutoFixture/Kernel/ThrowingRecursionHandler.cs b/Src/AutoFixture/Kernel/ThrowingRecursionHandler.cs index f824d4f16..977de0142 100644 --- a/Src/AutoFixture/Kernel/ThrowingRecursionHandler.cs +++ b/Src/AutoFixture/Kernel/ThrowingRecursionHandler.cs @@ -20,7 +20,7 @@ public class ThrowingRecursionHandler : IRecursionHandler /// /// An object intended to break the recursion. /// - /// Always + /// Always. /// /// /// This method is called when AutoFixture detects an infinite @@ -36,7 +36,8 @@ public class ThrowingRecursionHandler : IRecursionHandler /// contains instructions on how to move on. /// /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "AutoFixture"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "OmitOnRecursionBehavior", Justification = "Workaround for a bug in CA: https://connect.microsoft.com/VisualStudio/feedback/details/521030/")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "AutoFixture", Justification = "Workaround for a bug in CA: https://connect.microsoft.com/VisualStudio/feedback/details/521030/")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "OmitOnRecursionBehavior", Justification = "Workaround for a bug in CA: https://connect.microsoft.com/VisualStudio/feedback/details/521030/")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "ForEach", Justification = "Workaround for a bug in CA: https://connect.microsoft.com/VisualStudio/feedback/details/521030/")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "OfType", Justification = "Workaround for a bug in CA: https://connect.microsoft.com/VisualStudio/feedback/details/521030/")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "ToList", Justification = "Workaround for a bug in CA: https://connect.microsoft.com/VisualStudio/feedback/details/521030/")] diff --git a/Src/AutoFixture/Kernel/TracingBuilder.cs b/Src/AutoFixture/Kernel/TracingBuilder.cs index 9b47e8457..4aef819c4 100644 --- a/Src/AutoFixture/Kernel/TracingBuilder.cs +++ b/Src/AutoFixture/Kernel/TracingBuilder.cs @@ -38,7 +38,7 @@ public TracingBuilder(ISpecimenBuilder builder) public ISpecimenBuilder Builder { get; } /// - /// Gets or sets a filter for tracking + /// Gets or sets a filter for tracking. /// /// /// diff --git a/Src/AutoFixture/Kernel/TypeArgumentsCannotBeInferredException.cs b/Src/AutoFixture/Kernel/TypeArgumentsCannotBeInferredException.cs index edf6aab92..2519dc4a6 100644 --- a/Src/AutoFixture/Kernel/TypeArgumentsCannotBeInferredException.cs +++ b/Src/AutoFixture/Kernel/TypeArgumentsCannotBeInferredException.cs @@ -10,7 +10,7 @@ namespace AutoFixture.Kernel { /// - /// The exception that is thrown when AutoFixture is unable to infer the type + /// The exception that is thrown when AutoFixture is unable to infer the type /// parameters of a generic method from its arguments. /// #if SYSTEM_RUNTIME_SERIALIZATION @@ -27,7 +27,7 @@ public TypeArgumentsCannotBeInferredException() } /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// from a . /// /// @@ -42,13 +42,12 @@ public TypeArgumentsCannotBeInferredException(MethodInfo methodInfo) methodInfo.DeclaringType.FullName, methodInfo.Name, string.Join(", ", methodInfo.GetGenericArguments().Select(a => a.ToString())), - string.Join(", ", methodInfo.GetParameters().Select(p => GetFriendlyName(p.ParameterType))) - )) + string.Join(", ", methodInfo.GetParameters().Select(p => GetFriendlyName(p.ParameterType))))) { if (methodInfo == null) throw new ArgumentNullException(nameof(methodInfo)); } - + /// /// Initializes a new instance of the class with a /// custom . @@ -94,13 +93,14 @@ protected TypeArgumentsCannotBeInferredException(SerializationInfo info, Streami private static string GetFriendlyName(Type type) { if (type.GetTypeInfo().IsGenericType) - return string.Format(CultureInfo.CurrentCulture, - "{0}<{1}>", - type.Name.Split('`')[0], + { + return string.Format(CultureInfo.CurrentCulture, + "{0}<{1}>", + type.Name.Split('`')[0], string.Join(", ", type.GetTypeInfo().GetGenericArguments().Select(GetFriendlyName))); + } return type.Name; } - } } \ No newline at end of file diff --git a/Src/AutoFixture/Kernel/TypeEnvy.cs b/Src/AutoFixture/Kernel/TypeEnvy.cs index c74917335..8ca6ddef1 100644 --- a/Src/AutoFixture/Kernel/TypeEnvy.cs +++ b/Src/AutoFixture/Kernel/TypeEnvy.cs @@ -16,7 +16,7 @@ public static TAttribute GetAttribute(object candidate) var attributes = attributeProvider.GetCustomAttributes(typeof(TAttribute), true); if (attributes.Length == 0) return null; - if (attributes.Length == 1) return (TAttribute) attributes[0]; + if (attributes.Length == 1) return (TAttribute)attributes[0]; throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Member '{0}' contains more than one attribute of type '{1}'", candidate, typeof(TAttribute))); @@ -42,10 +42,10 @@ public static TAttribute GetAttribute(object candidate) argument = null; return false; } - + public static bool IsNumberType(this Type type) { - if(type.GetTypeInfo().IsEnum) return false; + if (type.GetTypeInfo().IsEnum) return false; var typeCode = Type.GetTypeCode(type); switch (typeCode) diff --git a/Src/AutoFixture/Kernel/TypeRelay.cs b/Src/AutoFixture/Kernel/TypeRelay.cs index d3c286738..a5877f639 100644 --- a/Src/AutoFixture/Kernel/TypeRelay.cs +++ b/Src/AutoFixture/Kernel/TypeRelay.cs @@ -9,12 +9,12 @@ namespace AutoFixture.Kernel public class TypeRelay : ISpecimenBuilder { private readonly IRequestSpecification fromSpecification; - + /// /// Gets the type which is relayed from. /// public Type From { get; } - + /// /// Gets the type which is relayed to. /// @@ -48,7 +48,7 @@ public class TypeRelay : ISpecimenBuilder /// new TypeRelay( /// typeof(BaseType), /// typeof(DerivedType))); - /// + /// /// var actual = fixture.Create<BaseType>(); /// /// @@ -56,10 +56,12 @@ public TypeRelay(Type from, Type to) { this.From = from ?? throw new ArgumentNullException(nameof(from)); this.To = to ?? throw new ArgumentNullException(nameof(to)); - - if(from.GetTypeInfo().IsGenericTypeDefinition ^ to.GetTypeInfo().IsGenericTypeDefinition) + + if (from.GetTypeInfo().IsGenericTypeDefinition ^ to.GetTypeInfo().IsGenericTypeDefinition) + { throw new ArgumentException("Relaying from open generic type to open generic type " + "or from closed type to closed type are supported only."); + } this.fromSpecification = new ExactTypeSpecification(from); } @@ -88,7 +90,7 @@ public TypeRelay(Type from, Type to) public object Create(object request, ISpecimenContext context) { if (context == null) throw new ArgumentNullException(nameof(context)); - + if (request is Type t && this.fromSpecification.IsSatisfiedBy(request)) return context.Resolve(this.GetRedirectedTypeRequest(t)); diff --git a/Src/AutoFixture/Kernel/ValueTypeSpecification.cs b/Src/AutoFixture/Kernel/ValueTypeSpecification.cs index 94f87c526..d12564c54 100644 --- a/Src/AutoFixture/Kernel/ValueTypeSpecification.cs +++ b/Src/AutoFixture/Kernel/ValueTypeSpecification.cs @@ -22,10 +22,10 @@ public bool IsSatisfiedBy(object request) return request is Type typeRequest && IsValueTypeButNotPrimitiveOrEnum(typeRequest); } - + /// - /// Checks if type is a struct. This will exclude primitive types (int, char etc.) considered as IsPrimitive as - /// well as enums but not .NET structs. + /// Checks if type is a struct. This will exclude primitive types (int, char etc.) considered as IsPrimitive as + /// well as enums but not .NET structs. /// private static bool IsValueTypeButNotPrimitiveOrEnum(Type type) { diff --git a/Src/AutoFixture/LambdaExpressionGenerator.cs b/Src/AutoFixture/LambdaExpressionGenerator.cs index f00cc86b8..8e9e55901 100644 --- a/Src/AutoFixture/LambdaExpressionGenerator.cs +++ b/Src/AutoFixture/LambdaExpressionGenerator.cs @@ -13,7 +13,7 @@ namespace AutoFixture /// Specimens are typically either of type /// Expression{Func{T}} /// - /// or . + /// or . /// public class LambdaExpressionGenerator : ISpecimenBuilder { diff --git a/Src/AutoFixture/MailAddressGenerator.cs b/Src/AutoFixture/MailAddressGenerator.cs index df09c78be..e6f65a4ea 100644 --- a/Src/AutoFixture/MailAddressGenerator.cs +++ b/Src/AutoFixture/MailAddressGenerator.cs @@ -22,7 +22,7 @@ public class MailAddressGenerator : ISpecimenBuilder /// /// > /// The generated MailAddress will have one of the reserved domains, - /// so as to avoid any possibility of tests bothering real email addresses + /// so as to avoid any possibility of tests bothering real email addresses. /// public object Create(object request, ISpecimenContext context) { @@ -36,7 +36,7 @@ public object Create(object request, ISpecimenContext context) try { return TryCreateMailAddress(context); - } + } catch (FormatException) { return new NoSpecimen(); @@ -56,7 +56,7 @@ private static object TryCreateMailAddress(ISpecimenContext context) var email = string.Format(CultureInfo.InvariantCulture, "{0} <{0}@{1}>", localPart, domainName); return new MailAddress(email); } - } + } } #endif diff --git a/Src/AutoFixture/MapCreateManyToEnumerable.cs b/Src/AutoFixture/MapCreateManyToEnumerable.cs index 558d2bdcd..32246aff3 100644 --- a/Src/AutoFixture/MapCreateManyToEnumerable.cs +++ b/Src/AutoFixture/MapCreateManyToEnumerable.cs @@ -32,7 +32,7 @@ public class MapCreateManyToEnumerable : ICustomization /// /// The fixture to customize. /// - /// fixture is null + /// fixture is null. /// /// /// diff --git a/Src/AutoFixture/MutableValueTypeGenerator.cs b/Src/AutoFixture/MutableValueTypeGenerator.cs index ee60b2aa3..1f4d8b32b 100644 --- a/Src/AutoFixture/MutableValueTypeGenerator.cs +++ b/Src/AutoFixture/MutableValueTypeGenerator.cs @@ -17,14 +17,13 @@ public MutableValueTypeGenerator() { this.valueTypeWithoutConstructorsSpecification = new AndRequestSpecification(new ValueTypeSpecification(), new NoConstructorsSpecification()); - } /// /// Creates a new . /// /// The request that describes what to create. - /// A context that can be used to create other specimens. Not used + /// A context that can be used to create other specimens. Not used. /// /// The requested struct if possible; otherwise a instance. /// diff --git a/Src/AutoFixture/NoAutoPropertiesCustomization.cs b/Src/AutoFixture/NoAutoPropertiesCustomization.cs index 17d4a12e1..199fd8269 100644 --- a/Src/AutoFixture/NoAutoPropertiesCustomization.cs +++ b/Src/AutoFixture/NoAutoPropertiesCustomization.cs @@ -4,7 +4,7 @@ namespace AutoFixture { /// - /// A customization that will turn off the auto population of properties on the target type + /// A customization that will turn off the auto population of properties on the target type. /// public class NoAutoPropertiesCustomization : ICustomization { @@ -44,7 +44,6 @@ public void Customize(IFixture fixture) this.targetType, constructor); fixture.Customizations.Insert(0, builder); - } } } diff --git a/Src/AutoFixture/NullRecursionBehavior.cs b/Src/AutoFixture/NullRecursionBehavior.cs index 52b817cf7..027e41164 100644 --- a/Src/AutoFixture/NullRecursionBehavior.cs +++ b/Src/AutoFixture/NullRecursionBehavior.cs @@ -17,7 +17,7 @@ public class NullRecursionBehavior : ISpecimenBuilderTransformation /// public NullRecursionBehavior() : this(DefaultRecursionDepth) - { + { } /// diff --git a/Src/AutoFixture/NumericSequencePerTypeCustomization.cs b/Src/AutoFixture/NumericSequencePerTypeCustomization.cs index 4d4487f53..eb43cd54c 100644 --- a/Src/AutoFixture/NumericSequencePerTypeCustomization.cs +++ b/Src/AutoFixture/NumericSequencePerTypeCustomization.cs @@ -18,11 +18,11 @@ namespace AutoFixture /// /// var fixture = new Fixture(); /// fixture.Customize(new NumericSequencePerTypeCustomization()); - /// + /// /// Console.WriteLine("Byte specimen is {0}", fixture.Create<byte>()); /// Console.WriteLine("Int32 specimen is {0}", fixture.Create<int>()); /// Console.WriteLine("Single specimen is {0}", fixture.Create<float>()); - /// + /// /// // The output of this program will be: /// // Byte specimen is 1 /// // Int32 specimen is 1 diff --git a/Src/AutoFixture/ObjectCreationExceptionWithPath.cs b/Src/AutoFixture/ObjectCreationExceptionWithPath.cs index 85b87609c..a3af805b5 100644 --- a/Src/AutoFixture/ObjectCreationExceptionWithPath.cs +++ b/Src/AutoFixture/ObjectCreationExceptionWithPath.cs @@ -21,7 +21,8 @@ public ObjectCreationExceptionWithPath() { } - public ObjectCreationExceptionWithPath(string message) : base(message) + public ObjectCreationExceptionWithPath(string message) + : base(message) { } @@ -95,6 +96,6 @@ private static string FormatInnerExceptionMessages(Exception ex) return messages.ToString(); } - private static string Indent(int level) => "".PadLeft(level * 2); + private static string Indent(int level) => string.Empty.PadLeft(level * 2); } } \ No newline at end of file diff --git a/Src/AutoFixture/OmitOnRecursionBehavior.cs b/Src/AutoFixture/OmitOnRecursionBehavior.cs index 4e07bfef7..a174a6c83 100644 --- a/Src/AutoFixture/OmitOnRecursionBehavior.cs +++ b/Src/AutoFixture/OmitOnRecursionBehavior.cs @@ -11,12 +11,14 @@ public class OmitOnRecursionBehavior : ISpecimenBuilderTransformation { private const int DefaultRecursionDepth = 1; private readonly int recursionDepth; + /// /// Initializes new instance of the class with default recursion depth. /// The default recursion depth will omit assignment on first recursion. /// - public OmitOnRecursionBehavior() : this(DefaultRecursionDepth) - { + public OmitOnRecursionBehavior() + : this(DefaultRecursionDepth) + { } /// diff --git a/Src/AutoFixture/Properties/AssemblyInfo.cs b/Src/AutoFixture/Properties/AssemblyInfo.cs index d3a88a5f7..d6452d607 100644 --- a/Src/AutoFixture/Properties/AssemblyInfo.cs +++ b/Src/AutoFixture/Properties/AssemblyInfo.cs @@ -1,12 +1,12 @@ using System; using System.Reflection; -using System.Runtime.InteropServices; using System.Resources; +using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixture/RandomBooleanSequenceCustomization.cs b/Src/AutoFixture/RandomBooleanSequenceCustomization.cs index cf6408698..fb26cf75f 100644 --- a/Src/AutoFixture/RandomBooleanSequenceCustomization.cs +++ b/Src/AutoFixture/RandomBooleanSequenceCustomization.cs @@ -3,13 +3,13 @@ namespace AutoFixture { /// - /// A customization that changes how are generated. Uses . + /// A customization that changes how are generated. Uses . /// public class RandomBooleanSequenceCustomization : ICustomization { /// - /// Customizes specified fixture by adding as a default strategy for - /// creating new . + /// Customizes specified fixture by adding as a default strategy for + /// creating new . /// /// The fixture to customize. public void Customize(IFixture fixture) diff --git a/Src/AutoFixture/RandomBooleanSequenceGenerator.cs b/Src/AutoFixture/RandomBooleanSequenceGenerator.cs index 967fba90f..aa3a395df 100644 --- a/Src/AutoFixture/RandomBooleanSequenceGenerator.cs +++ b/Src/AutoFixture/RandomBooleanSequenceGenerator.cs @@ -25,7 +25,7 @@ public RandomBooleanSequenceGenerator() /// The request that describes what to create. /// Not used. /// - /// or generated randomly using , + /// or generated randomly using , /// if is a request for a boolean; otherwise, a instance. /// public object Create(object request, ISpecimenContext context) diff --git a/Src/AutoFixture/RandomCharSequenceGenerator.cs b/Src/AutoFixture/RandomCharSequenceGenerator.cs index 84f5a6eb1..f8c61a4dc 100644 --- a/Src/AutoFixture/RandomCharSequenceGenerator.cs +++ b/Src/AutoFixture/RandomCharSequenceGenerator.cs @@ -25,10 +25,10 @@ public RandomCharSequenceGenerator() /// /// The request that describes what to create. /// - /// A context that can be used to create other + /// A context that can be used to create other /// specimens. /// - /// The requested specimen if possible; otherwise a + /// The requested specimen if possible; otherwise a /// instance. /// public object Create(object request, ISpecimenContext context) diff --git a/Src/AutoFixture/RandomNumericSequenceCustomization.cs b/Src/AutoFixture/RandomNumericSequenceCustomization.cs index 810a7a5ef..76aba1b0e 100644 --- a/Src/AutoFixture/RandomNumericSequenceCustomization.cs +++ b/Src/AutoFixture/RandomNumericSequenceCustomization.cs @@ -13,7 +13,7 @@ public class RandomNumericSequenceCustomization : ICustomization /// /// The fixture to customize. /// - /// fixture is null + /// fixture is null. /// public void Customize(IFixture fixture) { diff --git a/Src/AutoFixture/RandomNumericSequenceGenerator.cs b/Src/AutoFixture/RandomNumericSequenceGenerator.cs index 9d0f229ef..ec08701ec 100644 --- a/Src/AutoFixture/RandomNumericSequenceGenerator.cs +++ b/Src/AutoFixture/RandomNumericSequenceGenerator.cs @@ -23,7 +23,7 @@ public class RandomNumericSequenceGenerator : ISpecimenBuilder /// with the default limits, 255, 32767, and 2147483647. /// public RandomNumericSequenceGenerator() - : this(1, Byte.MaxValue, Int16.MaxValue, Int32.MaxValue) + : this(1, byte.MaxValue, short.MaxValue, int.MaxValue) { } @@ -45,7 +45,7 @@ public RandomNumericSequenceGenerator(IEnumerable limits) public RandomNumericSequenceGenerator(params long[] limits) { if (limits == null) throw new ArgumentNullException(nameof(limits)); - if (limits.Length < 2) + if (limits.Length < 2) throw new ArgumentException("Limits must be at least two ascending numbers.", nameof(limits)); ValidateThatLimitsAreStrictlyAscending(limits); @@ -101,48 +101,38 @@ private object CreateRandom(Type request) switch (Type.GetTypeCode(request)) { case TypeCode.Byte: - return (byte) - this.GetNextRandom(); + return (byte)this.GetNextRandom(); case TypeCode.Decimal: - return (decimal) - this.GetNextRandom(); + return (decimal)this.GetNextRandom(); case TypeCode.Double: - return (double) - this.GetNextRandom(); + return (double)this.GetNextRandom(); case TypeCode.Int16: - return (short) - this.GetNextRandom(); + return (short)this.GetNextRandom(); case TypeCode.Int32: - return (int) - this.GetNextRandom(); + return (int)this.GetNextRandom(); case TypeCode.Int64: return this.GetNextRandom(); case TypeCode.SByte: - return (sbyte) - this.GetNextRandom(); + return (sbyte)this.GetNextRandom(); case TypeCode.Single: - return (float) - this.GetNextRandom(); + return (float)this.GetNextRandom(); case TypeCode.UInt16: - return (ushort) - this.GetNextRandom(); + return (ushort)this.GetNextRandom(); case TypeCode.UInt32: - return (uint) - this.GetNextRandom(); + return (uint)this.GetNextRandom(); case TypeCode.UInt64: - return (ulong) - this.GetNextRandom(); + return (ulong)this.GetNextRandom(); default: return new NoSpecimen(); @@ -206,13 +196,13 @@ private void CreateRange() /// /// Returns upper limit + 1 when expecting to use upper as max value in Random.Next(Int32,Int32). /// This ensures that the upper limit is included in the possible values returned by Random.Next(Int32,Int32) - /// + /// /// When not expecting to use Random.Next(Int32,Int32). It returns the original upper limit. /// /// private long GetUpperRangeFromLimits() { - return this.limits[1] >= Int32.MaxValue + return this.limits[1] >= int.MaxValue ? this.limits[1] : this.limits[1] + 1; } @@ -220,15 +210,16 @@ private long GetUpperRangeFromLimits() private long GetNextInt64InRange() { var range = (ulong)(this.upper - this.lower); - ulong limit = ulong.MaxValue - ulong.MaxValue % range; + ulong limit = ulong.MaxValue - (ulong.MaxValue % range); ulong number; do { var buffer = new byte[sizeof(ulong)]; this.random.NextBytes(buffer); number = BitConverter.ToUInt64(buffer, 0); - } while (number > limit); - return (long)(number % range + (ulong)this.lower); + } + while (number > limit); + return (long)((number % range) + (ulong)this.lower); } } } diff --git a/Src/AutoFixture/RandomRangedNumberCustomization.cs b/Src/AutoFixture/RandomRangedNumberCustomization.cs index 31af73371..f72fabdb7 100644 --- a/Src/AutoFixture/RandomRangedNumberCustomization.cs +++ b/Src/AutoFixture/RandomRangedNumberCustomization.cs @@ -6,7 +6,7 @@ namespace AutoFixture /// A customization that enables numeric specimens to be random and unique per equivalence set of type and range limits. /// [Obsolete("The RandomRangedNumberGenerator now is used by default, therefore this customization is no longer needed and will be removed in future versions of AutoFixture.")] - public class RandomRangedNumberCustomization : ICustomization + public class RandomRangedNumberCustomization : ICustomization { /// /// Customizes the specified fixture by adding a @@ -14,7 +14,7 @@ public class RandomRangedNumberCustomization : ICustomization /// /// The fixture to customize. /// - /// fixture is null + /// fixture is null. /// public void Customize(IFixture fixture) { diff --git a/Src/AutoFixture/RandomRangedNumberGenerator.cs b/Src/AutoFixture/RandomRangedNumberGenerator.cs index 9c12aa846..f969e7f52 100644 --- a/Src/AutoFixture/RandomRangedNumberGenerator.cs +++ b/Src/AutoFixture/RandomRangedNumberGenerator.cs @@ -6,17 +6,17 @@ namespace AutoFixture { /// - /// Creates a random sequence for a given type within a given range without repeating in the range until - /// all values are exhausted. Once exhausted, will automatically reset the set and continue choosing randomly + /// Creates a random sequence for a given type within a given range without repeating in the range until + /// all values are exhausted. Once exhausted, will automatically reset the set and continue choosing randomly /// within the range. Multiple requests (whether the same or different object) for the same - /// operand type, minimum, and maximum are treated as being drawn from the same set. + /// operand type, minimum, and maximum are treated as being drawn from the same set. /// public class RandomRangedNumberGenerator : ISpecimenBuilder { private readonly ConcurrentDictionary generatorMap; /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class. /// public RandomRangedNumberGenerator() { @@ -26,7 +26,7 @@ public RandomRangedNumberGenerator() /// /// Creates a random number within the request range. /// - /// The request that describes what to create. Other requests for same type and limits + /// The request that describes what to create. Other requests for same type and limits /// denote the same set. /// A context that can be used to create other specimens. /// @@ -35,7 +35,7 @@ public RandomRangedNumberGenerator() /// public object Create(object request, ISpecimenContext context) { - if (context == null)throw new ArgumentNullException(nameof(context)); + if (context == null) throw new ArgumentNullException(nameof(context)); var rangedNumberRequest = request as RangedNumberRequest; if (rangedNumberRequest == null) @@ -54,7 +54,7 @@ public object Create(object request, ISpecimenContext context) /// /// Choose the RandomNumericSequenceGenerator to fulfill the request. Will add the request as a new key /// to generatorMap if the request does not already have a generator for it. Throws ArgumentException - /// if either of the limits in the request are non-numeric. + /// if either of the limits in the request are non-numeric. /// /// /// @@ -105,7 +105,6 @@ private static ISpecimenBuilder CreateRandomGenerator(RangedNumberRequest reques } } - private class FloatingPointRangedGenerator : ISpecimenBuilder { private const long RandomValueRange = int.MaxValue; @@ -124,7 +123,7 @@ public FloatingPointRangedGenerator(object minimum, object maximum, TypeCode res this.generator = new RandomNumericSequenceGenerator(0, RandomValueRange); // (max - min) could lead to overflow, so we divide each part on range individually. - this.factor = Math.Abs(this.maximum / RandomValueRange - this.minimum / RandomValueRange); + this.factor = Math.Abs((this.maximum / RandomValueRange) - (this.minimum / RandomValueRange)); } public object Create(object request, ISpecimenContext context) @@ -158,7 +157,7 @@ public HighPrecisionRangedGenerator(object minimum, object maximum, TypeCode res this.generator = new RandomNumericSequenceGenerator(0, RandomValueRange); // (max - min) could lead to overflow, so we divide each part on range individually. - this.factor = Math.Abs(this.maximum / RandomValueRange - this.minimum / RandomValueRange); + this.factor = Math.Abs((this.maximum / RandomValueRange) - (this.minimum / RandomValueRange)); } public object Create(object request, ISpecimenContext context) diff --git a/Src/AutoFixture/RangedNumberGenerator.cs b/Src/AutoFixture/RangedNumberGenerator.cs index c2471530b..8186dc398 100644 --- a/Src/AutoFixture/RangedNumberGenerator.cs +++ b/Src/AutoFixture/RangedNumberGenerator.cs @@ -5,8 +5,8 @@ namespace AutoFixture { /// - /// Creates a strictly increasing sequence of ranged numbers, starting at range minimum. - /// Sequence restarts at range minimum when range maximum is exceeded. + /// Creates a strictly increasing sequence of ranged numbers, starting at range minimum. + /// Sequence restarts at range minimum when range maximum is exceeded. /// public class RangedNumberGenerator : ISpecimenBuilder { @@ -73,14 +73,14 @@ private void CreateAnonymous(RangedNumberRequest range, IComparable value) if (this.rangedValue != null) { object target; - if (range.OperandType == typeof(byte) && + if ((range.OperandType == typeof(byte) && Convert.ToInt32( - this.rangedValue, - CultureInfo.CurrentCulture) > byte.MaxValue || - range.OperandType == typeof(short) && + this.rangedValue, + CultureInfo.CurrentCulture) > byte.MaxValue) || + (range.OperandType == typeof(short) && Convert.ToInt32( this.rangedValue, - CultureInfo.CurrentCulture) > short.MaxValue) + CultureInfo.CurrentCulture) > short.MaxValue)) target = minimum; else target = this.rangedValue; @@ -104,7 +104,7 @@ private void CreateAnonymous(RangedNumberRequest range, IComparable value) if (maximum.CompareTo(this.rangedValue) < 0) { this.rangedValue = Convert.ChangeType( - maximum, + maximum, range.OperandType, CultureInfo.CurrentCulture); } diff --git a/Src/AutoFixture/RequestMemberTypeResolver.cs b/Src/AutoFixture/RequestMemberTypeResolver.cs index 577f70fc7..dbed6e0de 100644 --- a/Src/AutoFixture/RequestMemberTypeResolver.cs +++ b/Src/AutoFixture/RequestMemberTypeResolver.cs @@ -4,15 +4,15 @@ namespace AutoFixture { /// - /// Resolver of the member type for the class member requests (e.g. PropertyInfo, FieldInfo) + /// Resolver of the member type for the class member requests (e.g. PropertyInfo, FieldInfo). /// public class RequestMemberTypeResolver : IRequestMemberTypeResolver { /// - /// Tries to determine requested member type and returns it. + /// Tries to determine requested member type and returns it. /// - /// Relay request object - /// Output variable for resolved request member type + /// Relay request object. + /// Output variable for resolved request member type. /// public bool TryGetMemberType(object request, out Type memberType) { diff --git a/Src/AutoFixture/ResidueCollectorNode.cs b/Src/AutoFixture/ResidueCollectorNode.cs index 02dee58f2..b90b9cabf 100644 --- a/Src/AutoFixture/ResidueCollectorNode.cs +++ b/Src/AutoFixture/ResidueCollectorNode.cs @@ -35,7 +35,7 @@ public ResidueCollectorNode(ISpecimenBuilder builder) { this.Builder = builder ?? throw new ArgumentNullException(nameof(builder)); } - + /// Composes the supplied builders. /// The builders to compose. /// diff --git a/Src/AutoFixture/SByteSequenceGenerator.cs b/Src/AutoFixture/SByteSequenceGenerator.cs index 0939c638f..1caac9763 100644 --- a/Src/AutoFixture/SByteSequenceGenerator.cs +++ b/Src/AutoFixture/SByteSequenceGenerator.cs @@ -37,7 +37,7 @@ public sbyte Create() /// Creates an anonymous number. /// /// The next number in a consecutive sequence. - /// Obsolete: Please move over to using Create() as this method will be removed in the next release + /// Obsolete: Please move over to using Create() as this method will be removed in the next release. [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] [CLSCompliant(false)] public sbyte CreateAnonymous() @@ -46,12 +46,12 @@ public sbyte CreateAnonymous() } /// - /// Creates an anonymous . + /// Creates an anonymous . /// /// The request that describes what to create. /// Not used. /// - /// The next in a consecutive sequence, if + /// The next in a consecutive sequence, if /// is a request for an SByte; otherwise, a instance. /// public object Create(object request, ISpecimenContext context) diff --git a/Src/AutoFixture/SingleSequenceGenerator.cs b/Src/AutoFixture/SingleSequenceGenerator.cs index ff732dbbd..70735e14e 100644 --- a/Src/AutoFixture/SingleSequenceGenerator.cs +++ b/Src/AutoFixture/SingleSequenceGenerator.cs @@ -36,7 +36,7 @@ public float Create() /// Creates an anonymous number. /// /// The next number in a consecutive sequence. - /// Obsolete: Please move over to using Create() as this method will be removed in the next release + /// Obsolete: Please move over to using Create() as this method will be removed in the next release. [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] public float CreateAnonymous() { @@ -50,7 +50,7 @@ public float CreateAnonymous() /// Not used. /// /// The next number in a consecutive sequence, if is a request - /// for a ; otherwise, a instance. + /// for a ; otherwise, a instance. /// public object Create(object request, ISpecimenContext context) { diff --git a/Src/AutoFixture/SingletonSpecimenBuilderNodeStackAdapterCollection.cs b/Src/AutoFixture/SingletonSpecimenBuilderNodeStackAdapterCollection.cs index 8a67c0a58..ce1227a4a 100644 --- a/Src/AutoFixture/SingletonSpecimenBuilderNodeStackAdapterCollection.cs +++ b/Src/AutoFixture/SingletonSpecimenBuilderNodeStackAdapterCollection.cs @@ -66,7 +66,7 @@ public class SingletonSpecimenBuilderNodeStackAdapterCollection : Collection @@ -181,7 +181,8 @@ protected virtual void OnGraphChanged(SpecimenBuilderNodeEventArgs e) handler(this, e); } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "ISpecimenBuilderNode"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "ISpecimenBuilderTransformation", Justification = "Workaround for a bug in CA: https://connect.microsoft.com/VisualStudio/feedback/details/521030/")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "ISpecimenBuilderNode", Justification = "Workaround for a bug in CA: https://connect.microsoft.com/VisualStudio/feedback/details/521030/")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "ISpecimenBuilderTransformation", Justification = "Workaround for a bug in CA: https://connect.microsoft.com/VisualStudio/feedback/details/521030/")] private void UpdateGraph() { ISpecimenBuilderNode g = this.Graph.FindFirstNode(this.isWrappedGraph); diff --git a/Src/AutoFixture/SpecimenBuilderNodeAdapterCollection.cs b/Src/AutoFixture/SpecimenBuilderNodeAdapterCollection.cs index 353e40922..e154ed60c 100644 --- a/Src/AutoFixture/SpecimenBuilderNodeAdapterCollection.cs +++ b/Src/AutoFixture/SpecimenBuilderNodeAdapterCollection.cs @@ -32,12 +32,12 @@ private ISpecimenBuilderNode AdaptedBuilderNode // Usually during the Fixture construction it's customized a lot of times. // Some of the collections are not even touched after the construction and are immediately // recreated again after a subsequent customization. - // To cover such scenarios we evaluate value on demand only saving the initialization time. + // To cover such scenarios we evaluate value on demand only saving the initialization time. if (this.adaptedBuilderNode != null) return this.adaptedBuilderNode; // The intermediate "result" variable is needed to ensure that null value can be never returned - // in case of concurrency (we can set field to null). While current collection implementation doesn't + // in case of concurrency (we can set field to null). While current collection implementation doesn't // seem to support concurrency, the additional guard adds more safety. var result = this.adaptedBuilderNode = this.FindAdaptedSpecimenBuilderNode(); return result; @@ -48,7 +48,6 @@ private ISpecimenBuilderNode AdaptedBuilderNode private IEnumerable AdaptedBuilders => this.AdaptedBuilderNode; - /// /// Initializes a new instance of the /// class. @@ -190,14 +189,8 @@ public void RemoveAt(int index) /// public ISpecimenBuilder this[int index] { - get - { - return this.AdaptedBuilders.ElementAt(index); - } - set - { - this.Mutate(this.AdaptedBuilders.SetItem(index, value)); - } + get => this.AdaptedBuilders.ElementAt(index); + set => this.Mutate(this.AdaptedBuilders.SetItem(index, value)); } /// @@ -447,7 +440,7 @@ protected virtual void OnGraphChanged(SpecimenBuilderNodeEventArgs e) private void Mutate(IEnumerable builders) { var adaptedNode = this.AdaptedBuilderNode; - + this.Graph = this.Graph.ReplaceNodes( with: builders, when: adaptedNode.Equals); @@ -456,7 +449,7 @@ private void Mutate(IEnumerable builders) private ISpecimenBuilderNode FindAdaptedSpecimenBuilderNode() { var markerNode = this.Graph.FindFirstNode(this.isAdaptedBuilder); - return (ISpecimenBuilderNode) markerNode.First(); + return (ISpecimenBuilderNode)markerNode.First(); } } } diff --git a/Src/AutoFixture/SpecimenBuilderNodeEventArgs.cs b/Src/AutoFixture/SpecimenBuilderNodeEventArgs.cs index f38739bff..e721cf87c 100644 --- a/Src/AutoFixture/SpecimenBuilderNodeEventArgs.cs +++ b/Src/AutoFixture/SpecimenBuilderNodeEventArgs.cs @@ -14,7 +14,7 @@ public class SpecimenBuilderNodeEventArgs : EventArgs /// class. /// /// The graph associated with an event. - /// graph + /// graph. public SpecimenBuilderNodeEventArgs(ISpecimenBuilderNode graph) { this.Graph = graph ?? throw new ArgumentNullException(nameof(graph)); diff --git a/Src/AutoFixture/SpecimenCommand.cs b/Src/AutoFixture/SpecimenCommand.cs index dfef681dd..10e26a367 100644 --- a/Src/AutoFixture/SpecimenCommand.cs +++ b/Src/AutoFixture/SpecimenCommand.cs @@ -11,74 +11,32 @@ public static class SpecimenCommand /// /// Invokes the supplied action with an anonymous parameter value. /// - /// - /// The type of the anonymous parameter. - /// - /// The builder. - /// The action to invoke. - /// - /// builder is null - /// - /// - /// action is null - /// public static void Do( this ISpecimenBuilder builder, Action action) { if (builder == null) throw new ArgumentNullException(nameof(builder)); if (action == null) throw new ArgumentNullException(nameof(action)); - + action(builder.Create()); } /// /// Invokes the supplied action with anonymous parameter values. /// - /// - /// The type of the first anonymous parameter. - /// - /// - /// The type of the second anonymous parameter. - /// - /// The builder. - /// The action to invoke. - /// - /// builder is null - /// - /// - /// action is null - /// public static void Do( this ISpecimenBuilder builder, Action action) { if (builder == null) throw new ArgumentNullException(nameof(builder)); if (action == null) throw new ArgumentNullException(nameof(action)); - + action(builder.Create(), builder.Create()); } /// /// Invokes the supplied action with anonymous parameter values. /// - /// /// - /// The type of the first anonymous parameter. - /// - /// - /// The type of the second anonymous parameter. - /// - /// - /// The type of the third anonymous parameter. - /// - /// The builder. - /// The action to invoke. - /// - /// builder is null - /// - /// - /// action is null - /// public static void Do( this ISpecimenBuilder builder, Action action) @@ -95,26 +53,6 @@ public static class SpecimenCommand /// /// Invokes the supplied action with anonymous parameter values. /// - /// - /// The type of the first anonymous parameter. - /// - /// - /// The type of the second anonymous parameter. - /// - /// - /// The type of the third anonymous parameter. - /// - /// - /// The type of the fourth anonymous parameter. - /// - /// The builder. - /// The action to invoke. - /// - /// builder is null - /// - /// - /// action is null - /// public static void Do( this ISpecimenBuilder builder, Action action) diff --git a/Src/AutoFixture/SpecimenFactory.cs b/Src/AutoFixture/SpecimenFactory.cs index 2ad134abb..bb0ed4f0f 100644 --- a/Src/AutoFixture/SpecimenFactory.cs +++ b/Src/AutoFixture/SpecimenFactory.cs @@ -31,7 +31,7 @@ public static T Create(this ISpecimenContext context) /// The type of object to create. /// The context used to resolve the type request. /// An anonymous object of type . - /// Obsolete: Please move over to using Create<T>() as this method will be removed in the next release + /// Obsolete: Please move over to using Create<T>() as this method will be removed in the next release. [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] public static T CreateAnonymous(this ISpecimenContext context) { @@ -83,7 +83,7 @@ public static T Create(this ISpecimenBuilder builder) [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Supports type inferencing.")] public static T Create(this IPostprocessComposer composer) { - return Create((ISpecimenBuilder) composer); + return Create((ISpecimenBuilder)composer); } /// @@ -92,7 +92,7 @@ public static T Create(this IPostprocessComposer composer) /// The type of object to create. /// The composer used to resolve the type request. /// An anonymous object of type . - /// Obsolete: "Please move over to using Create{T} as this method will be removed in the next release + /// Obsolete: "Please move over to using Create{T} as this method will be removed in the next release. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Supports type inferencing.")] [Obsolete("Please move over to using Create() as this method will be removed in the next release", true)] @@ -155,7 +155,7 @@ public static IEnumerable CreateMany(this ISpecimenContext context) if (context == null) throw new ArgumentNullException(nameof(context)); var rawResult = context.Resolve(new MultipleRequest(new SeededRequest(typeof(T), default(T)))); - return ((IEnumerable) rawResult).Cast(); + return ((IEnumerable)rawResult).Cast(); } /// @@ -244,7 +244,7 @@ public static IEnumerable CreateMany(this ISpecimenContext context, int co if (context == null) throw new ArgumentNullException(nameof(context)); var rawResult = context.Resolve(new FiniteSequenceRequest(new SeededRequest(typeof(T), default(T)), count)); - return ((IEnumerable) rawResult).Cast(); + return ((IEnumerable)rawResult).Cast(); } /// diff --git a/Src/AutoFixture/SpecimenQuery.cs b/Src/AutoFixture/SpecimenQuery.cs index a8e073554..dbc430aaf 100644 --- a/Src/AutoFixture/SpecimenQuery.cs +++ b/Src/AutoFixture/SpecimenQuery.cs @@ -9,22 +9,8 @@ namespace AutoFixture public static class SpecimenQuery { /// - /// Invokes the supplied function with an anonymous parameter value and - /// returns the result. + /// Invokes the supplied function with an anonymous parameter value and returns the result. /// - /// - /// The type of the anonymous parameter. - /// - /// The return type. - /// The builder. - /// The function to invoke. - /// The return value of . - /// - /// builder is null - /// - /// - /// function is null - /// public static TResult Get( this ISpecimenBuilder builder, Func function) @@ -36,25 +22,8 @@ public static class SpecimenQuery } /// - /// Invokes the supplied function with anonymous parameter values and - /// returns the result. + /// Invokes the supplied function with anonymous parameter values and returns the result. /// - /// - /// The type of the first anonymous parameter. - /// - /// - /// The type of the second anonymous parameter. - /// - /// The return type. - /// The builder. - /// The function to invoke. - /// The return value of . - /// - /// builder is null - /// - /// - /// function is null - /// public static TResult Get( this ISpecimenBuilder builder, Func function) @@ -66,28 +35,8 @@ public static class SpecimenQuery } /// - /// Invokes the supplied function with anonymous parameter values and - /// returns the result. + /// Invokes the supplied function with anonymous parameter values and returns the result. /// - /// - /// The type of the first anonymous parameter. - /// - /// - /// The type of the second anonymous parameter. - /// - /// - /// The type of the third anonymous parameter. - /// - /// The return type. - /// The builder. - /// The function to invoke. - /// The return value of . - /// - /// builder is null - /// - /// - /// function is null - /// public static TResult Get( this ISpecimenBuilder builder, Func function) @@ -102,31 +51,8 @@ public static class SpecimenQuery } /// - /// Invokes the supplied function with anonymous parameter values and - /// returns the result. + /// Invokes the supplied function with anonymous parameter values and returns the result. /// - /// - /// The type of the first anonymous parameter. - /// - /// - /// The type of the second anonymous parameter. - /// - /// - /// The type of the third anonymous parameter. - /// - /// - /// The type of the fourth anonymous parameter. - /// - /// The return type. - /// The builder. - /// The function to invoke. - /// The return value of . - /// - /// builder is null - /// - /// - /// function is null - /// public static TResult Get( this ISpecimenBuilder builder, Func function) diff --git a/Src/AutoFixture/SupportMutableValueTypesCustomization.cs b/Src/AutoFixture/SupportMutableValueTypesCustomization.cs index 1d6e01c20..1cf197a18 100644 --- a/Src/AutoFixture/SupportMutableValueTypesCustomization.cs +++ b/Src/AutoFixture/SupportMutableValueTypesCustomization.cs @@ -2,7 +2,6 @@ using AutoFixture.Kernel; namespace AutoFixture - { /// /// A customization that changes how custom are generated. Uses . @@ -10,7 +9,7 @@ namespace AutoFixture public class SupportMutableValueTypesCustomization : ICustomization { /// - /// Customizes specified fixture by adding as a default strategy for + /// Customizes specified fixture by adding as a default strategy for /// creating new custom that has only default constructor. /// /// The fixture to customize. diff --git a/Src/AutoFixture/UInt16SequenceGenerator.cs b/Src/AutoFixture/UInt16SequenceGenerator.cs index e10af1fe1..30347b6b4 100644 --- a/Src/AutoFixture/UInt16SequenceGenerator.cs +++ b/Src/AutoFixture/UInt16SequenceGenerator.cs @@ -45,7 +45,7 @@ public object Create(object request, ISpecimenContext context) { return new NoSpecimen(); } - + lock (this.syncRoot) { return ++this.u; diff --git a/Src/AutoFixture/UInt32SequenceGenerator.cs b/Src/AutoFixture/UInt32SequenceGenerator.cs index d6e9040f9..cf40354d5 100644 --- a/Src/AutoFixture/UInt32SequenceGenerator.cs +++ b/Src/AutoFixture/UInt32SequenceGenerator.cs @@ -45,7 +45,7 @@ public object Create(object request, ISpecimenContext context) { return new NoSpecimen(); } - + lock (this.syncRoot) { return ++this.u; diff --git a/Src/AutoFixture/UInt64SequenceGenerator.cs b/Src/AutoFixture/UInt64SequenceGenerator.cs index a3e39fd36..44fac4ea9 100644 --- a/Src/AutoFixture/UInt64SequenceGenerator.cs +++ b/Src/AutoFixture/UInt64SequenceGenerator.cs @@ -45,7 +45,7 @@ public object Create(object request, ISpecimenContext context) { return new NoSpecimen(); } - + lock (this.syncRoot) { return ++this.u; diff --git a/Src/AutoFixture/UriScheme.cs b/Src/AutoFixture/UriScheme.cs index bda47e6cc..ff1fe34a7 100644 --- a/Src/AutoFixture/UriScheme.cs +++ b/Src/AutoFixture/UriScheme.cs @@ -4,7 +4,7 @@ namespace AutoFixture { /// - /// Represents a URI scheme name. Scheme names consist of a sequence of characters beginning + /// Represents a URI scheme name. Scheme names consist of a sequence of characters beginning /// with a letter and followed by any combination of letters, digits, plus ('+'), period ('.'), /// or hyphen ('-'). /// @@ -38,11 +38,11 @@ public UriScheme(string scheme) } /// - /// Returns a that represents the URI scheme name for this + /// Returns a that represents the URI scheme name for this /// instance. /// /// - /// A that represents the URI scheme name for this instance. + /// A that represents the URI scheme name for this instance. /// public override string ToString() { @@ -50,12 +50,12 @@ public override string ToString() } /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// - /// The to compare with this instance. + /// The to compare with this instance. /// /// - /// true if the specified is equal to this instance; + /// true if the specified is equal to this instance; /// otherwise, false. /// /// @@ -75,8 +75,8 @@ public override bool Equals(object obj) /// Returns a hash code for this instance. /// /// - /// A hash code for this instance, suitable for use in hashing algorithms and data - /// structures like a hash table. + /// A hash code for this instance, suitable for use in hashing algorithms and data + /// structures like a hash table. /// public override int GetHashCode() { diff --git a/Src/AutoFixture/Utf8EncodingGenerator.cs b/Src/AutoFixture/Utf8EncodingGenerator.cs index 900605112..4c2c26792 100644 --- a/Src/AutoFixture/Utf8EncodingGenerator.cs +++ b/Src/AutoFixture/Utf8EncodingGenerator.cs @@ -5,7 +5,7 @@ namespace AutoFixture { /// - /// Handles creation requests for instances, + /// Handles creation requests for instances, /// returning always the same . /// [Obsolete("Please use a 'AutoFixture.Kernel.FilteringSpecimenBuilder' instead.", true)] diff --git a/Src/AutoFixtureDocumentationTest/Array/MyClassATest.cs b/Src/AutoFixtureDocumentationTest/Array/MyClassATest.cs index 2e7f2a0a6..e63e82741 100644 --- a/Src/AutoFixtureDocumentationTest/Array/MyClassATest.cs +++ b/Src/AutoFixtureDocumentationTest/Array/MyClassATest.cs @@ -30,7 +30,7 @@ public void BuiltSutWillHavePopulatedItems() var fixture = new Fixture(); // Act var mc = fixture.Build() - .With(x => x.Items, + .With(x => x.Items, fixture.CreateMany().ToArray()) .Create(); // Assert @@ -44,7 +44,7 @@ public void CustomizedSutWillHavePopulatedItems() // Arrange var fixture = new Fixture(); fixture.Customize(ob => - ob.With(x => x.Items, + ob.With(x => x.Items, fixture.CreateMany().ToArray())); // Act var mc = fixture.Create(); @@ -58,7 +58,7 @@ public void RegisterArrayWillProperlyPopulateItems() { // Arrange var fixture = new Fixture(); - fixture.Register(() => + fixture.Register(() => fixture.CreateMany().ToArray()); // Act var mc = fixture.Create(); diff --git a/Src/AutoFixtureDocumentationTest/Commerce/OrderTest.cs b/Src/AutoFixtureDocumentationTest/Commerce/OrderTest.cs index 3158bc527..0a6a4928d 100644 --- a/Src/AutoFixtureDocumentationTest/Commerce/OrderTest.cs +++ b/Src/AutoFixtureDocumentationTest/Commerce/OrderTest.cs @@ -16,7 +16,7 @@ public void BuildOrderWithShippingAddressInDenmark() var fixture = new Fixture(); // Act var order = fixture.Build() - .With(o => o.ShippingAddress, + .With(o => o.ShippingAddress, fixture.Build
() .With(a => a.Country, "Denmark") .Create()) diff --git a/Src/AutoFixtureDocumentationTest/Contact/Parsing/Contact.cs b/Src/AutoFixtureDocumentationTest/Contact/Parsing/Contact.cs index f2b05b828..96a29c865 100644 --- a/Src/AutoFixtureDocumentationTest/Contact/Parsing/Contact.cs +++ b/Src/AutoFixtureDocumentationTest/Contact/Parsing/Contact.cs @@ -5,7 +5,7 @@ public class Contact public Contact(string name, string phoneNumber) { this.Name = name; - this.PhoneNumber = + this.PhoneNumber = Contact.ParsePhoneNumber(phoneNumber); } diff --git a/Src/AutoFixtureDocumentationTest/Contact/ValidatingValueObject/ContactTest.cs b/Src/AutoFixtureDocumentationTest/Contact/ValidatingValueObject/ContactTest.cs index 99c4be8d7..f26a262a9 100644 --- a/Src/AutoFixtureDocumentationTest/Contact/ValidatingValueObject/ContactTest.cs +++ b/Src/AutoFixtureDocumentationTest/Contact/ValidatingValueObject/ContactTest.cs @@ -25,7 +25,7 @@ public void CreateWillPopulatePhoneNumber() { // Arrange Fixture fixture = new Fixture(); - fixture.Register(i => + fixture.Register(i => new DanishPhoneNumber(i + 112)); Contact sut = fixture.Create(); // Act @@ -40,7 +40,7 @@ public void UsingPhoneNumberMinValue() // Arrange Fixture fixture = new Fixture(); fixture.Register(i => - new DanishPhoneNumber(i + + new DanishPhoneNumber(i + DanishPhoneNumber.MinValue)); Contact sut = fixture.Create(); // Act diff --git a/Src/AutoFixtureDocumentationTest/Contact/ValidatingValueObject/DanishPhoneNumber.cs b/Src/AutoFixtureDocumentationTest/Contact/ValidatingValueObject/DanishPhoneNumber.cs index 06b978436..ea75eb9e5 100644 --- a/Src/AutoFixtureDocumentationTest/Contact/ValidatingValueObject/DanishPhoneNumber.cs +++ b/Src/AutoFixtureDocumentationTest/Contact/ValidatingValueObject/DanishPhoneNumber.cs @@ -17,7 +17,7 @@ public DanishPhoneNumber(int number) public static bool IsValid(int number) { - return (112 <= number) + return (number >= 112) && (number <= 99999999); } diff --git a/Src/AutoFixtureDocumentationTest/Extension/Constraints/ConstrainedStringGenerator.cs b/Src/AutoFixtureDocumentationTest/Extension/Constraints/ConstrainedStringGenerator.cs index efa65ba8c..463c9123e 100644 --- a/Src/AutoFixtureDocumentationTest/Extension/Constraints/ConstrainedStringGenerator.cs +++ b/Src/AutoFixtureDocumentationTest/Extension/Constraints/ConstrainedStringGenerator.cs @@ -7,7 +7,7 @@ public class ConstrainedStringGenerator private readonly int minimumLength; private readonly int maximumLength; - public ConstrainedStringGenerator(int minimumLength, + public ConstrainedStringGenerator(int minimumLength, int maximumLength) { if (maximumLength < 0) diff --git a/Src/AutoFixtureDocumentationTest/Extension/Constraints/ObjectBuilderExtensionTest.cs b/Src/AutoFixtureDocumentationTest/Extension/Constraints/ObjectBuilderExtensionTest.cs index cf8c3af27..00ddd7d81 100644 --- a/Src/AutoFixtureDocumentationTest/Extension/Constraints/ObjectBuilderExtensionTest.cs +++ b/Src/AutoFixtureDocumentationTest/Extension/Constraints/ObjectBuilderExtensionTest.cs @@ -34,7 +34,7 @@ public void CreateMyClassWithPropertyConstrainedAsInTheFeatureRequest() .With(x => x.SomeText, 0, 100) .Create(); // Assert - Assert.True(0 <= mc.SomeText.Length && mc.SomeText.Length <= 100, "SomeText within constraints."); + Assert.True(mc.SomeText.Length >= 0 && mc.SomeText.Length <= 100, "SomeText within constraints."); } } } diff --git a/Src/AutoFixtureDocumentationTest/Intermediate/MyClassTest.cs b/Src/AutoFixtureDocumentationTest/Intermediate/MyClassTest.cs index e667b2954..d1b65958f 100644 --- a/Src/AutoFixtureDocumentationTest/Intermediate/MyClassTest.cs +++ b/Src/AutoFixtureDocumentationTest/Intermediate/MyClassTest.cs @@ -36,7 +36,7 @@ public void NumberSumIsCorrect_DerivedFixture() MyClassFixture fixture = new MyClassFixture(); fixture.AddManyTo(fixture.Things); - int expectedSum = + int expectedSum = fixture.Things.Select(t => t.Number).Sum(); MyClass sut = fixture.Create(); // Act diff --git a/Src/AutoFixtureDocumentationTest/Intermediate/Person.cs b/Src/AutoFixtureDocumentationTest/Intermediate/Person.cs index 6c1136ffd..24a157fba 100644 --- a/Src/AutoFixtureDocumentationTest/Intermediate/Person.cs +++ b/Src/AutoFixtureDocumentationTest/Intermediate/Person.cs @@ -10,9 +10,9 @@ public class Person public string Name { get; set; } - public Person Spouse + public Person Spouse { - get { return this.spouse; } + get => this.spouse; set { this.spouse = value; diff --git a/Src/AutoFixtureDocumentationTest/Intermediate/RegisterExample.cs b/Src/AutoFixtureDocumentationTest/Intermediate/RegisterExample.cs index fa9d47838..b38afdd3d 100644 --- a/Src/AutoFixtureDocumentationTest/Intermediate/RegisterExample.cs +++ b/Src/AutoFixtureDocumentationTest/Intermediate/RegisterExample.cs @@ -26,7 +26,7 @@ public void CreatingMyClassIsNotPossibleWithoutRegister() public void SimpleRegister() { Fixture fixture = new Fixture(); - fixture.Register(() => + fixture.Register(() => new FakeMyInterface()); MyClass sut = fixture.Create(); @@ -40,7 +40,7 @@ public void ManuallyRegisteringWithAnonymousParameter() Fixture fixture = new Fixture(); int anonymousNumber = fixture.Create(); string knownText = "This text is not anonymous"; - fixture.Register(() => + fixture.Register(() => new FakeMyInterface(anonymousNumber, knownText)); // Act MyClass sut = fixture.Create(); @@ -54,7 +54,7 @@ public void RegisterWithAnonymousParameter() // Arrange Fixture fixture = new Fixture(); string knownText = "This text is not anonymous"; - fixture.Register((i, s) => + fixture.Register((i, s) => new FakeMyInterface(i, knownText)); // Act MyClass sut = fixture.Create(); diff --git a/Src/AutoFixtureDocumentationTest/Multiple/General/StableFiniteSequenceCustomization.cs b/Src/AutoFixtureDocumentationTest/Multiple/General/StableFiniteSequenceCustomization.cs index 6f5a1e9a8..d89c949b7 100644 --- a/Src/AutoFixtureDocumentationTest/Multiple/General/StableFiniteSequenceCustomization.cs +++ b/Src/AutoFixtureDocumentationTest/Multiple/General/StableFiniteSequenceCustomization.cs @@ -8,7 +8,7 @@ public class StableFiniteSequenceCustomization : { public void Customize(IFixture fixture) { - var stableRelay = + var stableRelay = new StableFiniteSequenceRelay(); fixture.Customizations.Add(stableRelay); } diff --git a/Src/AutoFixtureDocumentationTest/Multiple/Specific/Scenario.cs b/Src/AutoFixtureDocumentationTest/Multiple/Specific/Scenario.cs index af7f8f5d6..34a137ca7 100644 --- a/Src/AutoFixtureDocumentationTest/Multiple/Specific/Scenario.cs +++ b/Src/AutoFixtureDocumentationTest/Multiple/Specific/Scenario.cs @@ -68,7 +68,7 @@ public void CreatePopulatedCollection() public void CreatePopulatedListInterface() { var fixture = new Fixture(); - fixture.Register>(() => + fixture.Register>(() => fixture.CreateMany().ToList()); var list = fixture.Create>(); Assert.True(list.Any()); diff --git a/Src/AutoFixtureDocumentationTest/Properties/AssemblyInfo.cs b/Src/AutoFixtureDocumentationTest/Properties/AssemblyInfo.cs index e6177391f..3b40cd860 100644 --- a/Src/AutoFixtureDocumentationTest/Properties/AssemblyInfo.cs +++ b/Src/AutoFixtureDocumentationTest/Properties/AssemblyInfo.cs @@ -3,8 +3,8 @@ [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixtureDocumentationTest/Simple/DocumentationExample.cs b/Src/AutoFixtureDocumentationTest/Simple/DocumentationExample.cs index 21fb1a0d2..d2abb70f2 100644 --- a/Src/AutoFixtureDocumentationTest/Simple/DocumentationExample.cs +++ b/Src/AutoFixtureDocumentationTest/Simple/DocumentationExample.cs @@ -323,7 +323,7 @@ public void CreateAnonymousFilterWillThrow() var fixture = new Fixture(); fixture.Customizations.Add(new NumericSequenceGenerator()); // Act & Assert - Assert.ThrowsAny(()=> + Assert.ThrowsAny(() => fixture.Create()); } diff --git a/Src/AutoFixtureDocumentationTest/Simple/Filter.cs b/Src/AutoFixtureDocumentationTest/Simple/Filter.cs index 029b68842..d0f7efbe6 100644 --- a/Src/AutoFixtureDocumentationTest/Simple/Filter.cs +++ b/Src/AutoFixtureDocumentationTest/Simple/Filter.cs @@ -9,7 +9,7 @@ public class Filter public int Max { - get { return this.max; } + get => this.max; set { if (value < this.Min) @@ -22,7 +22,7 @@ public int Max public int Min { - get { return this.min; } + get => this.min; set { if (value > this.Max) diff --git a/Src/AutoFixtureDocumentationTest/Simple/MyViewModel.cs b/Src/AutoFixtureDocumentationTest/Simple/MyViewModel.cs index 5287ceec5..73217fe5f 100644 --- a/Src/AutoFixtureDocumentationTest/Simple/MyViewModel.cs +++ b/Src/AutoFixtureDocumentationTest/Simple/MyViewModel.cs @@ -20,8 +20,8 @@ public ICollection AvailableItems public MyClass SelectedItem { - get { return this.selectedItem; } - set + get => this.selectedItem; + set { if (!this.availableItems.Contains(value)) { diff --git a/Src/AutoFixtureDocumentationTest/Simple/SomeImp.cs b/Src/AutoFixtureDocumentationTest/Simple/SomeImp.cs index 9df684bcf..d657d5d42 100644 --- a/Src/AutoFixtureDocumentationTest/Simple/SomeImp.cs +++ b/Src/AutoFixtureDocumentationTest/Simple/SomeImp.cs @@ -9,7 +9,7 @@ public class SomeImp : IBadDesign public string Message { - get { return this.message; } + get => this.message; set { if (this.mc == null) diff --git a/Src/AutoFixtureDocumentationTest/Simple/TestConsole.cs b/Src/AutoFixtureDocumentationTest/Simple/TestConsole.cs index 7eb6417fa..b57711e97 100644 --- a/Src/AutoFixtureDocumentationTest/Simple/TestConsole.cs +++ b/Src/AutoFixtureDocumentationTest/Simple/TestConsole.cs @@ -1,4 +1,4 @@ -//#define ALLOWCONSOLE +// #define ALLOWCONSOLE namespace AutoFixtureDocumentationTest.Simple { diff --git a/Src/AutoFixtureUnitTest/AbstractRecursionIssue/Repro.cs b/Src/AutoFixtureUnitTest/AbstractRecursionIssue/Repro.cs index 328566476..8d321f0a2 100644 --- a/Src/AutoFixtureUnitTest/AbstractRecursionIssue/Repro.cs +++ b/Src/AutoFixtureUnitTest/AbstractRecursionIssue/Repro.cs @@ -9,7 +9,7 @@ public class Repro { /// /// This test reproduces the issue exactly as reported at - /// https://github.com/AutoFixture/AutoFixture/issues/3 + /// https://github.com/AutoFixture/AutoFixture/issues/3. /// [Fact] public void IssueAsReported() diff --git a/Src/AutoFixtureUnitTest/CompositeCustomizationTest.cs b/Src/AutoFixtureUnitTest/CompositeCustomizationTest.cs index 0b92f1773..0ab097b4a 100644 --- a/Src/AutoFixtureUnitTest/CompositeCustomizationTest.cs +++ b/Src/AutoFixtureUnitTest/CompositeCustomizationTest.cs @@ -81,9 +81,9 @@ public void CustomizeCustomizesFixtureForAllCustomizations() var verifications = new List(); var customizations = new[] { - new DelegatingCustomization { OnCustomize = f => verifications.Add(f == fixture)}, - new DelegatingCustomization { OnCustomize = f => verifications.Add(f == fixture)}, - new DelegatingCustomization { OnCustomize = f => verifications.Add(f == fixture)} + new DelegatingCustomization { OnCustomize = f => verifications.Add(f == fixture) }, + new DelegatingCustomization { OnCustomize = f => verifications.Add(f == fixture) }, + new DelegatingCustomization { OnCustomize = f => verifications.Add(f == fixture) } }; var sut = new CompositeCustomization(customizations); diff --git a/Src/AutoFixtureUnitTest/ConstrainedStringGeneratorTest.cs b/Src/AutoFixtureUnitTest/ConstrainedStringGeneratorTest.cs index adfea611d..99ee98bae 100644 --- a/Src/AutoFixtureUnitTest/ConstrainedStringGeneratorTest.cs +++ b/Src/AutoFixtureUnitTest/ConstrainedStringGeneratorTest.cs @@ -121,9 +121,9 @@ public void CreateReturnsStringWithCorrectLengthMultipleCall(int minimumLength, }; var sut = new ConstrainedStringGenerator(); // Act - var result = (from s in Enumerable.Range(1, 30).Select(i => (string)sut.Create(request, context)) - where (s.Length <= request.MinimumLength || s.Length > request.MaximumLength) - select s); + var result = from s in Enumerable.Range(1, 30).Select(i => (string)sut.Create(request, context)) + where s.Length <= request.MinimumLength || s.Length > request.MaximumLength + select s; // Assert Assert.False(result.Any()); } diff --git a/Src/AutoFixtureUnitTest/DataAnnotations/DataAnnotationsSupportNodeTest.cs b/Src/AutoFixtureUnitTest/DataAnnotations/DataAnnotationsSupportNodeTest.cs index 8d8dfabb1..e4795b2ce 100644 --- a/Src/AutoFixtureUnitTest/DataAnnotations/DataAnnotationsSupportNodeTest.cs +++ b/Src/AutoFixtureUnitTest/DataAnnotations/DataAnnotationsSupportNodeTest.cs @@ -74,7 +74,7 @@ public void ShouldComposeCorrectly() var sut = new DataAnnotationsSupportNode(new DelegatingSpecimenBuilder()); var newBuilder = new DelegatingSpecimenBuilder(); // Act - var result = sut.Compose(new []{newBuilder}); + var result = sut.Compose(new[] { newBuilder }); // Assert var castedResult = Assert.IsType(result); Assert.Equal(newBuilder, castedResult.Builder); diff --git a/Src/AutoFixtureUnitTest/DataAnnotations/RangeValidatedType.cs b/Src/AutoFixtureUnitTest/DataAnnotations/RangeValidatedType.cs index e338befbb..98f9a4e46 100644 --- a/Src/AutoFixtureUnitTest/DataAnnotations/RangeValidatedType.cs +++ b/Src/AutoFixtureUnitTest/DataAnnotations/RangeValidatedType.cs @@ -67,8 +67,12 @@ public class RangeValidatedType [Range(Minimum, float.MaxValue)] public float PropertyWithMaximumFloatMaxValue { get; set; } - public void MethodWithRangedParameter([Range(Minimum, Maximum)] decimal argument) { } + public void MethodWithRangedParameter([Range(Minimum, Maximum)] decimal argument) + { + } - public void MethodWithRangedNullableParameter([Range(Minimum, Maximum)] decimal? argument) { } + public void MethodWithRangedNullableParameter([Range(Minimum, Maximum)] decimal? argument) + { + } } } \ No newline at end of file diff --git a/Src/AutoFixtureUnitTest/DataAnnotations/RangedRequestTest.cs b/Src/AutoFixtureUnitTest/DataAnnotations/RangedRequestTest.cs index 6d4a71694..2d0ade964 100644 --- a/Src/AutoFixtureUnitTest/DataAnnotations/RangedRequestTest.cs +++ b/Src/AutoFixtureUnitTest/DataAnnotations/RangedRequestTest.cs @@ -17,7 +17,6 @@ public void ShouldFailWithArgumentExceptionForNullArguments(Type memberType, Typ // Act & assert Assert.Throws(() => new RangedRequest(memberType, operandType, min, max)); - } [Fact] @@ -37,7 +36,6 @@ public void PropertiesShouldReturnPassedToConstructorValues() Assert.Equal(operandType, sut.OperandType); Assert.Equal(min, sut.Minimum); Assert.Equal(max, sut.Maximum); - } [Fact] @@ -203,12 +201,12 @@ public void HashCodeIsSameWhenAllMembersAreSame() } [Theory] - [InlineData((int)42)] - [InlineData((uint)42)] - [InlineData((long)42)] - [InlineData((ulong)42)] - [InlineData((double)42.0)] - [InlineData((float)42.0f)] + [InlineData(42)] + [InlineData(42U)] + [InlineData(42L)] + [InlineData(42UL)] + [InlineData(42.0D)] + [InlineData(42.0F)] [InlineData("42")] public void ShouldCorrectlyConvertMinimum(object bounaryValue) { @@ -223,12 +221,12 @@ public void ShouldCorrectlyConvertMinimum(object bounaryValue) } [Theory] - [InlineData((int)42)] - [InlineData((uint)42)] - [InlineData((long)42)] - [InlineData((ulong)42)] - [InlineData((double)42.0)] - [InlineData((float)42.0f)] + [InlineData(42)] + [InlineData(42U)] + [InlineData(42L)] + [InlineData(42UL)] + [InlineData(42.0D)] + [InlineData(42.0F)] [InlineData("42")] public void ShouldCorrectlyConvertMaximum(object bounaryValue) { @@ -300,7 +298,6 @@ public void ToStringShouldBeOverridden() Assert.Contains("Int64", stringResult); Assert.Contains("42", stringResult); Assert.Contains("100", stringResult); - } } } \ No newline at end of file diff --git a/Src/AutoFixtureUnitTest/DataAnnotations/TimeSpanRangedRequestRelayTest.cs b/Src/AutoFixtureUnitTest/DataAnnotations/TimeSpanRangedRequestRelayTest.cs index 6436ec125..5a1ff7779 100644 --- a/Src/AutoFixtureUnitTest/DataAnnotations/TimeSpanRangedRequestRelayTest.cs +++ b/Src/AutoFixtureUnitTest/DataAnnotations/TimeSpanRangedRequestRelayTest.cs @@ -18,7 +18,6 @@ public void SutShouldBeASpecimenBuilder() Assert.IsAssignableFrom(sut); } - [Fact] public void ShouldFailForNullContext() { @@ -58,7 +57,7 @@ public void ShouldHandleRequestOfTimeSpanType() var context = new DelegatingSpecimenContext { - OnResolve = _ => 30 * 60 * 1000.0 //30 (chosen randomly) minutes in miliseconds + OnResolve = _ => 30 * 60 * 1000.0 // 30 (chosen randomly) minutes in miliseconds }; // Act diff --git a/Src/AutoFixtureUnitTest/DelegatingEqualityComparer.cs b/Src/AutoFixtureUnitTest/DelegatingEqualityComparer.cs index 1be2e56f3..17089f583 100644 --- a/Src/AutoFixtureUnitTest/DelegatingEqualityComparer.cs +++ b/Src/AutoFixtureUnitTest/DelegatingEqualityComparer.cs @@ -18,8 +18,8 @@ bool IEqualityComparer.Equals(object x, object y) int IEqualityComparer.GetHashCode(object obj) { - // It's not safe to assume anything about how OnEquals is going to [effectively] - // 'bucket' results, so make no assumptions that could lead to false negatives. + // It's not safe to assume anything about how OnEquals is going to [effectively] + // 'bucket' results, so make no assumptions that could lead to false negatives. // See http://stackoverflow.com/a/3719617 return 0; } @@ -41,8 +41,8 @@ bool IEqualityComparer.Equals(T x, T y) int IEqualityComparer.GetHashCode(T obj) { - // It's not safe to assume anything about how OnEquals is going to [effectively] - // 'bucket' results, so make no assumptions that could lead to false negatives. + // It's not safe to assume anything about how OnEquals is going to [effectively] + // 'bucket' results, so make no assumptions that could lead to false negatives. // See http://stackoverflow.com/a/3719617 return 0; } diff --git a/Src/AutoFixtureUnitTest/DelegatingRecursionGuard.cs b/Src/AutoFixtureUnitTest/DelegatingRecursionGuard.cs index b55b6f8df..ead28c9e2 100644 --- a/Src/AutoFixtureUnitTest/DelegatingRecursionGuard.cs +++ b/Src/AutoFixtureUnitTest/DelegatingRecursionGuard.cs @@ -28,7 +28,6 @@ public DelegatingRecursionGuard(ISpecimenBuilder builder) { } - [Obsolete] public override object HandleRecursiveRequest(object request) { @@ -40,7 +39,7 @@ public override ISpecimenBuilderNode Compose(IEnumerable build return new DelegatingRecursionGuard(new CompositeSpecimenBuilder(builders)); } - internal IEnumerable UnprotectedRecordedRequests + internal IEnumerable UnprotectedRecordedRequests { get { return this.RecordedRequests.Cast(); } } diff --git a/Src/AutoFixtureUnitTest/Dsl/NodeComposerTest.cs b/Src/AutoFixtureUnitTest/Dsl/NodeComposerTest.cs index cea205554..6e3ef1840 100644 --- a/Src/AutoFixtureUnitTest/Dsl/NodeComposerTest.cs +++ b/Src/AutoFixtureUnitTest/Dsl/NodeComposerTest.cs @@ -286,7 +286,7 @@ public void SecondDoReturnsCorrectResult() // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer>(); Action> dummy = _ => { }; - Action> a = ph => ph.Property = ""; + Action> a = ph => ph.Property = string.Empty; // Act var actual = sut.Do(dummy).Do(a); // Assert @@ -444,8 +444,7 @@ public void WithExplicitValueReturnsCorrectResult(string value) new EqualRequestSpecification( pi, new MemberInfoEqualityComparer()))), - new FalseRequestSpecification() - ), + new FalseRequestSpecification()), new BindingCommand, string>(x => x.Property, value), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder)), diff --git a/Src/AutoFixtureUnitTest/EmailAddressLocalPartGeneratorTest.cs b/Src/AutoFixtureUnitTest/EmailAddressLocalPartGeneratorTest.cs index cf4296e78..44171c50c 100644 --- a/Src/AutoFixtureUnitTest/EmailAddressLocalPartGeneratorTest.cs +++ b/Src/AutoFixtureUnitTest/EmailAddressLocalPartGeneratorTest.cs @@ -119,6 +119,5 @@ public void CreateReturnsNoSpecimenWhenContextCreatesInvalidLocalPartString(stri var expectedResult = new NoSpecimen(); Assert.Equal(expectedResult, result); } - } } diff --git a/Src/AutoFixtureUnitTest/FixtureResolvingItselfTests.cs b/Src/AutoFixtureUnitTest/FixtureResolvingItselfTests.cs index 9cc211a28..be10ed453 100644 --- a/Src/AutoFixtureUnitTest/FixtureResolvingItselfTests.cs +++ b/Src/AutoFixtureUnitTest/FixtureResolvingItselfTests.cs @@ -18,7 +18,13 @@ public void FixtureCanResolveItself() } } - public class FixtureResolvingItselfTestsOfFixture : FixtureResolvingItselfTests { } - public class FixtureResolvingItselfTestsOfFixtureInterface : FixtureResolvingItselfTests { } - public class FixtureResolvingItselfTestsOfSpecimenBuilder : FixtureResolvingItselfTests { } + public class FixtureResolvingItselfTestsOfFixture : FixtureResolvingItselfTests + { + } + public class FixtureResolvingItselfTestsOfFixtureInterface : FixtureResolvingItselfTests + { + } + public class FixtureResolvingItselfTestsOfSpecimenBuilder : FixtureResolvingItselfTests + { + } } diff --git a/Src/AutoFixtureUnitTest/FixtureTest.cs b/Src/AutoFixtureUnitTest/FixtureTest.cs index 049fb8807..7353f813a 100644 --- a/Src/AutoFixtureUnitTest/FixtureTest.cs +++ b/Src/AutoFixtureUnitTest/FixtureTest.cs @@ -318,7 +318,6 @@ IEnumerable GetPropertyAndFieldValues(object obj, BindingFlags flags) .SelectMany(t => t.SelectMany(s => s.ValuesNotPopulated)); Assert.Empty(allValuesNotPopulated); - } [Fact] @@ -824,11 +823,11 @@ public void CreateAnonymousWithRandomNumericSequenceCustomizationReturnsRandomNu var definedNumbers = new object[] { 1, - (uint)2, + 2U, (byte)3, (sbyte)4, - (long)5, - (ulong)6, + 5L, + 6UL, (short)7, (ushort)8, 9.0F, @@ -868,8 +867,7 @@ public void InjectCustomUpperLimitWillCauseSutToReturnNumbersInLimit() // Assert Assert.True( (result.Property1 >= lower && result.Property1 <= upper) && - (result.Property2 >= lower && result.Property2 <= upper) - ); + (result.Property2 >= lower && result.Property2 <= upper)); } [Fact] @@ -1209,7 +1207,7 @@ public void CreateAnonymousWithRangeValidatedDecimalPropertyReturnsCorrectResult var result = fixture.Create(); // Assert Assert.True( - RangeValidatedType.Minimum <= result.Property && result.Property <= RangeValidatedType.Maximum, + result.Property >= RangeValidatedType.Minimum && result.Property <= RangeValidatedType.Maximum, string.Format( "Expected result to fall into the interval [{0}, {1}], but was {2}", RangeValidatedType.Minimum, @@ -1411,9 +1409,9 @@ public void CreateAnonymousWithRangeValidatedDecimalPropertyReturnsCorrectResult // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property) - where (n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property) + where n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum + select n; // Assert Assert.False(result.Any()); } @@ -1425,9 +1423,9 @@ public void CreateAnonymousWithRangeValidatedDecimalFieldReturnsCorrectResultFor // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Field) - where (n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Field) + where n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum + select n; // Assert Assert.False(result.Any()); } @@ -1439,9 +1437,9 @@ public void CreateAnonymousWithRangeValidatedDoublePropertyReturnsCorrectResultF // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property2) - where (n < RangeValidatedType.DoubleMinimum && n > RangeValidatedType.DoubleMaximum) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property2) + where n < RangeValidatedType.DoubleMinimum && n > RangeValidatedType.DoubleMaximum + select n; // Assert Assert.False(result.Any()); } @@ -1453,9 +1451,9 @@ public void CreateAnonymousWithRangeValidatedDecimalPropertyReturnsCorrectResult // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property3) - where (n < Convert.ToDecimal(RangeValidatedType.DoubleMinimum) && n > Convert.ToDecimal(RangeValidatedType.DoubleMaximum)) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property3) + where n < Convert.ToDecimal(RangeValidatedType.DoubleMinimum) && n > Convert.ToDecimal(RangeValidatedType.DoubleMaximum) + select n; // Assert Assert.False(result.Any()); } @@ -1467,9 +1465,9 @@ public void CreateAnonymousWithRangeValidatedDecimalPropertyReturnsCorrectResult // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property4) - where (n < Convert.ToDecimal(RangeValidatedType.StringMinimum) && n > Convert.ToDecimal(RangeValidatedType.StringMaximum)) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property4) + where n < Convert.ToDecimal(RangeValidatedType.StringMinimum) && n > Convert.ToDecimal(RangeValidatedType.StringMaximum) + select n; // Assert Assert.False(result.Any()); } @@ -1481,9 +1479,9 @@ public void CreateAnonymousWithRangeValidatedIntegerPropertyReturnsCorrectResult // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property5) - where (n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property5) + where n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum + select n; // Assert Assert.False(result.Any()); } @@ -1495,9 +1493,9 @@ public void CreateAnonymousWithRangeValidatedBytePropertyReturnsCorrectResultFor // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property6) - where (n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property6) + where n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum + select n; // Assert Assert.False(result.Any()); } @@ -1509,9 +1507,9 @@ public void CreateAnonymousWithRangeValidatedShortPropertyReturnsCorrectResultFo // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property7) - where (n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property7) + where n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum + select n; // Assert Assert.False(result.Any()); } @@ -1523,9 +1521,9 @@ public void CreateAnonymousWithRangeValidatedUnsignedShortPropertyReturnsCorrect // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().UnsignedShortProperty) - where (n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().UnsignedShortProperty) + where n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum + select n; // Assert Assert.False(result.Any()); } @@ -1537,9 +1535,9 @@ public void CreateAnonymousWithRangeValidatedUnsignedIntPropertyReturnsCorrectRe // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().UnsignedIntProperty) - where (n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().UnsignedIntProperty) + where n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum + select n; // Assert Assert.False(result.Any()); } @@ -1551,9 +1549,9 @@ public void CreateAnonymousWithRangeValidatedUnsignedLongPropertyReturnsCorrectR // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().UnsignedLongProperty) - where (n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().UnsignedLongProperty) + where n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum + select n; // Assert Assert.False(result.Any()); } @@ -1565,9 +1563,9 @@ public void CreateAnonymousWithRangeValidatedSignedBytePropertyReturnsCorrectRes // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().SignedByteProperty) - where (n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().SignedByteProperty) + where n < RangeValidatedType.Minimum && n > RangeValidatedType.Maximum + select n; // Assert Assert.False(result.Any()); } @@ -1579,9 +1577,9 @@ public void CreateAnonymousWithRangeValidatedDoublePropertyReturnsCorrectResultF // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().PropertyWithMinimumDoubleMinValue) - where (n > Convert.ToDouble(RangeValidatedType.Maximum)) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().PropertyWithMinimumDoubleMinValue) + where n > Convert.ToDouble(RangeValidatedType.Maximum) + select n; // Assert Assert.False(result.Any()); } @@ -1593,9 +1591,9 @@ public void CreateAnonymousWithRangeValidatedDoublePropertyReturnsCorrectResultF // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().PropertyWithMaximumDoubleMaxValue) - where (n < Convert.ToDouble(RangeValidatedType.Minimum)) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().PropertyWithMaximumDoubleMaxValue) + where n < Convert.ToDouble(RangeValidatedType.Minimum) + select n; // Assert Assert.False(result.Any()); } @@ -1607,9 +1605,9 @@ public void CreateAnonymousWithRangeValidatedFloatPropertyReturnsCorrectResultFo // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().PropertyWithMinimumFloatMinValue) - where (n > Convert.ToSingle(RangeValidatedType.Maximum)) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().PropertyWithMinimumFloatMinValue) + where n > Convert.ToSingle(RangeValidatedType.Maximum) + select n; // Assert Assert.False(result.Any()); } @@ -1621,9 +1619,9 @@ public void CreateAnonymousWithRangeValidatedFloatPropertyReturnsCorrectResultFo // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().PropertyWithMaximumFloatMaxValue) - where (n < Convert.ToSingle(RangeValidatedType.Minimum)) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().PropertyWithMaximumFloatMaxValue) + where n < Convert.ToSingle(RangeValidatedType.Minimum) + select n; // Assert Assert.False(result.Any()); } @@ -1654,9 +1652,9 @@ public void CreateAnonymousWithStringLengthValidatedReturnsCorrectResultMultiple // Arrange var fixture = new Fixture(); // Act - var result = (from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property.Length) - where (n > StringLengthValidatedType.MaximumLength) - select n); + var result = from n in Enumerable.Range(1, 33).Select(i => fixture.Create().Property.Length) + where n > StringLengthValidatedType.MaximumLength + select n; // Assert Assert.False(result.Any()); } @@ -2163,7 +2161,11 @@ public void GetOnQueryWithSingleParameterWillInvokeMethod() var sut = new Fixture(); var mock = new QueryMock(); - mock.OnQuery = x => { methodInvoked = true; return true; }; + mock.OnQuery = x => + { + methodInvoked = true; + return true; + }; // Act sut.Get((ulong s) => mock.Query(s)); // Assert @@ -2180,7 +2182,11 @@ public void GetOnQueryWithSingleParameterWillInvokeMethodWithCorrectParameter() sut.Register(() => expectedNumber); var mock = new QueryMock(); - mock.OnQuery = x => { Assert.Equal(expectedNumber, x); return "Anonymous text"; }; + mock.OnQuery = x => + { + Assert.Equal(expectedNumber, x); + return "Anonymous text"; + }; // Act sut.Get((double? x) => mock.Query(x)); // Assert (done by mock) @@ -2219,7 +2225,11 @@ public void GetOnQueryWithTwoParametersWillInvokeMethod() var sut = new Fixture(); var mock = new QueryMock(); - mock.OnQuery = (x1, x2) => { methodInvoked = true; return 148; }; + mock.OnQuery = (x1, x2) => + { + methodInvoked = true; + return 148; + }; // Act sut.Get((string x1, int x2) => mock.Query(x1, x2)); // Assert @@ -2236,7 +2246,11 @@ public void GetOnQueryWithTwoParametersWillInvokeMethodWithCorrectFirstParameter sut.Register(() => expectedByte); var mock = new QueryMock(); - mock.OnQuery = (x1, x2) => { Assert.Equal(expectedByte, x1); return 9823829; }; + mock.OnQuery = (x1, x2) => + { + Assert.Equal(expectedByte, x1); + return 9823829; + }; // Act sut.Get((byte x1, int x2) => mock.Query(x1, x2)); // Assert (done by mock) @@ -2252,7 +2266,11 @@ public void GetOnQueryWithTwoParametersWillInvokeMethodWithCorrectSecondParamete sut.Register(() => expectedByte); var mock = new QueryMock(); - mock.OnQuery = (x1, x2) => { Assert.Equal(expectedByte, x2); return false; }; + mock.OnQuery = (x1, x2) => + { + Assert.Equal(expectedByte, x2); + return false; + }; // Act sut.Get((DateTime x1, sbyte x2) => mock.Query(x1, x2)); // Assert (done by mock) @@ -2291,7 +2309,11 @@ public void GetOnQueryWithThreeParametersWillInvokeMethod() var sut = new Fixture(); var mock = new QueryMock(); - mock.OnQuery = (x1, x2, x3) => { methodInvoked = true; return new object(); }; + mock.OnQuery = (x1, x2, x3) => + { + methodInvoked = true; + return new object(); + }; // Act sut.Get((object x1, object x2, object x3) => mock.Query(x1, x2, x3)); // Assert @@ -2308,7 +2330,11 @@ public void GetOnQueryWithThreeParametersWillInvokeMethodWithCorrectFirstParamet sut.Register(() => expectedByte); var mock = new QueryMock(); - mock.OnQuery = (x1, x2, x3) => { Assert.Equal(expectedByte, x1); return 3646.77f; }; + mock.OnQuery = (x1, x2, x3) => + { + Assert.Equal(expectedByte, x1); + return 3646.77f; + }; // Act sut.Get((sbyte? x1, bool x2, string x3) => mock.Query(x1, x2, x3)); // Assert (done by mock) @@ -2324,7 +2350,11 @@ public void GetOnQueryWithThreeParametersWillInvokeMethodWithCorrectSecondParame sut.Register(() => expectedNumber); var mock = new QueryMock(); - mock.OnQuery = (x1, x2, x3) => { Assert.Equal(expectedNumber, x2); return new object(); }; + mock.OnQuery = (x1, x2, x3) => + { + Assert.Equal(expectedNumber, x2); + return new object(); + }; // Act sut.Get((bool x1, float x2, TimeSpan x3) => mock.Query(x1, x2, x3)); // Assert (done by mock) @@ -2340,7 +2370,11 @@ public void GetOnQueryWithThreeParametersWillInvokeMethodWithCorrectThirdParamet sut.Register(() => expectedText); var mock = new QueryMock(); - mock.OnQuery = (x1, x2, x3) => { Assert.Equal(expectedText, x3); return 111.11m; }; + mock.OnQuery = (x1, x2, x3) => + { + Assert.Equal(expectedText, x3); + return 111.11m; + }; // Act sut.Get((long x1, short x2, string x3) => mock.Query(x1, x2, x3)); // Assert (done by mock) @@ -2379,7 +2413,11 @@ public void GetOnQueryWithFourParametersWillInvokeMethod() var sut = new Fixture(); var mock = new QueryMock(); - mock.OnQuery = (x1, x2, x3, x4) => { methodInvoked = true; return new object(); }; + mock.OnQuery = (x1, x2, x3, x4) => + { + methodInvoked = true; + return new object(); + }; // Act sut.Get((object x1, object x2, object x3, object x4) => mock.Query(x1, x2, x3, x4)); // Assert @@ -2396,7 +2434,11 @@ public void GetOnQueryWithFourParametersWillInvokeMethodWithCorrectFirstParamete sut.Register(() => expectedTimeSpan); var mock = new QueryMock(); - mock.OnQuery = (x1, x2, x3, x4) => { Assert.Equal(expectedTimeSpan, x1); return EventArgs.Empty; }; + mock.OnQuery = (x1, x2, x3, x4) => + { + Assert.Equal(expectedTimeSpan, x1); + return EventArgs.Empty; + }; // Act sut.Get((TimeSpan x1, Version x2, Random x3, Guid x4) => mock.Query(x1, x2, x3, x4)); // Assert (done by mock) @@ -2412,7 +2454,11 @@ public void GetOnQueryWithFourParametersWillInvokeMethodWithCorrectSecondParamet sut.Register(() => expectedDateTimeKind); var mock = new QueryMock(); - mock.OnQuery = (x1, x2, x3, x4) => { Assert.Equal(expectedDateTimeKind, x2); return 77f; }; + mock.OnQuery = (x1, x2, x3, x4) => + { + Assert.Equal(expectedDateTimeKind, x2); + return 77f; + }; // Act sut.Get((Random x1, DateTimeKind x2, DateTime x3, string x4) => mock.Query(x1, x2, x3, x4)); // Assert (done by mock) @@ -2428,7 +2474,11 @@ public void GetOnQueryWithFourParametersWillInvokeMethodWithCorrectThirdParamete sut.Register(() => expectedDayOfWeek); var mock = new QueryMock(); - mock.OnQuery = (x1, x2, x3, x4) => { Assert.Equal(expectedDayOfWeek, x3); return ConsoleColor.Black; }; + mock.OnQuery = (x1, x2, x3, x4) => + { + Assert.Equal(expectedDayOfWeek, x3); + return ConsoleColor.Black; + }; // Act sut.Get((int x1, float x2, DayOfWeek x3, string x4) => mock.Query(x1, x2, x3, x4)); // Assert (done by mock) @@ -2444,7 +2494,11 @@ public void GetOnQueryWithFourParametersWillInvokeMethodWithCorrectFourthParamet sut.Register(() => expectedNumber); var mock = new QueryMock(); - mock.OnQuery = (x1, x2, x3, x4) => { Assert.Equal(expectedNumber, x4); return ConsoleColor.Cyan; }; + mock.OnQuery = (x1, x2, x3, x4) => + { + Assert.Equal(expectedNumber, x4); + return ConsoleColor.Cyan; + }; // Act sut.Get((Version x1, ushort x2, string x3, int x4) => mock.Query(x1, x2, x3, x4)); // Assert (done by mock) @@ -2734,8 +2788,6 @@ public void FreezeWillCauseFixtureToKeepReturningTheFrozenInstanceEvenAsProperty Assert.Equal(expectedResult, result); } - - [Fact] public void FreezeWithNullTransformationThrows() { @@ -2900,9 +2952,8 @@ public void BuildWithThrowingRecursionHandlerWillThrowOnReferenceRecursionPointO Assert.ThrowsAny(() => new SpecimenContext( new ThrowingRecursionGuard( - sut.Build() - ) - ).CreateAnonymous()); + sut.Build())) + .CreateAnonymous()); } [Fact] @@ -2915,9 +2966,8 @@ public void BuildWithThrowingRecursionHandlerWillThrowOnReferenceRecursionPoint( new SpecimenContext( new RecursionGuard( sut.Build(), - new ThrowingRecursionHandler() - ) - ).Create()); + new ThrowingRecursionHandler())) + .Create()); } [Fact] @@ -2930,9 +2980,8 @@ public void BuildWithThrowingRecursionHandlerWillThrowOnConstructorRecursionPoin Assert.ThrowsAny(() => new SpecimenContext( new ThrowingRecursionGuard( - sut.Build() - ) - ).CreateAnonymous()); + sut.Build())) + .CreateAnonymous()); } [Fact] @@ -2945,9 +2994,8 @@ public void BuildWithThrowingRecursionHandlerWillThrowOnConstructorRecursionPoin new SpecimenContext( new RecursionGuard( sut.Build(), - new ThrowingRecursionHandler() - ) - ).Create()); + new ThrowingRecursionHandler())) + .Create()); } [Fact] @@ -2959,9 +3007,8 @@ public void BuildWithNullRecursionHandlerWillCreateNullOnRecursionPointObsolete( // Act var result = new SpecimenContext( new NullRecursionGuard( - sut.Build() - ) - ).CreateAnonymous(); + sut.Build())) + .CreateAnonymous(); // Assert Assert.Null(result.ReferenceToB.ReferenceToA); } @@ -2975,9 +3022,8 @@ public void BuildWithNullRecursionHandlerWillCreateNullOnRecursionPoint() var result = new SpecimenContext( new RecursionGuard( sut.Build(), - new NullRecursionHandler() - ) - ).Create(); + new NullRecursionHandler())) + .Create(); // Assert Assert.Null(result.ReferenceToB.ReferenceToA); } @@ -3616,7 +3662,6 @@ public void BuilderSequenceWillBePreservedObsolete() Assert.Equal(expectedValue, result.Property); } - [Fact] public void BuilderSequenceWillBePreserved() { @@ -4247,7 +4292,6 @@ public void BuildAbstractTypeUsingBuilderIsPossibleObsolete() Assert.IsAssignableFrom(result); } - [Fact] public void BuildAbstractTypeUsingBuilderIsPossible() { @@ -4761,8 +4805,7 @@ public void ResidueCollectorsContainForwardsByDefault(Type from, Type to) sut.Customizations, b => b is FilteringSpecimenBuilder fsb && fsb.Specification is ExactTypeSpecification ets && ets.TargetType == matchingType - && fsb.Builder is MethodInvoker mi && mi.Query.GetType() == queryType - ); + && fsb.Builder is MethodInvoker mi && mi.Query.GetType() == queryType); } [Theory] @@ -4779,8 +4822,7 @@ public void ResidueCollectorsContainForwardsByDefault(Type from, Type to) b => b is FilteringSpecimenBuilder fsb && fsb.Specification is ExactTypeSpecification ets && ets.TargetType == matchingType && fsb.Builder is Postprocessor pp && pp.Command is DictionaryFiller - && pp.Builder is MethodInvoker mi && mi.Query.GetType() == queryType - ); + && pp.Builder is MethodInvoker mi && mi.Query.GetType() == queryType); } [Fact] @@ -4822,7 +4864,7 @@ public void CreateAnonymousStructWithoutConstructorThrowsException() } /// - /// This test is just to make sure that edge cases as decimal which is not primitive type and is a structure will not fall within + /// This test is just to make sure that edge cases as decimal which is not primitive type and is a structure will not fall within /// struct checking mechanism. /// [Fact] @@ -5127,7 +5169,7 @@ public void CustomizationOfOverriddenPropOfChildADoesNotAffectChildB() } /// - /// Checks the scenario: https://github.com/AutoFixture/AutoFixture/issues/531 + /// Checks the scenario: https://github.com/AutoFixture/AutoFixture/issues/531. /// [Fact] public void CustomizationOfBasePropOfChildADoesNotAffectChildB() @@ -5145,47 +5187,47 @@ public void CustomizationOfBasePropOfChildADoesNotAffectChildB() } /// - /// Checks the scenario reported in https://github.com/AutoFixture/AutoFixture/issues/772 + /// Checks the scenario reported in https://github.com/AutoFixture/AutoFixture/issues/772. /// [Fact] public void CustomizatonOfSamePropertyIsIgnoredDuringTheBuild() { - //arrange + // arrange var sut = new Fixture(); sut.Customize>(c => c.With(x => x.Property1, "foo")); - //act + // act var result = sut .Build>() .With(x => x.Property2, 42) .Create(); - //assert + // assert Assert.NotEqual("foo", result.Property1); Assert.Equal(42, result.Property2); } /// - /// Scenario from https://github.com/AutoFixture/AutoFixture/issues/321 + /// Scenario from https://github.com/AutoFixture/AutoFixture/issues/321. /// [Fact] public void CustomizationOfIntPropertyDoesntThrowInBuild() { - //arrange + // arrange var sut = new Fixture(); sut.Customize>(c => c.Without(x => x.Property)); - //act + // act var result = sut.Build>().With(x => x.Property).Create(); - //assert + // assert Assert.NotEqual(0L, result.Property); } [Fact] public void EnableDisableAutoPropertiesDoesntBreakCustomization() { - //arrange + // arrange var sut = new Fixture(); sut.Customize>(c => c @@ -5193,10 +5235,10 @@ public void EnableDisableAutoPropertiesDoesntBreakCustomization() .OmitAutoProperties() .WithAutoProperties()); - //act + // act var result = sut.Create>(); - //assert + // assert Assert.Null(result.Property); } @@ -5464,10 +5506,9 @@ public void WithImplicitConversionToNullableFieldReturnsCorrectResult() Assert.Equal(expected, actual.Field); } - /// /// This test reproduces the issue as reported in pull request: - /// https://github.com/AutoFixture/AutoFixture/pull/604 + /// https://github.com/AutoFixture/AutoFixture/pull/604. /// [Fact] public void WithoutOnFieldInBaseClassThrowsNullPointerException() @@ -5478,9 +5519,9 @@ public void WithoutOnFieldInBaseClassThrowsNullPointerException() /* Success when no ArgumentNullException is thrown: - When reported, the call to Without on Field1 residing - in ConcreteType's base class (AbstractType) will cause - a null pointer exception to bubble. + When reported, the call to Without on Field1 residing + in ConcreteType's base class (AbstractType) will cause + a null pointer exception to bubble. */ } @@ -5511,7 +5552,6 @@ public void Issue691_DontUseCastOperatorsToCreateSpecimen() fixture.Create()); Assert.Contains("most likely because it has no public constructor", ex.Message); - } [Fact] @@ -5528,7 +5568,6 @@ public void Issue724_ShouldFailWithMeaningfulException_WhenNestedPropertyConfigu .With(x => x.Property.Property1, "Dummy"); }); Assert.Contains("nested property or field", ex.Message); - } [Fact] @@ -5545,10 +5584,8 @@ public void Issue724_ShouldFailWithMeaningfulException_WhenNestedPropertyConfigu .With(x => x.Property.Property1); }); Assert.Contains("nested property or field", ex.Message); - } - [Fact] public void Issue724_ShouldFailWithMeaningfulException_WhenNestedPropertyConfiguredViaBuildWithout() { @@ -5563,7 +5600,6 @@ public void Issue724_ShouldFailWithMeaningfulException_WhenNestedPropertyConfigu .Without(x => x.Property.Property1); }); Assert.Contains("nested property or field", ex.Message); - } [Fact] @@ -5578,7 +5614,6 @@ public void Issue724_ShouldFailWithMeaningfulException_WhenNestedPropertyConfigu fixture.Customize>(c => c.With(x => x.Property.Property1, "dummy")); }); Assert.Contains("nested property or field", ex.Message); - } [Fact] @@ -5593,7 +5628,6 @@ public void Issue724_ShouldFailWithMeaningfulException_WhenNestedPropertyConfigu fixture.Customize>(c => c.With(x => x.Property.Property1)); }); Assert.Contains("nested property or field", ex.Message); - } [Fact] @@ -5608,7 +5642,6 @@ public void Issue724_ShouldFailWithMeaningfulException_WhenNestedPropertyConfigu fixture.Customize>(c => c.Without(x => x.Property.Property1)); }); Assert.Contains("nested property or field", ex.Message); - } [Fact] @@ -5620,7 +5653,6 @@ public void Issue871_FailsWithArgumentExceptionForNullRequest() // Act & assert Assert.Throws(() => sut.Create(null, specimenContext)); - } [Fact] @@ -5632,7 +5664,6 @@ public void Issue871_FailsWithArgumentExceptionForNullRequestContext() // Act & assert Assert.Throws(() => sut.Create(request, null)); - } #if SYSTEM_NET_MAIL @@ -5660,7 +5691,6 @@ public void Issue453_RangeAttributeShouldFailWithMeaningfulException() Assert.IsType(actualEx.InnerException); Assert.Contains("To solve the issue", actualEx.InnerException.Message); - } private class Issue453_AnnotationWithOverflow @@ -5705,7 +5735,6 @@ public void ShouldNotDuplicateRequestPathTwiceInCaseOfRecursionGuardException() new Regex(Regex.Escape(requestToLookFor.ToString())).Matches(actualEx.Message).Count; Assert.Equal(1, numberOfRequestOccurence); - } [Theory] @@ -5727,8 +5756,7 @@ public void Issue897_ShouldCorrectlyHandleRequestsWithSameMinimumAndMaximumValue var fakeMember = new FakeMemberInfo( new ProvidedAttribute( new RangeAttribute(type, "42", "42"), - inherited: false - )); + inherited: false)); var sut = new Fixture(); @@ -5823,10 +5851,10 @@ public void ShouldResolveISetByDefault() { // Arrange var sut = new Fixture(); - + // Act var result = sut.Create>(); - + // Assert Assert.IsAssignableFrom>(result); } @@ -5924,7 +5952,7 @@ private class TypeWithRangedEnumProperties } /// - /// Scenario for: https://github.com/AutoFixture/AutoFixture/issues/722 + /// Scenario for: https://github.com/AutoFixture/AutoFixture/issues/722. /// [Fact] public void ShouldCorrectlyResolveEnumPropertiesDecoratedWithRange() @@ -5993,7 +6021,7 @@ public void Issue970_DoesNotFailWhenHelperExtensionMethodIsUsed() Assert.Equal("42", result.Value); IPostprocessComposer ConfigurePropertyField(IPostprocessComposer composer) - where T: IIssue970_ValueHolder + where T : IIssue970_ValueHolder { return composer.With(x => x.Value, "42"); } @@ -6020,7 +6048,7 @@ public void ShouldCorrectlyResolveTimeSpanPropertiesDecoratedWithRange() [Fact] public void TimeSpanDecoratedWithRangeCreatedByFixtureShouldPassValidation() - { + { // Arrange var sut = new Fixture(); diff --git a/Src/AutoFixtureUnitTest/FreezeOnMatchCustomizationTest.cs b/Src/AutoFixtureUnitTest/FreezeOnMatchCustomizationTest.cs index 6e6820c2d..fc7dffe7a 100644 --- a/Src/AutoFixtureUnitTest/FreezeOnMatchCustomizationTest.cs +++ b/Src/AutoFixtureUnitTest/FreezeOnMatchCustomizationTest.cs @@ -75,7 +75,6 @@ public void InitializeWithMatcherShouldSetCorrespondingProperty() Assert.Equal(matcher, sut.Matcher); } - [Fact] public void InitializeWithSingleNullRequestArgumentShouldThrowArgumentNullException() { diff --git a/Src/AutoFixtureUnitTest/GeneratorTest.cs b/Src/AutoFixtureUnitTest/GeneratorTest.cs index 60ebab611..28ce972e0 100644 --- a/Src/AutoFixtureUnitTest/GeneratorTest.cs +++ b/Src/AutoFixtureUnitTest/GeneratorTest.cs @@ -9,11 +9,6 @@ namespace AutoFixtureUnitTest { - public class GeneratorTestOfObject : GeneratorTest { } - public class GeneratorTestOfString : GeneratorTest { } - public class GeneratorTestOfInt32 : GeneratorTest { } - public class GeneratorTestOfGuid : GeneratorTest { } - public class GeneratorTestOfNetPipeStyleUriParser : GeneratorTest { } public abstract class GeneratorTest { [Theory, ClassData(typeof(CountTestCases))] @@ -140,4 +135,24 @@ IEnumerator IEnumerable.GetEnumerator() return this.GetEnumerator(); } } + + public class GeneratorTestOfObject : GeneratorTest + { + } + + public class GeneratorTestOfString : GeneratorTest + { + } + + public class GeneratorTestOfInt32 : GeneratorTest + { + } + + public class GeneratorTestOfGuid : GeneratorTest + { + } + + public class GeneratorTestOfNetPipeStyleUriParser : GeneratorTest + { + } } diff --git a/Src/AutoFixtureUnitTest/Kernel/AutoPropertiesCommandTest.cs b/Src/AutoFixtureUnitTest/Kernel/AutoPropertiesCommandTest.cs index ef7a4bf3c..3c38994df 100644 --- a/Src/AutoFixtureUnitTest/Kernel/AutoPropertiesCommandTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/AutoPropertiesCommandTest.cs @@ -119,7 +119,7 @@ public void ExecuteDoesNotSetStaticProperty() [Fact] [Obsolete] - void ExecuteDoesNotSetStaticField() + public void ExecuteDoesNotSetStaticField() { // Arrange var sut = new AutoPropertiesCommand>(); @@ -609,7 +609,6 @@ public void NonTypedWithSpecificationReturnsNullSpecimenTypeIfNotProvided() Assert.Null(sut.ExplicitSpecimenType); } - public void Dispose() { StaticPropertyHolder.Property = null; diff --git a/Src/AutoFixtureUnitTest/Kernel/EnumeratorRelayTest.cs b/Src/AutoFixtureUnitTest/Kernel/EnumeratorRelayTest.cs index 2fab3f5e7..34b200415 100644 --- a/Src/AutoFixtureUnitTest/Kernel/EnumeratorRelayTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/EnumeratorRelayTest.cs @@ -44,7 +44,6 @@ public void CreateWithNullContextThrows() Assert.Equal(expectedResult, result); } - [Theory] [InlineData(typeof(IEnumerator), typeof(object))] [InlineData(typeof(IEnumerator), typeof(string))] diff --git a/Src/AutoFixtureUnitTest/Kernel/EqualRequestSpecificationTests.cs b/Src/AutoFixtureUnitTest/Kernel/EqualRequestSpecificationTests.cs index b25de20ac..e9232d527 100644 --- a/Src/AutoFixtureUnitTest/Kernel/EqualRequestSpecificationTests.cs +++ b/Src/AutoFixtureUnitTest/Kernel/EqualRequestSpecificationTests.cs @@ -97,7 +97,6 @@ public void ConstructWithNullComparerAndDummyTargetThrows() // Arrange var dummyTarget = new object(); // Act & assert - Assert.Throws(() => new EqualRequestSpecification(dummyTarget, null)); } diff --git a/Src/AutoFixtureUnitTest/Kernel/FactoryMethodQueryTest.cs b/Src/AutoFixtureUnitTest/Kernel/FactoryMethodQueryTest.cs index 0e0cd92fa..5fe422d45 100644 --- a/Src/AutoFixtureUnitTest/Kernel/FactoryMethodQueryTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/FactoryMethodQueryTest.cs @@ -85,7 +85,6 @@ public void SelectMethodsFromTypeWithConversionOperatorsOnlyReturnsEmptyResult() // Assert Assert.Empty(result); - } } } diff --git a/Src/AutoFixtureUnitTest/Kernel/GenericMethodTests.cs b/Src/AutoFixtureUnitTest/Kernel/GenericMethodTests.cs index f0f4fcaf9..a7eb059d4 100644 --- a/Src/AutoFixtureUnitTest/Kernel/GenericMethodTests.cs +++ b/Src/AutoFixtureUnitTest/Kernel/GenericMethodTests.cs @@ -13,7 +13,7 @@ public class GenericMethodTests [Fact] public void SutIsIMethod() { - Action dummy = delegate { }; + Action dummy = () => { }; var anonymousFactory = new DelegatingMethodFactory(); var sut = new GenericMethod(dummy.GetMethodInfo(), anonymousFactory); Assert.IsAssignableFrom(sut); @@ -30,7 +30,7 @@ public void InitializeWithNullMethodInfoThrows() [Fact] public void InitializeWithNullFactoryThrows() { - Action dummy = delegate { }; + Action dummy = () => { }; Assert.Throws(() => new GenericMethod(dummy.GetMethodInfo(), null)); @@ -39,7 +39,8 @@ public void InitializeWithNullFactoryThrows() [Fact] public void MethodIsCorrect() { - var expectedMethod = ((Action)delegate { }).GetMethodInfo(); + Action action = () => { }; + var expectedMethod = action.GetMethodInfo(); var anonymousFactory = new DelegatingMethodFactory(); var sut = new GenericMethod(expectedMethod, anonymousFactory); @@ -51,7 +52,8 @@ public void MethodIsCorrect() [Fact] public void FactoryIsCorrect() { - var anonymousMethod = ((Action)delegate { }).GetMethodInfo(); + Action action = () => { }; + var anonymousMethod = action.GetMethodInfo(); var expectedFactory = new DelegatingMethodFactory(); var sut = new GenericMethod(anonymousMethod, expectedFactory); @@ -63,7 +65,7 @@ public void FactoryIsCorrect() [Fact] public void ParametersIsCorrect() { - Action dummy = delegate { }; + Action dummy = (i, d) => { }; var anonymousFactory = new DelegatingMethodFactory(); var expectedParameters = dummy.GetMethodInfo().GetParameters(); var sut = new GenericMethod(dummy.GetMethodInfo(), anonymousFactory); @@ -194,12 +196,12 @@ public static TypeWithGenericMethod Create(IEnumerable arguments) return new TypeWithGenericMethod(); } - public static TypeWithGenericMethod Create(T argument1, U argument2) + public static TypeWithGenericMethod Create(T1 argument1, T2 argument2) { return new TypeWithGenericMethod(); } - public static TypeWithGenericMethod Create(T argument1, Func argument2) + public static TypeWithGenericMethod Create(T1 argument1, Func argument2) { return new TypeWithGenericMethod(); } diff --git a/Src/AutoFixtureUnitTest/Kernel/GraphEqualsTest.cs b/Src/AutoFixtureUnitTest/Kernel/GraphEqualsTest.cs index 3d595e1f8..7f1a7f99e 100644 --- a/Src/AutoFixtureUnitTest/Kernel/GraphEqualsTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/GraphEqualsTest.cs @@ -159,7 +159,7 @@ public void EmptyNodesAreEqualAccordingToComparer(bool expected) new CompositeSpecimenBuilder( new DelegatingSpecimenBuilder()), new CompositeSpecimenBuilder( - new[] {new CompositeSpecimenBuilder()}) + new[] { new CompositeSpecimenBuilder() }) }, { new CompositeSpecimenBuilder( @@ -173,7 +173,6 @@ public void EmptyNodesAreEqualAccordingToComparer(bool expected) public static TheoryData DifferentlyShapedGraphs => new TheoryData - { { new CompositeSpecimenBuilder(), diff --git a/Src/AutoFixtureUnitTest/Kernel/GreedyConstructorQueryTest.cs b/Src/AutoFixtureUnitTest/Kernel/GreedyConstructorQueryTest.cs index 180066009..5f0d13759 100644 --- a/Src/AutoFixtureUnitTest/Kernel/GreedyConstructorQueryTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/GreedyConstructorQueryTest.cs @@ -71,7 +71,6 @@ public void DoesNotReturnConstructorsWithParametersOfEnclosingType() Assert.Empty(result); } - public class TypeWithCopyConstructorsOnly { public TypeWithCopyConstructorsOnly(TypeWithCopyConstructorsOnly other) @@ -86,6 +85,5 @@ public TypeWithCopyConstructorsOnly(TypeWithCopyConstructorsOnly other, string s { } } - } } diff --git a/Src/AutoFixtureUnitTest/Kernel/MethodInvokerTest.cs b/Src/AutoFixtureUnitTest/Kernel/MethodInvokerTest.cs index 84ec6ab96..8b6015b0b 100644 --- a/Src/AutoFixtureUnitTest/Kernel/MethodInvokerTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/MethodInvokerTest.cs @@ -181,11 +181,11 @@ public void CreateFromTypeWillInvokeContainerCorrectly() var pType = ((ParameterInfo)r).ParameterType; if (typeof(long) == pType) { - return new long(); + return default(long); } if (typeof(short) == pType) { - return new short(); + return default(short); } } throw new ArgumentException("Unexpected container request.", nameof(r)); diff --git a/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingMethodFactoryTests.cs b/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingMethodFactoryTests.cs index b487a76b3..e71e7cf57 100644 --- a/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingMethodFactoryTests.cs +++ b/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingMethodFactoryTests.cs @@ -26,7 +26,7 @@ public void OwnerIsCorrect() [Fact] public void CreateReturnsCorrectResult() { - Action dummy = delegate { }; + Action dummy = () => { }; var owner = new object(); var sut = new MissingParametersSupplyingMethodFactory(owner); diff --git a/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingMethodTests.cs b/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingMethodTests.cs index a871decea..9148010aa 100644 --- a/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingMethodTests.cs +++ b/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingMethodTests.cs @@ -37,7 +37,7 @@ public void MethodIsCorrect() [Fact] public void ParametersIsCorrect() { - Action dummy = delegate { }; + Action dummy = (i, d) => { }; var expectedParameters = dummy.GetMethodInfo().GetParameters(); var method = new DelegatingMethod { OnParameters = () => expectedParameters }; var sut = new MissingParametersSupplyingMethod(method); @@ -52,7 +52,7 @@ public void InvokeWithCorrectArgumentsReturnsCorrectResult() { var arguments = new[] { new object(), new object() }; var expected = new object(); - Action dummy = delegate { }; + Action dummy = (o1, o2) => { }; var method = new DelegatingMethod(); method.OnParameters = () => dummy.GetMethodInfo().GetParameters(); method.OnInvoke = args => arguments.SequenceEqual(args) ? expected : null; diff --git a/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingStaticMethodFactoryTests.cs b/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingStaticMethodFactoryTests.cs index c2185cc5f..0a53067d9 100644 --- a/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingStaticMethodFactoryTests.cs +++ b/Src/AutoFixtureUnitTest/Kernel/MissingParametersSupplyingStaticMethodFactoryTests.cs @@ -17,7 +17,7 @@ public void SutIsIMethodFactory() [Fact] public void CreateReturnsCorrectResult() { - Action dummy = delegate { }; + Action dummy = () => { }; var sut = new MissingParametersSupplyingStaticMethodFactory(); var result = sut.Create(dummy.GetMethodInfo()); diff --git a/Src/AutoFixtureUnitTest/Kernel/MultidimensionalArrayRelayTest.cs b/Src/AutoFixtureUnitTest/Kernel/MultidimensionalArrayRelayTest.cs index 8bc66a9ce..ce63ee499 100644 --- a/Src/AutoFixtureUnitTest/Kernel/MultidimensionalArrayRelayTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/MultidimensionalArrayRelayTest.cs @@ -69,7 +69,9 @@ public void CreateWithInvalidRequestReturnsNoSpecimen(object invalidRequest) }, Expected = new[,] { - { 1 } + { + 1 + } } }, new // 2 dimension - 2 length @@ -81,8 +83,12 @@ public void CreateWithInvalidRequestReturnsNoSpecimen(object invalidRequest) }, Expected = new[,] { - { 1, 2 }, - { 3, 4 } + { + 1, 2 + }, + { + 3, 4 + } } }, new // 2 dimension - 3 length @@ -95,9 +101,15 @@ public void CreateWithInvalidRequestReturnsNoSpecimen(object invalidRequest) }, Expected = new[,] { - { 1, 2, 3 }, - { 11, 12, 13 }, - { 211, 212, 213 } + { + 1, 2, 3 + }, + { + 11, 12, 13 + }, + { + 211, 212, 213 + } } }, new // 2 dimension - 4 length @@ -111,10 +123,18 @@ public void CreateWithInvalidRequestReturnsNoSpecimen(object invalidRequest) }, Expected = new[,] { - { 1, 2, 3, 4 }, - { 11, 12, 13, 34 }, - { 211, 212, 213, 23 }, - { 3, 4, 5, 6 } + { + 1, 2, 3, 4 + }, + { + 11, 12, 13, 34 + }, + { + 211, 212, 213, 23 + }, + { + 3, 4, 5, 6 + } } } } @@ -169,7 +189,9 @@ public void Create2DimensionalArrayReturnsCorrectResult(int[][] jagged, int[,] e Expected = new[,,] { { - {12} + { + 12 + } } } }, @@ -179,24 +201,32 @@ public void Create2DimensionalArrayReturnsCorrectResult(int[][] jagged, int[,] e { new[] { - new[] {1, 2}, - new[] {3, 4} + new[] { 1, 2 }, + new[] { 3, 4 } }, new[] { - new[] {31, 32}, - new[] {33, 34} + new[] { 31, 32 }, + new[] { 33, 34 } } }, Expected = new[,,] { { - {1, 2}, - {3, 4} + { + 1, 2 + }, + { + 3, 4 + } }, { - {31, 32}, - {33, 34} + { + 31, 32 + }, + { + 33, 34 + } } } }, @@ -206,39 +236,57 @@ public void Create2DimensionalArrayReturnsCorrectResult(int[][] jagged, int[,] e { new[] { - new[] {1, 2, 4}, - new[] {2, 4, 6}, - new[] {3, 5, 7} + new[] { 1, 2, 4 }, + new[] { 2, 4, 6 }, + new[] { 3, 5, 7 } }, new[] { - new[] {31, 32, 2}, - new[] {33, 34, 4}, - new[] {45, 34, 342} + new[] { 31, 32, 2 }, + new[] { 33, 34, 4 }, + new[] { 45, 34, 342 } }, new[] { - new[] {1, 2, 3}, - new[] {4, 5, 6}, - new[] {7, 8, 9} + new[] { 1, 2, 3 }, + new[] { 4, 5, 6 }, + new[] { 7, 8, 9 } } }, Expected = new[,,] { { - {1, 2, 4}, - {2, 4, 6}, - {3, 5, 7} + { + 1, 2, 4 + }, + { + 2, 4, 6 + }, + { + 3, 5, 7 + } }, { - {31, 32, 2}, - {33, 34, 4}, - {45, 34, 342} + { + 31, 32, 2 + }, + { + 33, 34, 4 + }, + { + 45, 34, 342 + } }, { - {1, 2, 3}, - {4, 5, 6}, - {7, 8, 9} + { + 1, 2, 3 + }, + { + 4, 5, 6 + }, + { + 7, 8, 9 + } } } } @@ -297,26 +345,42 @@ public void Create4DimensionalArrayReturnsCorrectResult() } }; - var expected = new[, , ,] + var expected = new[,,,] { { { - { 11, 22 }, - { 33, 44 } + { + 11, 22 + }, + { + 33, 44 + } }, { - { 531, 632 }, - { 733, 834 } + { + 531, 632 + }, + { + 733, 834 + } } }, { { - { 1, 2 }, - { 3, 4 } + { + 1, 2 + }, + { + 3, 4 + } }, { - { 31, 32 }, - { 33, 34 } + { + 31, 32 + }, + { + 33, 34 + } } } }; diff --git a/Src/AutoFixtureUnitTest/Kernel/NodeComparer.cs b/Src/AutoFixtureUnitTest/Kernel/NodeComparer.cs index 1f3165b5b..7f48ae3d0 100644 --- a/Src/AutoFixtureUnitTest/Kernel/NodeComparer.cs +++ b/Src/AutoFixtureUnitTest/Kernel/NodeComparer.cs @@ -194,7 +194,7 @@ public int GetHashCode(ISpecimenCommand obj) private static class GenericComparer { - private static readonly Dictionary equatables = + private static readonly Dictionary Equatables = new Dictionary { { typeof(SeededFactory<>), typeof(SeededFactoryEquatable<>) }, @@ -213,7 +213,7 @@ public static object CreateFromTemplate(object obj) if (!t.GetTypeInfo().IsGenericType) return new object(); - if (equatables.TryGetValue(t.GetGenericTypeDefinition(), out Type equatableType)) + if (Equatables.TryGetValue(t.GetGenericTypeDefinition(), out Type equatableType)) { var typeArguments = t.GetGenericArguments(); return equatableType.MakeGenericType(typeArguments) @@ -316,7 +316,6 @@ protected override bool EqualsInstance(NodeComposer other) } } - private class CompositeNodeComposerEquatable : GenericEquatable> { public CompositeNodeComposerEquatable(CompositeNodeComposer item) @@ -330,7 +329,8 @@ protected override bool EqualsInstance(CompositeNodeComposer other) } } - private abstract class GenericEquatable : IEquatable where T : class + private abstract class GenericEquatable : IEquatable + where T : class { public GenericEquatable(T item) { diff --git a/Src/AutoFixtureUnitTest/Kernel/OmitSpecimenTest.cs b/Src/AutoFixtureUnitTest/Kernel/OmitSpecimenTest.cs index 3b5cedd79..0b74f77ab 100644 --- a/Src/AutoFixtureUnitTest/Kernel/OmitSpecimenTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/OmitSpecimenTest.cs @@ -62,7 +62,8 @@ public void GetHashCodeIsStableAcrossInstances() Assert.Equal(expected, actual); } - private static IEnumerable BothEquals(T sut, T other) where T : IEquatable + private static IEnumerable BothEquals(T sut, T other) + where T : IEquatable { yield return sut.Equals((object)other); yield return sut.Equals(other); diff --git a/Src/AutoFixtureUnitTest/Kernel/ParameterTypeAndNameCriterionTests.cs b/Src/AutoFixtureUnitTest/Kernel/ParameterTypeAndNameCriterionTests.cs index 412f15361..cd9b71d99 100644 --- a/Src/AutoFixtureUnitTest/Kernel/ParameterTypeAndNameCriterionTests.cs +++ b/Src/AutoFixtureUnitTest/Kernel/ParameterTypeAndNameCriterionTests.cs @@ -77,7 +77,6 @@ public void ConstructWithNullTypeCriterionThrows() [Fact] public void ConstructWithNullNameCriterionThrows() { - Assert.Throws( () => new ParameterTypeAndNameCriterion( new DelegatingCriterion(), diff --git a/Src/AutoFixtureUnitTest/Kernel/RangedNumberRequestTest.cs b/Src/AutoFixtureUnitTest/Kernel/RangedNumberRequestTest.cs index 3a477fca2..f3df1b6b9 100644 --- a/Src/AutoFixtureUnitTest/Kernel/RangedNumberRequestTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/RangedNumberRequestTest.cs @@ -293,7 +293,6 @@ public void ToStringShouldBeOverridden() Assert.Contains("Int64", stringResult); Assert.Contains("42", stringResult); Assert.Contains("100", stringResult); - } } } \ No newline at end of file diff --git a/Src/AutoFixtureUnitTest/Kernel/Scenario.cs b/Src/AutoFixtureUnitTest/Kernel/Scenario.cs index df15bbde0..6278528cc 100644 --- a/Src/AutoFixtureUnitTest/Kernel/Scenario.cs +++ b/Src/AutoFixtureUnitTest/Kernel/Scenario.cs @@ -536,9 +536,8 @@ public void CustomizeAndComposeComplexTypeObsolete() var result = new CompositeNodeComposer>( new CompositeSpecimenBuilder( SpecimenBuilderNodeFactory.CreateComposer>(), - Scenario.CreateAutoPropertyBuilder() - ) - ).With(x => x.Property2, 8m).WithAutoProperties().CreateAnonymous(); + Scenario.CreateAutoPropertyBuilder())) + .With(x => x.Property2, 8m).WithAutoProperties().CreateAnonymous(); // Assert Assert.Equal(1, result.Property1); Assert.Equal(8, result.Property2); @@ -552,9 +551,8 @@ public void CustomizeAndComposeComplexType() var result = new CompositeNodeComposer>( new CompositeSpecimenBuilder( SpecimenBuilderNodeFactory.CreateComposer>(), - Scenario.CreateAutoPropertyBuilder() - ) - ).With(x => x.Property2, 8m).WithAutoProperties().Create(); + Scenario.CreateAutoPropertyBuilder())) + .With(x => x.Property2, 8m).WithAutoProperties().Create(); // Assert Assert.Equal(1, result.Property1); Assert.Equal(8, result.Property2); diff --git a/Src/AutoFixtureUnitTest/Kernel/SortedListSpecificationTest.cs b/Src/AutoFixtureUnitTest/Kernel/SortedListSpecificationTest.cs index 5a267b3c8..dd1b52e84 100644 --- a/Src/AutoFixtureUnitTest/Kernel/SortedListSpecificationTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/SortedListSpecificationTest.cs @@ -44,7 +44,7 @@ public void IsSatisfiedBySortedListRequestReturnsCorrectResult(object request) [Theory] [InlineData(null)] - [InlineData("")] // non-Type + [InlineData("")] // non-Type [InlineData(1)] [InlineData(typeof(object))] [InlineData(typeof(string))] @@ -58,8 +58,8 @@ public void IsSatisfiedBySortedListRequestReturnsCorrectResult(object request) [InlineData(typeof(Version[]))] [InlineData(typeof(int?[]))] [InlineData(typeof(EmptyEnum?[]))] - [InlineData(typeof(List))] // Generic, but not SortedList<,> - [InlineData(typeof(Dictionary))] // double parameter generic, that implements same interface + [InlineData(typeof(List))] // Generic, but not SortedList<,> + [InlineData(typeof(Dictionary))] // double parameter generic, that implements same interface public void IsSatisfiedByNonSortedListRequestReturnsCorrectResult(object request) { // Arrange diff --git a/Src/AutoFixtureUnitTest/Kernel/StaticMethodTest.cs b/Src/AutoFixtureUnitTest/Kernel/StaticMethodTest.cs index bd95b524d..53e27e717 100644 --- a/Src/AutoFixtureUnitTest/Kernel/StaticMethodTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/StaticMethodTest.cs @@ -13,7 +13,7 @@ public class StaticMethodTest public void SutIsMethod() { // Arrange - Action dummy = delegate { }; + Action dummy = () => { }; // Act var sut = new StaticMethod(dummy.GetMethodInfo()); // Assert @@ -33,7 +33,7 @@ public void InitializeOneParamsConstructorWithNullMethodInfoThrows() public void InitializeWithNullMethodInfoThrows() { // Arrange - Action dummy = delegate { }; + Action dummy = () => { }; // Act & assert Assert.Throws(() => new StaticMethod(null, dummy.GetMethodInfo().GetParameters())); @@ -43,7 +43,7 @@ public void InitializeWithNullMethodInfoThrows() public void InitializeWithNullMethodParametersThrows() { // Arrange - Action dummy = delegate { }; + Action dummy = () => { }; // Act & assert Assert.Throws(() => new StaticMethod(dummy.GetMethodInfo(), null)); @@ -53,7 +53,8 @@ public void InitializeWithNullMethodParametersThrows() public void MethodIsCorrect() { // Arrange - var expectedMethod = ((Action)delegate { }).GetMethodInfo(); + Action action = () => { }; + var expectedMethod = action.GetMethodInfo(); var sut = new StaticMethod(expectedMethod); // Act var result = sut.Method; @@ -65,7 +66,7 @@ public void MethodIsCorrect() public void ParametersIsCorrectWhenPassedOnOneParamsConstructor() { // Arrange - Action dummy = delegate { }; + Action dummy = o => { }; var expectedParameters = dummy.GetMethodInfo().GetParameters(); var sut = new StaticMethod(dummy.GetMethodInfo()); // Act @@ -78,7 +79,7 @@ public void ParametersIsCorrectWhenPassedOnOneParamsConstructor() public void ParametersIsCorrect() { // Arrange - Action dummy = delegate { }; + Action dummy = (i, d) => { }; var expectedParameters = dummy.GetMethodInfo().GetParameters(); var sut = new StaticMethod(dummy.GetMethodInfo(), expectedParameters); // Act @@ -110,7 +111,8 @@ public void InvokeWithFactoryMethodReturnsCorrectResult(Type targetType, int ind public void SutIsEquatable() { // Arrange - var method = ((Action)delegate { }).GetMethodInfo(); + Action action = o => { }; + var method = action.GetMethodInfo(); // Act var sut = new StaticMethod(method); // Assert @@ -121,7 +123,8 @@ public void SutIsEquatable() public void SutDoesNotEqualNullObject() { // Arrange - var method = ((Action)delegate { }).GetMethodInfo(); + Action action = o => { }; + var method = action.GetMethodInfo(); var sut = new StaticMethod(method); // Act var result = sut.Equals((object)null); @@ -133,7 +136,8 @@ public void SutDoesNotEqualNullObject() public void SutDoesNotEqualNullSut() { // Arrange - var method = ((Action)delegate { }).GetMethodInfo(); + Action action = o => { }; + var method = action.GetMethodInfo(); var sut = new StaticMethod(method); // Act var result = sut.Equals((StaticMethod)null); @@ -145,7 +149,8 @@ public void SutDoesNotEqualNullSut() public void SutDoesNotEqualSomeOtherObject() { // Arrange - var method = ((Action)delegate { }).GetMethodInfo(); + Action action = o => { }; + var method = action.GetMethodInfo(); var sut = new StaticMethod(method); // Act var result = sut.Equals(new object()); @@ -157,10 +162,12 @@ public void SutDoesNotEqualSomeOtherObject() public void SutDoesNotEqualOtherObjectWithDifferentMethod() { // Arrange - var method = ((Action)delegate { }).GetMethodInfo(); + Action action = o => { }; + var method = action.GetMethodInfo(); var sut = new StaticMethod(method); - var otherMethod = ((Action)delegate { }).GetMethodInfo(); + Action otherAction = i => { }; + var otherMethod = otherAction.GetMethodInfo(); object other = new StaticMethod(otherMethod); // Act @@ -173,10 +180,12 @@ public void SutDoesNotEqualOtherObjectWithDifferentMethod() public void SutDoesNotEqualOtherObjectWithDifferentParameters() { // Arrange - var method = ((Action)delegate { }).GetMethodInfo(); + Action action = o => { }; + var method = action.GetMethodInfo(); var sut = new StaticMethod(method, method.GetParameters()); - var otherParameters = ((Action)delegate { }).GetMethodInfo().GetParameters(); + Action otherAction = i => { }; + var otherParameters = otherAction.GetMethodInfo().GetParameters(); object other = new StaticMethod(method, otherParameters); // Act @@ -188,7 +197,8 @@ public void SutDoesNotEqualOtherObjectWithDifferentParameters() [Fact] public void SutEqualsOtherObjectWithSameMethod() { - var method = ((Action)delegate { }).GetMethodInfo(); + Action action = o => { }; + var method = action.GetMethodInfo(); var sut = new StaticMethod(method); object other = new StaticMethod(method); // Act @@ -200,7 +210,8 @@ public void SutEqualsOtherObjectWithSameMethod() [Fact] public void SutEqualsOtherObjectWithSameMethodAndSameParameters() { - var method = ((Action)delegate { }).GetMethodInfo(); + Action action = o => { }; + var method = action.GetMethodInfo(); var parameters = method.GetParameters(); var sut = new StaticMethod(method, parameters); object other = new StaticMethod(method, parameters); @@ -214,7 +225,8 @@ public void SutEqualsOtherObjectWithSameMethodAndSameParameters() public void GetHashCodeReturnsCorrectResult() { // Arrange - var method = ((Action)delegate { }).GetMethodInfo(); + Action action = o => { }; + var method = action.GetMethodInfo(); var sut = new StaticMethod(method); // Act var result = sut.GetHashCode(); diff --git a/Src/AutoFixtureUnitTest/Kernel/TemplateMethodQueryTests.cs b/Src/AutoFixtureUnitTest/Kernel/TemplateMethodQueryTests.cs index e21b4c50c..85ea461ef 100644 --- a/Src/AutoFixtureUnitTest/Kernel/TemplateMethodQueryTests.cs +++ b/Src/AutoFixtureUnitTest/Kernel/TemplateMethodQueryTests.cs @@ -13,7 +13,7 @@ public class TemplateMethodQueryTests [Fact] public void SutIsIMethodQuery() { - Action dummy = delegate { }; + Action dummy = () => { }; var sut = new TemplateMethodQuery(dummy.GetMethodInfo()); Assert.IsAssignableFrom(sut); } @@ -34,14 +34,14 @@ public void InitializeSecondConstructorWithNullTemplateThrows() [Fact] public void InitializeWithNullOwnerThrows() { - Action dummy = delegate { }; + Action dummy = () => { }; Assert.Throws(() => new TemplateMethodQuery(dummy.GetMethodInfo(), null)); } [Fact] public void TemplateIsCorrect() { - Action dummy = delegate { }; + Action dummy = () => { }; var sut = new TemplateMethodQuery(dummy.GetMethodInfo()); Assert.Equal(dummy.GetMethodInfo(), sut.Template); } @@ -49,7 +49,7 @@ public void TemplateIsCorrect() [Fact] public void OwnerIsCorrect() { - Action dummy = delegate { }; + Action dummy = () => { }; var owner = new object(); var sut = new TemplateMethodQuery(dummy.GetMethodInfo(), owner); @@ -60,7 +60,7 @@ public void OwnerIsCorrect() [Fact] public void SelectMethodsWithNullThrows() { - Action dummy = delegate { }; + Action dummy = () => { }; var sut = new TemplateMethodQuery(dummy.GetMethodInfo()); Assert.Throws(() => sut.SelectMethods(null)); diff --git a/Src/AutoFixtureUnitTest/Kernel/TerminatingWithPathSpecimenBuilderTest.cs b/Src/AutoFixtureUnitTest/Kernel/TerminatingWithPathSpecimenBuilderTest.cs index 702dd0bff..c4396bf14 100644 --- a/Src/AutoFixtureUnitTest/Kernel/TerminatingWithPathSpecimenBuilderTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/TerminatingWithPathSpecimenBuilderTest.cs @@ -389,7 +389,6 @@ public void ShouldWrapObjectCreationExceptionsFromInnerBuilders() var request = new object(); var exceptionToThrow = new ObjectCreationException("Creation failed."); - var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => throw exceptionToThrow @@ -449,7 +448,6 @@ public void ThrownExceptionIncludesInnerExceptionMessages() var actualEx = Assert.ThrowsAny(() => sut.Create(request, context)); Assert.Contains("WRAPPED_INNER_EXCEPTION", actualEx.Message); Assert.Contains("INNER_INNER_EXCEPTION", actualEx.Message); - } } } diff --git a/Src/AutoFixtureUnitTest/Kernel/TracingBuilderTest.cs b/Src/AutoFixtureUnitTest/Kernel/TracingBuilderTest.cs index f3607489f..5dabcd30b 100644 --- a/Src/AutoFixtureUnitTest/Kernel/TracingBuilderTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/TracingBuilderTest.cs @@ -62,7 +62,6 @@ public void CreateWillPassThroughToDecoratedBuilder() // Assert Assert.Equal(expectedSpecimen, result); - } [Fact] @@ -124,7 +123,6 @@ public void CreateWillTrackCompositeRequests() // Assert Assert.Equal(2, spy.Count); Assert.Equal(subRequest, spy[1]); - } [Fact] @@ -158,7 +156,6 @@ public void CreateWillTrackCreatedSpecimen() // Assert Assert.Equal(res, tracked); - } [Fact] @@ -210,7 +207,6 @@ public void CreateWillTrackCreatedSpecimensComposite() Assert.Equal(2, spy.Count); Assert.Equal(createdSpecimen, spy[0]); Assert.Equal(createdSpecimen, spy[1]); - } [Fact] @@ -337,7 +333,6 @@ public void IgnoredTypeWillNotTrackRequest() // Assert Assert.Null(tracked); - } [Fact] @@ -369,7 +364,9 @@ public void DepthWillBeResetAfterDecoratedBuilderThrows() Assert.Equal(1, lastRequestDepth); } - class PrivateException : Exception { } + private class PrivateException : Exception + { + } [Fact] public void CreateWillNotRaiseSpecimenCreatedForIgnoredType() @@ -409,7 +406,6 @@ public void IgnoredTypeWillNotTrackCreatedSpecimen() // Assert Assert.Null(tracked); - } } } \ No newline at end of file diff --git a/Src/AutoFixtureUnitTest/Kernel/TypeArgumentsCannotBeInferredExceptionTests.cs b/Src/AutoFixtureUnitTest/Kernel/TypeArgumentsCannotBeInferredExceptionTests.cs index c901d1213..1f20e8b05 100644 --- a/Src/AutoFixtureUnitTest/Kernel/TypeArgumentsCannotBeInferredExceptionTests.cs +++ b/Src/AutoFixtureUnitTest/Kernel/TypeArgumentsCannotBeInferredExceptionTests.cs @@ -32,7 +32,7 @@ public void InitializeWithNullMethodInfoThrows() [Fact] public void MessageWillBeDefineWhenInitializedWithMethodInfo() { - Action dummy = delegate { }; + Action dummy = () => { }; var sut = new TypeArgumentsCannotBeInferredException(dummy.GetMethodInfo()); var result = sut.Message; diff --git a/Src/AutoFixtureUnitTest/Kernel/TypeRelayTests.cs b/Src/AutoFixtureUnitTest/Kernel/TypeRelayTests.cs index 123ec6f5d..09947f5b5 100644 --- a/Src/AutoFixtureUnitTest/Kernel/TypeRelayTests.cs +++ b/Src/AutoFixtureUnitTest/Kernel/TypeRelayTests.cs @@ -134,7 +134,6 @@ public void DocumentationExample() Assert.IsAssignableFrom(actual); } - [Fact] public void ShouldNotFailIfOpenGenericsIsPassedToConstructor() { @@ -217,8 +216,12 @@ public void FailsAtResolveIfImproperMappingIsSpecified() sut.Create(request, dummyContext)); } - private abstract class BaseType { } + private abstract class BaseType + { + } - private class DerivedType : BaseType { } + private class DerivedType : BaseType + { + } } } diff --git a/Src/AutoFixtureUnitTest/Kernel/ValueTypeSpecificationTest.cs b/Src/AutoFixtureUnitTest/Kernel/ValueTypeSpecificationTest.cs index 52367d608..4771acd82 100644 --- a/Src/AutoFixtureUnitTest/Kernel/ValueTypeSpecificationTest.cs +++ b/Src/AutoFixtureUnitTest/Kernel/ValueTypeSpecificationTest.cs @@ -37,7 +37,7 @@ public void IsSatisfiedByNullThrows() [InlineData(typeof(char), false)] [InlineData(typeof(ActivityScope), false)] [InlineData(typeof(decimal), true)] - [InlineData(typeof(Nullable), true)] + [InlineData(typeof(int?), true)] public void IsSatisfiedByReturnsCorrectResult(object request, bool expectedResult) { // Arrange diff --git a/Src/AutoFixtureUnitTest/LazyRelayTest.cs b/Src/AutoFixtureUnitTest/LazyRelayTest.cs index fd15f4d2e..7a1e094c5 100644 --- a/Src/AutoFixtureUnitTest/LazyRelayTest.cs +++ b/Src/AutoFixtureUnitTest/LazyRelayTest.cs @@ -107,25 +107,31 @@ public void CreateWithLazyRequestReturnsCorrectResult() public class LazyRelayTestOfInt32 : LazyRelayTest - { } + { + } public class LazyRelayTestOfString : LazyRelayTest - { } + { + } public class LazyRelayTestOfVersion : LazyRelayTest - { } + { + } public class LazyRelayTestOfSingleParameterType : LazyRelayTest> - { } + { + } public class LazyRelayTestOfDoubleParameterType : LazyRelayTest> - { } + { + } public class LazyRelayTestOfTripleParameterType : LazyRelayTest> - { } + { + } } diff --git a/Src/AutoFixtureUnitTest/MailAddressGeneratorTests.cs b/Src/AutoFixtureUnitTest/MailAddressGeneratorTest.cs similarity index 100% rename from Src/AutoFixtureUnitTest/MailAddressGeneratorTests.cs rename to Src/AutoFixtureUnitTest/MailAddressGeneratorTest.cs diff --git a/Src/AutoFixtureUnitTest/MarkerNodeTests.cs b/Src/AutoFixtureUnitTest/MarkerNodeTests.cs index fe5435002..2870858aa 100644 --- a/Src/AutoFixtureUnitTest/MarkerNodeTests.cs +++ b/Src/AutoFixtureUnitTest/MarkerNodeTests.cs @@ -8,9 +8,9 @@ namespace AutoFixtureUnitTest { - public abstract class MarkerNodeTests where T : ISpecimenBuilderNode + public abstract class MarkerNodeTests + where T : ISpecimenBuilderNode { - [Fact] public void BuilderIsCorrect() { diff --git a/Src/AutoFixtureUnitTest/MultipleCustomizationTest.cs b/Src/AutoFixtureUnitTest/MultipleCustomizationTest.cs index 154243eac..f0d4fd6fa 100644 --- a/Src/AutoFixtureUnitTest/MultipleCustomizationTest.cs +++ b/Src/AutoFixtureUnitTest/MultipleCustomizationTest.cs @@ -91,8 +91,6 @@ public void CustomizeAddsBuilderForConcreteDictionaries() .Any()); } - #region Usage/scenario tests - [Fact] public void CreateAnonymousEnumerableReturnsCorrectResult() { @@ -180,7 +178,5 @@ public void CreateAnonymousIDictionaryReturnsCorrectResult() // Assert Assert.True(result.Any()); } - - #endregion } } diff --git a/Src/AutoFixtureUnitTest/MutableValueTypeGeneratorTest.cs b/Src/AutoFixtureUnitTest/MutableValueTypeGeneratorTest.cs index e802316e2..bdfcb604c 100644 --- a/Src/AutoFixtureUnitTest/MutableValueTypeGeneratorTest.cs +++ b/Src/AutoFixtureUnitTest/MutableValueTypeGeneratorTest.cs @@ -94,7 +94,6 @@ public void CreateWithValueTypeRequestWillReturnCorrectResult() var result = sut.Create(valueTypeRequest, dummyContainer); // Assert Assert.IsType(result); - } } } diff --git a/Src/AutoFixtureUnitTest/NavigationPropertyRecursionIssue/Repro.cs b/Src/AutoFixtureUnitTest/NavigationPropertyRecursionIssue/Repro.cs index 29ba57160..dc8e63611 100644 --- a/Src/AutoFixtureUnitTest/NavigationPropertyRecursionIssue/Repro.cs +++ b/Src/AutoFixtureUnitTest/NavigationPropertyRecursionIssue/Repro.cs @@ -8,7 +8,7 @@ public class Repro { /// /// This test reproduces the issue reported at - /// http://stackoverflow.com/q/12531920/126014 + /// http://stackoverflow.com/q/12531920/126014. /// [Fact] public void Issue() diff --git a/Src/AutoFixtureUnitTest/NumericSequenceGeneratorTest.cs b/Src/AutoFixtureUnitTest/NumericSequenceGeneratorTest.cs index 2d7989c05..953229f64 100644 --- a/Src/AutoFixtureUnitTest/NumericSequenceGeneratorTest.cs +++ b/Src/AutoFixtureUnitTest/NumericSequenceGeneratorTest.cs @@ -99,8 +99,8 @@ public void CreateWithNumericTypeRequestReturnsCorrectValue(Type request) public void CreateWith256ByteRequestsReturnsByteSpecimens() { // Arrange - var sequence = Enumerable.Range(0, Byte.MaxValue + 1); - var request = typeof(Byte); + var sequence = Enumerable.Range(0, byte.MaxValue + 1); + var request = typeof(byte); var sut = new NumericSequenceGenerator(); // Act var dummyContainer = new DelegatingSpecimenContext(); @@ -113,8 +113,8 @@ public void CreateWith256ByteRequestsReturnsByteSpecimens() public void CreateWith128SByteRequestsReturnsSByteSpecimens() { // Arrange - var sequence = Enumerable.Range(0, SByte.MaxValue + 1); - var request = typeof(SByte); + var sequence = Enumerable.Range(0, sbyte.MaxValue + 1); + var request = typeof(sbyte); var sut = new NumericSequenceGenerator(); // Act var dummyContainer = new DelegatingSpecimenContext(); diff --git a/Src/AutoFixtureUnitTest/NumericSequencePerTypeCustomizationTest.cs b/Src/AutoFixtureUnitTest/NumericSequencePerTypeCustomizationTest.cs index 6621bd65c..91c43807b 100644 --- a/Src/AutoFixtureUnitTest/NumericSequencePerTypeCustomizationTest.cs +++ b/Src/AutoFixtureUnitTest/NumericSequencePerTypeCustomizationTest.cs @@ -68,12 +68,12 @@ public void CreateAnonymousWithNumericSequencePerTypeCustomizationWillReturnCorr 1.0D, (short)1, 1, - (long)1, + 1L, (sbyte)1, 1.0F, (ushort)1, - (uint)1, - (ulong)1 + 1U, + 1UL }; var sut = new Fixture(); var customization = new NumericSequencePerTypeCustomization(); diff --git a/Src/AutoFixtureUnitTest/Properties/AssemblyInfo.cs b/Src/AutoFixtureUnitTest/Properties/AssemblyInfo.cs index d7ecb1ec5..2934fa681 100644 --- a/Src/AutoFixtureUnitTest/Properties/AssemblyInfo.cs +++ b/Src/AutoFixtureUnitTest/Properties/AssemblyInfo.cs @@ -4,8 +4,8 @@ [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM componenets. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM componenets. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoFixtureUnitTest/RandomBooleanSequenceCustomizationTest.cs b/Src/AutoFixtureUnitTest/RandomBooleanSequenceCustomizationTest.cs index eba9a78e1..ea2bd1356 100644 --- a/Src/AutoFixtureUnitTest/RandomBooleanSequenceCustomizationTest.cs +++ b/Src/AutoFixtureUnitTest/RandomBooleanSequenceCustomizationTest.cs @@ -38,7 +38,5 @@ public void CustomizeProperFixtureCorrectlyCustomizesIt() // Assert Assert.NotNull(result); } - - } } \ No newline at end of file diff --git a/Src/AutoFixtureUnitTest/RandomNumericSequenceGeneratorTest.cs b/Src/AutoFixtureUnitTest/RandomNumericSequenceGeneratorTest.cs index b4bb61697..dc260bb13 100644 --- a/Src/AutoFixtureUnitTest/RandomNumericSequenceGeneratorTest.cs +++ b/Src/AutoFixtureUnitTest/RandomNumericSequenceGeneratorTest.cs @@ -27,9 +27,9 @@ public void InitializeWithDefaultConstructorSetsCorrectLimits() var expectedResult = new long[] { 1, - Byte.MaxValue, - Int16.MaxValue, - Int32.MaxValue + byte.MaxValue, + short.MaxValue, + int.MaxValue }; // Act IEnumerable result = sut.Limits; @@ -61,7 +61,7 @@ public void InitializeWithSingleLimitThrows(long[] limits) [Theory] [InlineData(new long[] { 10, 5 })] - [InlineData(new long[] { 32, 8, Int32.MaxValue })] + [InlineData(new long[] { 32, 8, int.MaxValue })] [InlineData(new long[] { 0, -2, 5 })] [InlineData(new long[] { -4, -8 })] [InlineData(new long[] { 1, 1, 5 })] @@ -208,8 +208,7 @@ public void CreateReturnsNumberInCorrectRange(long[] limits) var result = (double)sut.Create(request, dummyContext); // Assert Assert.True( - result >= expectedMin && result <= expectedMax - ); + result >= expectedMin && result <= expectedMax); } [Theory] @@ -230,8 +229,7 @@ public void CreateReturnsNumberInCorrectRangeOnMultipleCall(long[] limits) .Cast(); // Assert Assert.True( - result.All(x => x >= expectedMin && x <= expectedMax) - ); + result.All(x => x >= expectedMin && x <= expectedMax)); } [Theory] @@ -247,9 +245,9 @@ public void CreateReturnsNumberInCorrectRangeOnMultipleCall(long[] limits) [InlineData(new[] { (long)int.MaxValue + 10, long.MaxValue })] [InlineData(new[] { (long)int.MaxValue + 200, long.MaxValue })] [InlineData(new[] { (long)int.MaxValue + 3000, long.MaxValue })] - [InlineData(new[] { -byte.MaxValue, (long)(int.MaxValue) + 10 })] - [InlineData(new[] { -byte.MaxValue, (long)(int.MaxValue) + 200 })] - [InlineData(new[] { -byte.MaxValue, (long)(int.MaxValue) + 3000 })] + [InlineData(new[] { -byte.MaxValue, (long)int.MaxValue + 10 })] + [InlineData(new[] { -byte.MaxValue, (long)int.MaxValue + 200 })] + [InlineData(new[] { -byte.MaxValue, (long)int.MaxValue + 3000 })] [InlineData(new[] { long.MinValue + byte.MaxValue, byte.MaxValue })] public void CreateReturnsNumberInCorrectRangeForInt64OnMultipleCall(long[] limits) { @@ -266,8 +264,7 @@ public void CreateReturnsNumberInCorrectRangeForInt64OnMultipleCall(long[] limit .Cast(); // Assert Assert.True( - result.All(x => x >= expectedMin && x <= expectedMax) - ); + result.All(x => x >= expectedMin && x <= expectedMax)); } [Theory] @@ -391,6 +388,5 @@ public void CreateReturnsUniqueNumbersOnMultipleCallAsynchronously(long[] limits new long[] { 2, 5, 9, 30, 255, 512 }, new long[] { -30, -9, -5, 2, 5, 9, 30 } }; - } } diff --git a/Src/AutoFixtureUnitTest/RandomRangedNumberGeneratorTest.cs b/Src/AutoFixtureUnitTest/RandomRangedNumberGeneratorTest.cs index 5ec3d2ac2..98d895c55 100644 --- a/Src/AutoFixtureUnitTest/RandomRangedNumberGeneratorTest.cs +++ b/Src/AutoFixtureUnitTest/RandomRangedNumberGeneratorTest.cs @@ -56,7 +56,6 @@ public void CreateWithAnonymousRequestReturnsCorrectResult() Assert.Equal(new NoSpecimen(), result); } - [Theory] [InlineData(typeof(int), "a", "b")] [InlineData(typeof(long), 'd', 'e')] @@ -74,7 +73,6 @@ public void CreateWithNonnumericLimitsReturnsNoSpecimen(Type operandType, object Assert.Equal(new NoSpecimen(), result); } - [Fact] public void CreateReturnsAllValuesInSetBeforeRepeating() { @@ -95,7 +93,6 @@ public void CreateReturnsAllValuesInSetBeforeRepeating() // Verify Assert.True(generatedValues.All(a => a >= minimum && a <= maximum)); Assert.InRange(shouldBeRepeatedValue, minimum, maximum); - } [Theory] @@ -103,8 +100,8 @@ public void CreateReturnsAllValuesInSetBeforeRepeating() [InlineData(-20, 10, 20, 11, -20, 15, 21, 15, -20, 20, 21, 20)] [InlineData(0, 2, 1, 2, -1, 2, 2, 2, -2, 2, 2, 3)] [InlineData(-20, 10, 20, 11, -15, 10, 16, 10, -10, 10, 11, 10)] - public void CreateReturnsCorrectValuesForRequestsOfSameTypeAndSingleSharedLimit - (int request1Min, int request1Max, int request1FirstGroup, int request1SecondGroup, + public void CreateReturnsCorrectValuesForRequestsOfSameTypeAndSingleSharedLimit( + int request1Min, int request1Max, int request1FirstGroup, int request1SecondGroup, int request2Min, int request2Max, int request2FirstGroup, int request2SecondGroup, int request3Min, int request3Max, int request3FirstGroup, int request3SecondGroup) { @@ -134,7 +131,7 @@ public void CreateReturnsCorrectValuesForRequestsOfSameTypeAndSingleSharedLimit results[request2].AddMany(() => (int)sut.Create(request2, dummyContext), request2SecondGroup); results[request3].AddMany(() => (int)sut.Create(request3, dummyContext), request3SecondGroup); - // Verify + // Verify Assert.True(Enumerable.Range(request1Min, request1Count) .Intersect(results[request1]).Count() == request1Count); Assert.True(Enumerable.Range(request2Min, request2Count) @@ -143,7 +140,6 @@ public void CreateReturnsCorrectValuesForRequestsOfSameTypeAndSingleSharedLimit .Intersect(results[request3]).Count() == request3Count); } - [Fact] public void CreateReturnsValuesFromCorrectSetForTwoRequestsOfSameTypeAndDifferentLimits() { @@ -190,7 +186,6 @@ public void CreateReturnsValuesFromCorrectSetForMultipleRequestsWithInterspersed Assert.NotEqual(value1, value3); } - [Theory] [MemberData(nameof(PairsOfDifferentIntegerTypes))] public void CreateReturnsValuesFromCorrectSetForRequestsWithDifferentTypesAndSameLimits( @@ -210,7 +205,7 @@ public void CreateReturnsValuesFromCorrectSetForMultipleRequestsWithInterspersed // Act primaryResults.Add((IComparable)sut.Create(primaryRequest, dummyContext)); primaryResults.Add((IComparable)sut.Create(primaryRequest, dummyContext)); - var otherResult = ((IComparable)sut.Create(otherRequest, dummyContext)); + var otherResult = (IComparable)sut.Create(otherRequest, dummyContext); primaryResults.Add((IComparable)sut.Create(primaryRequest, dummyContext)); // Verify @@ -230,14 +225,13 @@ public void CreateReturnsValuesFromCorrectSetForMultipleRequestsWithInterspersed public void CreateReturnsUniqueNumbersOnMultipleCallAsynchronously(int minimum, int maximum, int numberOfThreads) { // Arrange - int expectedDistinctCount = Math.Abs((maximum - minimum + 1)); + int expectedDistinctCount = Math.Abs(maximum - minimum + 1); int requestsPerThread = expectedDistinctCount / numberOfThreads; var dummyContext = new DelegatingSpecimenContext(); var sut = new RandomRangedNumberGenerator(); // Act - var numbers = Enumerable .Range(0, numberOfThreads) .AsParallel() @@ -254,7 +248,6 @@ public void CreateReturnsUniqueNumbersOnMultipleCallAsynchronously(int minimum, // Verify int actualDistinctCount = numbers.SelectMany(a => a).Distinct().Count(); Assert.Equal(expectedDistinctCount, actualDistinctCount); - } [Theory] @@ -268,7 +261,6 @@ public void CreationOnFullRangeShouldNotFail(Type type, object minimum, object m // Act & Assert Assert.Null(Record.Exception(() => sut.Create(request, dummyContext))); - } [Theory] @@ -285,7 +277,6 @@ public void CreationOnFullRangeShouldReturnValue(Type type, object minimum, obje // Assert Assert.IsType(type, result); - } [Theory] @@ -302,7 +293,6 @@ public void CreationWithLimitsInBoundariesShouldReturnValueInRange(Type type, ob // Assert Assert.InRange(result, (IComparable)minimum, (IComparable)maximum); - } [Theory] @@ -351,71 +341,65 @@ public void ShouldCorrectlyHandleRequestsWithSameMinimumAndMaximumValue(Type typ public static TheoryData RequestsWithLimitsToZeroRange => new TheoryData { - { typeof(float), float.MinValue, (float)0 }, - { typeof(float), (float)0, float.MaxValue }, - - { typeof(double), double.MinValue, (double)0 }, - { typeof(double), (double)0, double.MaxValue }, - - { typeof(decimal), decimal.MinValue, (decimal)0 }, - { typeof(decimal), (decimal)0, decimal.MaxValue }, - + { typeof(float), float.MinValue, 0F }, + { typeof(float), 0F, float.MaxValue }, + { typeof(double), double.MinValue, 0D }, + { typeof(double), 0D, double.MaxValue }, + { typeof(decimal), decimal.MinValue, 0M }, + { typeof(decimal), 0M, decimal.MaxValue }, { typeof(sbyte), sbyte.MinValue, (sbyte)0 }, { typeof(sbyte), (sbyte)0, sbyte.MaxValue }, - { typeof(byte), (byte)0, byte.MaxValue }, - + { typeof(byte), byte.MinValue, byte.MaxValue }, { typeof(short), short.MinValue, (short)0 }, { typeof(short), (short)0, short.MaxValue }, - { typeof(ushort), (ushort)0, ushort.MaxValue }, - - { typeof(int), int.MinValue, (int)0 }, - { typeof(int), (int)0, int.MaxValue }, - { typeof(uint), (uint)0, uint.MaxValue }, - - { typeof(long), long.MinValue, (long)0 }, - { typeof(long), (long)0, long.MaxValue }, - { typeof(ulong), (ulong)0, ulong.MaxValue } + { typeof(ushort), ushort.MinValue, ushort.MaxValue }, + { typeof(int), int.MinValue, 0 }, + { typeof(int), 0, int.MaxValue }, + { typeof(uint), uint.MinValue, uint.MaxValue }, + { typeof(long), long.MinValue, 0L }, + { typeof(long), 0L, long.MaxValue }, + { typeof(ulong), ulong.MinValue, ulong.MaxValue } }; public static TheoryData PairsOfDifferentIntegerTypes => new TheoryData { + // sbyte { typeof(sbyte), typeof(int) }, { typeof(sbyte), typeof(byte) }, { typeof(sbyte), typeof(short) }, { typeof(sbyte), typeof(long) }, { typeof(sbyte), typeof(ulong) }, { typeof(sbyte), typeof(ushort) }, - + // long { typeof(long), typeof(int) }, { typeof(long), typeof(byte) }, { typeof(long), typeof(short) }, { typeof(long), typeof(sbyte) }, { typeof(long), typeof(ushort) }, { typeof(long), typeof(uint) }, - - + // int { typeof(int), typeof(ulong) }, { typeof(int), typeof(byte) }, { typeof(int), typeof(short) }, { typeof(int), typeof(long) }, { typeof(int), typeof(ushort) }, { typeof(int), typeof(sbyte) }, - + // short { typeof(short), typeof(int) }, { typeof(short), typeof(byte) }, { typeof(short), typeof(ushort) }, { typeof(short), typeof(long) }, { typeof(short), typeof(sbyte) }, { typeof(short), typeof(ulong) }, - + // byte { typeof(byte), typeof(int) }, { typeof(byte), typeof(short) }, { typeof(byte), typeof(sbyte) }, { typeof(byte), typeof(long) }, { typeof(byte), typeof(ushort) }, { typeof(byte), typeof(ulong) }, - + // unit { typeof(uint), typeof(int) }, { typeof(uint), typeof(short) }, { typeof(uint), typeof(sbyte) }, diff --git a/Src/AutoFixtureUnitTest/RangedNumberGeneratorTest.cs b/Src/AutoFixtureUnitTest/RangedNumberGeneratorTest.cs index f95b30a75..cdf045383 100644 --- a/Src/AutoFixtureUnitTest/RangedNumberGeneratorTest.cs +++ b/Src/AutoFixtureUnitTest/RangedNumberGeneratorTest.cs @@ -223,18 +223,15 @@ public void CreateWithDifferentOperandTypeDoesNotThrowOnMultipleCall(object mini new RangedNumberRequest( typeof(decimal), Convert.ChangeType(minimum, typeof(decimal)), - Convert.ChangeType(maximum, typeof(decimal)) - ), + Convert.ChangeType(maximum, typeof(decimal))), new RangedNumberRequest( typeof(double), Convert.ChangeType(minimum, typeof(double)), - Convert.ChangeType(maximum, typeof(double)) - ), + Convert.ChangeType(maximum, typeof(double))), new RangedNumberRequest( typeof(decimal), Convert.ChangeType(minimum, typeof(decimal)), - Convert.ChangeType(maximum, typeof(decimal)) - ) + Convert.ChangeType(maximum, typeof(decimal))) }; var context = new DelegatingSpecimenContext { @@ -254,7 +251,6 @@ public void CreateWithDifferentOperandTypeDoesNotThrowOnMultipleCall(object mini { Assert.Null(Record.Exception(() => sut.Create(r, context))); } - } [Fact] @@ -277,7 +273,7 @@ public void DoesNotThrowForHeterogeneousRequestsWithValuesGreaterThanByteMaxValu { request = new RangedNumberRequest( - typeof(short), (short)(byte.MaxValue), short.MaxValue), + typeof(short), (short)byte.MaxValue, short.MaxValue), contextStub = new DelegatingSpecimenContext { @@ -325,7 +321,7 @@ public void DoesNotThrowForHeterogeneousRequestsWithValuesGreaterThanInt16MaxVal { request = new RangedNumberRequest( - typeof(int), (int)(short.MaxValue), int.MaxValue), + typeof(int), (int)short.MaxValue, int.MaxValue), contextStub = new DelegatingSpecimenContext { @@ -372,14 +368,14 @@ public IEnumerator GetEnumerator() yield return CreateTestCase(operandType: typeof(int), minimum: 10, maximum: 20, contextValue: new object(), expectedResult: new NoSpecimen()); - yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 1, expectedResult: (uint)11); - yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 2, expectedResult: (uint)12); - yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 3, expectedResult: (uint)13); - yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 10, expectedResult: (uint)10); - yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 17, expectedResult: (uint)17); - yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 20, expectedResult: (uint)20); - yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 21, expectedResult: (uint)10); - yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 13, contextValue: 4, expectedResult: (uint)10); + yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 1, expectedResult: 11U); + yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 2, expectedResult: 12U); + yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 3, expectedResult: 13U); + yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 10, expectedResult: 10U); + yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 17, expectedResult: 17U); + yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 20, expectedResult: 20U); + yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: 21, expectedResult: 10U); + yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 13, contextValue: 4, expectedResult: 10U); yield return CreateTestCase(operandType: typeof(uint), minimum: 10, maximum: 20, contextValue: new object(), expectedResult: new NoSpecimen()); @@ -413,14 +409,14 @@ public IEnumerator GetEnumerator() yield return CreateTestCase(operandType: typeof(long), minimum: 100000000000, maximum: 200000000000, contextValue: new object(), expectedResult: new NoSpecimen()); - yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 1, expectedResult: (ulong)11); - yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 2, expectedResult: (ulong)12); - yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 3, expectedResult: (ulong)13); - yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 10, expectedResult: (ulong)10); - yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 17, expectedResult: (ulong)17); - yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 20, expectedResult: (ulong)20); - yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 21, expectedResult: (ulong)10); - yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 13, contextValue: 4, expectedResult: (ulong)10); + yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 1, expectedResult: 11UL); + yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 2, expectedResult: 12UL); + yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 3, expectedResult: 13UL); + yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 10, expectedResult: 10UL); + yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 17, expectedResult: 17UL); + yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 20, expectedResult: 20UL); + yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: 21, expectedResult: 10UL); + yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 13, contextValue: 4, expectedResult: 10UL); yield return CreateTestCase(operandType: typeof(ulong), minimum: 10, maximum: 20, contextValue: new object(), expectedResult: new NoSpecimen()); diff --git a/Src/AutoFixtureUnitTest/RecursionGuardTest.cs b/Src/AutoFixtureUnitTest/RecursionGuardTest.cs index 1f732869b..c9d4442c4 100644 --- a/Src/AutoFixtureUnitTest/RecursionGuardTest.cs +++ b/Src/AutoFixtureUnitTest/RecursionGuardTest.cs @@ -175,7 +175,7 @@ public void CreateWillNotTriggerHandlingOnSecondarySameRequestWhenDecoratedBuild Assert.Empty(sut.UnprotectedRecordedRequests); } - class PrivateExpectedException : Exception + private class PrivateExpectedException : Exception { public PrivateExpectedException(string message) : base(message) @@ -183,7 +183,7 @@ public PrivateExpectedException(string message) } } - class PrivateUnexpectedException : Exception + private class PrivateUnexpectedException : Exception { public PrivateUnexpectedException(string message) : base(message) @@ -229,7 +229,6 @@ public void CreateWillNotTriggerHandlingUntilDeeperThanRecursionDepth() sut.OnHandleRecursiveRequest = obj => recursiveRequest = obj; - var container = new DelegatingSpecimenContext(); container.OnResolve = r => sut.Create(r, container); diff --git a/Src/AutoFixtureUnitTest/TestConsole.cs b/Src/AutoFixtureUnitTest/TestConsole.cs index 0a626f942..6e7fe78f1 100644 --- a/Src/AutoFixtureUnitTest/TestConsole.cs +++ b/Src/AutoFixtureUnitTest/TestConsole.cs @@ -1,4 +1,4 @@ -//#define ALLOWCONSOLE +// #define ALLOWCONSOLE using System.IO; using System.Text; diff --git a/Src/AutoFixtureUnitTest/UseCultureAttribute.cs b/Src/AutoFixtureUnitTest/UseCultureAttribute.cs index 70c54f681..6dab35875 100644 --- a/Src/AutoFixtureUnitTest/UseCultureAttribute.cs +++ b/Src/AutoFixtureUnitTest/UseCultureAttribute.cs @@ -27,7 +27,6 @@ public UseCultureAttribute(string culture, string uiCulture) this.uiCulture = new CultureInfo(uiCulture); } - public override void Before(MethodInfo methodUnderTest) { originalCulture = CultureInfo.CurrentCulture; diff --git a/Src/AutoMoq/AutoConfiguredMoqCustomization.cs b/Src/AutoMoq/AutoConfiguredMoqCustomization.cs index 73b852145..1b881a870 100644 --- a/Src/AutoMoq/AutoConfiguredMoqCustomization.cs +++ b/Src/AutoMoq/AutoConfiguredMoqCustomization.cs @@ -22,7 +22,6 @@ public AutoConfiguredMoqCustomization() /// /// Creates a new instance of . /// - /// A mock relay to be added to public AutoConfiguredMoqCustomization(ISpecimenBuilder relay) : base(relay) { diff --git a/Src/AutoMoq/AutoMoqCustomization.cs b/Src/AutoMoq/AutoMoqCustomization.cs index 8f0ed7f0a..17bfb77d1 100644 --- a/Src/AutoMoq/AutoMoqCustomization.cs +++ b/Src/AutoMoq/AutoMoqCustomization.cs @@ -7,7 +7,7 @@ namespace AutoFixture.AutoMoq /// Enables auto-mocking with Moq. /// /// - /// NOTICE! You can assign the customization properties to tweak the features you would like to enable. Example: + /// NOTICE! You can assign the customization properties to tweak the features you would like to enable. See example. ///
/// new AutoMoqCustomization { ConfigureMembers = true } ///
diff --git a/Src/AutoMoq/Extensions/MethodInfoBaseExtensions.cs b/Src/AutoMoq/Extensions/MethodInfoExtensions.cs similarity index 88% rename from Src/AutoMoq/Extensions/MethodInfoBaseExtensions.cs rename to Src/AutoMoq/Extensions/MethodInfoExtensions.cs index 4438ea08b..c3efc8ddf 100644 --- a/Src/AutoMoq/Extensions/MethodInfoBaseExtensions.cs +++ b/Src/AutoMoq/Extensions/MethodInfoExtensions.cs @@ -9,10 +9,10 @@ internal static bool IsOverridable(this MethodInfo method) { /* * From MSDN (http://goo.gl/WvOgYq) - * + * * To determine if a method is overridable, it is not sufficient to check that IsVirtual is true. * For a method to be overridable, IsVirtual must be true and IsFinal must be false. - * + * * For example, interface implementations are marked as "virtual final". * Methods marked with "override sealed" are also marked as "virtual final". */ @@ -27,7 +27,7 @@ internal static bool IsSealed(this MethodInfo method) internal static bool IsVoid(this MethodInfo method) { - return method.ReturnType == typeof (void); + return method.ReturnType == typeof(void); } internal static bool HasOutParameters(this MethodInfo method) @@ -38,7 +38,7 @@ internal static bool HasOutParameters(this MethodInfo method) internal static bool HasRefParameters(this MethodInfo method) { - //"out" parameters are also considered "byref", so we have to filter these out + // "out" parameters are also considered "byref", so we have to filter these out return method.GetParameters() .Any(p => p.ParameterType.IsByRef && !p.IsOut); } diff --git a/Src/AutoMoq/Extensions/TypeExtensions.cs b/Src/AutoMoq/Extensions/TypeExtensions.cs index 62269dcef..5f6af7162 100644 --- a/Src/AutoMoq/Extensions/TypeExtensions.cs +++ b/Src/AutoMoq/Extensions/TypeExtensions.cs @@ -13,7 +13,7 @@ internal static class TypeExtensions internal static IEnumerable GetAllMethods(this Type type) { IEnumerable result = type.GetMethods(); - + // If "type" is an interface, "GetMethods" does not return methods declared on other interfaces extended by "type". if (type.GetTypeInfo().IsInterface) result = result.Concat(type.GetInterfaces().SelectMany(x => x.GetMethods())); @@ -27,12 +27,12 @@ internal static IEnumerable GetAllMethods(this Type type) internal static IEnumerable GetAllProperties(this Type type) { IEnumerable result = type.GetProperties(); - + // If "type" is an interface, "GetProperties" does not return methods declared on other interfaces extended by "type". if (type.GetTypeInfo().IsInterface) result = result.Concat(type.GetInterfaces().SelectMany(x => x.GetProperties())); return result; - } + } } } diff --git a/Src/AutoMoq/GlobalSuppressions.cs b/Src/AutoMoq/GlobalSuppressions.cs index 5275322c1..097b607ac 100644 --- a/Src/AutoMoq/GlobalSuppressions.cs +++ b/Src/AutoMoq/GlobalSuppressions.cs @@ -1,13 +1,13 @@ -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. -// Project-level suppressions either have no target or are given -// a specific target and scoped to a namespace, type, member, etc. +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. // -// To add a suppression to this file, right-click the message in the -// Error List, point to "Suppress Message(s)", and click -// "In Project Suppression File". -// You do not need to add suppressions to this file manually. +// To add a suppression to this file, right-click the message in the +// Error List, point to "Suppress Message(s)", and click +// "In Project Suppression File". +// You do not need to add suppressions to this file manually. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", - Scope = "namespace", Target = "AutoFixture.AutoMoq", +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", + Scope = "namespace", Target = "AutoFixture.AutoMoq", Justification = "This should be a separate assembly because it provides extensions to AutoFixture that are specific to the use of Moq.")] diff --git a/Src/AutoMoq/GreedyMockConstructorQuery.cs b/Src/AutoMoq/GreedyMockConstructorQuery.cs index 8b057418a..21a0e692b 100644 --- a/Src/AutoMoq/GreedyMockConstructorQuery.cs +++ b/Src/AutoMoq/GreedyMockConstructorQuery.cs @@ -29,7 +29,7 @@ public class GreedyMockConstructorQuery : IMethodQuery /// interface, the default constructor is returned. If the type /// is a class, constructors are returned according to all the public and protected /// constructors of the underlying type. In this case, the - /// constructor that takes a params array is returned + /// constructor that takes a params array is returned /// for each underlying constructor, with information about the appropriate parameters for /// each constructor. /// diff --git a/Src/AutoMoq/MockConstructorQuery.cs b/Src/AutoMoq/MockConstructorQuery.cs index c0bb239a7..ca7b5079e 100644 --- a/Src/AutoMoq/MockConstructorQuery.cs +++ b/Src/AutoMoq/MockConstructorQuery.cs @@ -31,7 +31,7 @@ public class MockConstructorQuery : IMethodQuery /// interface, the default constructor is returned. If the type /// is a class, constructors are returned according to all the public and protected /// constructors of the underlying type. In this case, the - /// constructor that takes a params array is returned + /// constructor that takes a params array is returned /// for each underlying constructor, with information about the appropriate parameters for /// each constructor. /// diff --git a/Src/AutoMoq/MockPostprocessor.cs b/Src/AutoMoq/MockPostprocessor.cs index 1ad3d1e32..7f39ccbc3 100644 --- a/Src/AutoMoq/MockPostprocessor.cs +++ b/Src/AutoMoq/MockPostprocessor.cs @@ -69,7 +69,8 @@ public object Create(object request, ISpecimenContext context) [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "It's activated via reflection.")] - private class MockConfigurator : IMockConfigurator where T : class + private class MockConfigurator : IMockConfigurator + where T : class { public void Configure(Mock mock) { diff --git a/Src/AutoMoq/MockRelay.cs b/Src/AutoMoq/MockRelay.cs index 68a3fd3bc..9d749cad3 100644 --- a/Src/AutoMoq/MockRelay.cs +++ b/Src/AutoMoq/MockRelay.cs @@ -71,6 +71,7 @@ public object Create(object request, ISpecimenContext context) return new NoSpecimen(); var result = ResolveMock(t, context); + // Note: null is a valid specimen (e.g., returned by NullRecursionHandler) if (result is NoSpecimen || result is OmitSpecimen || result == null) return result; @@ -84,7 +85,7 @@ public object Create(object request, ISpecimenContext context) private static object ResolveMock(Type t, ISpecimenContext context) { - var mockType = typeof (Mock<>).MakeGenericType(t); + var mockType = typeof(Mock<>).MakeGenericType(t); return context.Resolve(mockType); } diff --git a/Src/AutoMoq/MockSealedPropertiesCommand.cs b/Src/AutoMoq/MockSealedPropertiesCommand.cs index 654c5f690..039b7dd59 100644 --- a/Src/AutoMoq/MockSealedPropertiesCommand.cs +++ b/Src/AutoMoq/MockSealedPropertiesCommand.cs @@ -45,7 +45,7 @@ public bool IsSatisfiedBy(object request) { case PropertyInfo pi: return pi.GetSetMethod().IsSealed(); - + case FieldInfo fi: return !IsDynamicProxyMember(fi); } diff --git a/Src/AutoMoq/MockType.cs b/Src/AutoMoq/MockType.cs index 95dda8a62..7f9f98132 100644 --- a/Src/AutoMoq/MockType.cs +++ b/Src/AutoMoq/MockType.cs @@ -36,10 +36,10 @@ public static class MockType internal static bool IsMock(this Type type) { - return (type != null + return type != null && type.GetTypeInfo().IsGenericType && typeof(Mock<>).IsAssignableFrom(type.GetGenericTypeDefinition()) - && !type.GetMockedType().IsGenericParameter); + && !type.GetMockedType().IsGenericParameter; } internal static ConstructorInfo GetDefaultConstructor(this Type type) @@ -69,28 +69,32 @@ internal static Type GetMockedType(this Type type) { return setup.Returns(() => { - var specimen = context.Resolve(typeof (TResult)); + var specimen = context.Resolve(typeof(TResult)); // check if specimen is null but member is non-nullable value type if (specimen == null && (default(TResult) != null)) + { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, "Tried to setup a member with a return type of {0}, but null was found instead.", - typeof (TResult))); + typeof(TResult))); + } // check if specimen can be safely converted to TResult if (specimen != null && !(specimen is TResult)) + { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, "Tried to setup a member with a return type of {0}, but an instance of {1} was found instead.", - typeof (TResult), + typeof(TResult), specimen.GetType())); + } - TResult result = (TResult) specimen; + TResult result = (TResult)specimen; - //"cache" value for future invocations + // "cache" value for future invocations setup.Returns(result); return result; }); diff --git a/Src/AutoMoq/MockVirtualMethodsCommand.cs b/Src/AutoMoq/MockVirtualMethodsCommand.cs index 6e04717a8..570551c6c 100644 --- a/Src/AutoMoq/MockVirtualMethodsCommand.cs +++ b/Src/AutoMoq/MockVirtualMethodsCommand.cs @@ -13,7 +13,7 @@ namespace AutoFixture.AutoMoq /// /// Sets up a mocked object's methods so that the return values will be retrieved from a fixture, /// instead of being created directly by Moq. - /// + /// /// This will setup any virtual methods that are either non-void or have "out" parameters. /// /// @@ -21,7 +21,7 @@ namespace AutoFixture.AutoMoq /// This includes: /// - interface's methods/property getters; /// - class's abstract/virtual/overridden/non-sealed methods/property getters. - /// + /// /// Notes: /// - Due to a limitation in Moq, methods with "ref" parameters are skipped. /// - Automatic mocking of generic methods isn't feasible either - we'd have to antecipate any type parameters that this method could be called with. @@ -61,14 +61,14 @@ public void Execute(object specimen, ISpecimenContext context) this.GetType() .GetMethod(nameof(SetupVoidMethod), BindingFlags.NonPublic | BindingFlags.Static) .MakeGenericMethod(mockedType) - .Invoke(this, new object[] {mock, methodInvocationLambda}); + .Invoke(this, new object[] { mock, methodInvocationLambda }); } else { this.GetType() .GetMethod(nameof(SetupMethod), BindingFlags.NonPublic | BindingFlags.Static) .MakeGenericMethod(mockedType, returnType) - .Invoke(this, new object[] {mock, methodInvocationLambda, context}); + .Invoke(this, new object[] { mock, methodInvocationLambda, context }); } } } @@ -130,10 +130,10 @@ private static IEnumerable SkipWritablePropertyGetters(Type type, IE .Where(p => p.GetGetMethod() != null && p.GetSetMethod() != null) .Select(p => p.GetGetMethod()); - + return methods.Except(getterMethods); } - + /// /// Determines whether a method can be mocked. /// @@ -149,7 +149,7 @@ private static bool CanBeConfigured(MethodInfo method) /// /// Returns a lambda expression thats represents an invocation of a mocked type's method. - /// E.g., x.Method(It.IsAny(), out parameter) ]]> + /// E.g.,. x.Method(It.IsAny(), out parameter) ]]> /// private static Expression MakeMethodInvocationLambda(Type mockedType, MethodInfo method, ISpecimenContext context) @@ -165,11 +165,15 @@ private static bool CanBeConfigured(MethodInfo method) Expression methodCall; if (DelegateSpecification.IsSatisfiedBy(mockedType)) + { // e.g. "x(It.IsAny(), out parameter)" methodCall = Expression.Invoke(lambdaParam, methodCallParams); + } else + { // e.g. "x.Method(It.IsAny(), out parameter)" methodCall = Expression.Call(lambdaParam, method, methodCallParams); + } // e.g. "x => x.Method(It.IsAny(), out parameter)" // or "x => x(It.IsAny(), out parameter)" diff --git a/Src/AutoMoq/Properties/AssemblyInfo.cs b/Src/AutoMoq/Properties/AssemblyInfo.cs index 56c7074ee..12e9dee53 100644 --- a/Src/AutoMoq/Properties/AssemblyInfo.cs +++ b/Src/AutoMoq/Properties/AssemblyInfo.cs @@ -1,14 +1,14 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Runtime.InteropServices; -using System; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoMoq/StubPropertiesCommand.cs b/Src/AutoMoq/StubPropertiesCommand.cs index 201034661..0ac8f3a10 100644 --- a/Src/AutoMoq/StubPropertiesCommand.cs +++ b/Src/AutoMoq/StubPropertiesCommand.cs @@ -26,12 +26,12 @@ public void Execute(object specimen, ISpecimenContext context) var mockDefaultValueSetting = mock.DefaultValue; mock.DefaultValue = DefaultValue.Empty; - //stub properties + // stub properties mock.GetType() .GetMethod("SetupAllProperties") .Invoke(mock, new object[0]); - //restore setting + // restore setting mock.DefaultValue = mockDefaultValueSetting; } } diff --git a/Src/AutoMoqUnitTest/AutoConfiguredMoqCustomizationTest.cs b/Src/AutoMoqUnitTest/AutoConfiguredMoqCustomizationTest.cs index 7090a211f..7bdd5aaff 100644 --- a/Src/AutoMoqUnitTest/AutoConfiguredMoqCustomizationTest.cs +++ b/Src/AutoMoqUnitTest/AutoConfiguredMoqCustomizationTest.cs @@ -61,7 +61,7 @@ public void CustomizeAddsPostprocessorToCustomizations() { // Arrange var customizations = new List(); - var fixture = new Mock {DefaultValue = DefaultValue.Mock}; + var fixture = new Mock { DefaultValue = DefaultValue.Mock }; fixture.Setup(f => f.Customizations) .Returns(customizations); @@ -80,7 +80,7 @@ public void CustomizeAddsMockCommandsToPostprocessor(Type expectedCommandType) { // Arrange var customizations = new List(); - var fixture = new Mock {DefaultValue = DefaultValue.Mock}; + var fixture = new Mock { DefaultValue = DefaultValue.Mock }; fixture.Setup(f => f.Customizations) .Returns(customizations); @@ -88,8 +88,8 @@ public void CustomizeAddsMockCommandsToPostprocessor(Type expectedCommandType) // Act sut.Customize(fixture.Object); // Assert - var postprocessor = (Postprocessor) customizations.Single(builder => builder is Postprocessor); - var compositeCommand = (CompositeSpecimenCommand) postprocessor.Command; + var postprocessor = (Postprocessor)customizations.Single(builder => builder is Postprocessor); + var compositeCommand = (CompositeSpecimenCommand)postprocessor.Command; Assert.Contains(compositeCommand.Commands, command => command.GetType() == expectedCommandType); } @@ -100,7 +100,7 @@ public void CustomizeAddsRelayToResidueCollectors() // Arrange var relay = new Mock(); var collectors = new List(); - var fixture = new Mock {DefaultValue = DefaultValue.Mock}; + var fixture = new Mock { DefaultValue = DefaultValue.Mock }; fixture.Setup(f => f.ResidueCollectors) .Returns(collectors); diff --git a/Src/AutoMoqUnitTest/AutoMockPropertiesCommandTest.cs b/Src/AutoMoqUnitTest/AutoMockPropertiesCommandTest.cs index d4ac1d41a..3daf1c4aa 100644 --- a/Src/AutoMoqUnitTest/AutoMockPropertiesCommandTest.cs +++ b/Src/AutoMoqUnitTest/AutoMockPropertiesCommandTest.cs @@ -10,7 +10,7 @@ namespace AutoFixture.AutoMoq.UnitTest public class AutoMockPropertiesCommandTest { [Theory] - [ClassData(typeof (ValidNonMockSpecimens))] + [ClassData(typeof(ValidNonMockSpecimens))] public void ExecuteDoesNotThrowsWhenSpecimenIsValidNonMockSpecimen(object validNonMockSpecimen) { // Arrange diff --git a/Src/AutoMoqUnitTest/AutoMoqCustomizationTest.cs b/Src/AutoMoqUnitTest/AutoMoqCustomizationTest.cs index 6399cef4e..c4cee7caa 100644 --- a/Src/AutoMoqUnitTest/AutoMoqCustomizationTest.cs +++ b/Src/AutoMoqUnitTest/AutoMoqCustomizationTest.cs @@ -153,8 +153,8 @@ public void WithConfigureMembers_CustomizeAddsMockCommandsToPostprocessor(Type e // Act sut.Customize(fixtureStub); // Assert - var postprocessor = (Postprocessor) fixtureStub.Customizations.Single(builder => builder is Postprocessor); - var compositeCommand = (CompositeSpecimenCommand) postprocessor.Command; + var postprocessor = (Postprocessor)fixtureStub.Customizations.Single(builder => builder is Postprocessor); + var compositeCommand = (CompositeSpecimenCommand)postprocessor.Command; Assert.Contains(compositeCommand.Commands, command => command.GetType() == expectedCommandType); } diff --git a/Src/AutoMoqUnitTest/FixtureIntegrationWithAutoConfiguredMoqCustomizationTest.cs b/Src/AutoMoqUnitTest/FixtureIntegrationWithAutoConfiguredMoqCustomizationTest.cs index 1142d444a..e8d7315c1 100644 --- a/Src/AutoMoqUnitTest/FixtureIntegrationWithAutoConfiguredMoqCustomizationTest.cs +++ b/Src/AutoMoqUnitTest/FixtureIntegrationWithAutoConfiguredMoqCustomizationTest.cs @@ -204,7 +204,7 @@ public void RefMethodsAreIgnored() IInterfaceWithRefMethod result = null; Assert.Null(Record.Exception(() => result = fixture.Create())); - string refResult = ""; + string refResult = string.Empty; string returnValue = result.Method(ref refResult); Assert.NotEqual(frozenString, refResult); Assert.NotEqual(frozenString, returnValue); diff --git a/Src/AutoMoqUnitTest/FixtureIntegrationWithAutoMoqCustomizationTest.cs b/Src/AutoMoqUnitTest/FixtureIntegrationWithAutoMoqCustomizationTest.cs index ef479394a..394895254 100644 --- a/Src/AutoMoqUnitTest/FixtureIntegrationWithAutoMoqCustomizationTest.cs +++ b/Src/AutoMoqUnitTest/FixtureIntegrationWithAutoMoqCustomizationTest.cs @@ -107,7 +107,7 @@ public void FixtureCanCreateUsableMockOfFunc() // Act var actual = mockOfFunc.Object(42); - + // Assert Assert.Equal(expected, actual); } @@ -356,7 +356,7 @@ public void WithConfigureMembers_RefMethodsAreIgnored() IInterfaceWithRefMethod result = null; Assert.Null(Record.Exception(() => result = fixture.Create())); - string refResult = ""; + string refResult = string.Empty; string returnValue = result.Method(ref refResult); Assert.NotEqual(frozenString, refResult); Assert.NotEqual(frozenString, returnValue); @@ -469,7 +469,6 @@ public void WithGenerateDelegates_ReturnsMockForDelegates(Type delegateType) // Act var result = fixture.Create(delegateType, context); // Assert - Assert.Null(Record.Exception(() => AssertIsMock(result, delegateType))); } diff --git a/Src/AutoMoqUnitTest/MockPostprocessorTest.cs b/Src/AutoMoqUnitTest/MockPostprocessorTest.cs index 6e1f51f42..777e4f891 100644 --- a/Src/AutoMoqUnitTest/MockPostprocessorTest.cs +++ b/Src/AutoMoqUnitTest/MockPostprocessorTest.cs @@ -80,12 +80,12 @@ public void CreateMockRequestReturnsCorrectMock() } [Theory] - [ClassData(typeof (ValidNonMockSpecimens))] + [ClassData(typeof(ValidNonMockSpecimens))] public void CreateFromMockRequestWhenDecoratedBuilderReturnsValidNonMockSpecimenReturnsCorrectResult( object validNonMockSpecimen) { // Arrange - var request = typeof (Mock); + var request = typeof(Mock); var context = new Mock().Object; var builderStub = new Mock(); diff --git a/Src/AutoMoqUnitTest/MockRelayTest.cs b/Src/AutoMoqUnitTest/MockRelayTest.cs index f8839793a..c88187893 100644 --- a/Src/AutoMoqUnitTest/MockRelayTest.cs +++ b/Src/AutoMoqUnitTest/MockRelayTest.cs @@ -118,12 +118,12 @@ public void CreateReturnsCorrectResultWhenContextReturnsNonMock() } [Theory] - [ClassData(typeof (ValidNonMockSpecimens))] + [ClassData(typeof(ValidNonMockSpecimens))] public void CreateReturnsCorrectResultWhenContextReturnsValidNonMockSpecimen(object validNonMockSpecimen) { // Arrange - var request = typeof (IInterface); - var mockType = typeof (Mock<>).MakeGenericType(request); + var request = typeof(IInterface); + var mockType = typeof(Mock<>).MakeGenericType(request); var contextStub = new Mock(); contextStub.Setup(ctx => ctx.Resolve(mockType)).Returns(validNonMockSpecimen); diff --git a/Src/AutoMoqUnitTest/MockSealedPropertiesCommandTest.cs b/Src/AutoMoqUnitTest/MockSealedPropertiesCommandTest.cs index c972259a6..a842b2aba 100644 --- a/Src/AutoMoqUnitTest/MockSealedPropertiesCommandTest.cs +++ b/Src/AutoMoqUnitTest/MockSealedPropertiesCommandTest.cs @@ -51,7 +51,6 @@ public void InitializesSealedPropertyUsingContext() [Fact] public void InitializesPublicFields() { - // Arrange var fixture = new Fixture(); var frozenString = fixture.Freeze(); @@ -111,7 +110,7 @@ public void IgnoresPrivateProperties() var fixture = new Fixture(); var frozenString = fixture.Freeze(); var mock = new Mock(); - var privateProperty = typeof (TypeWithPrivateProperty) + var privateProperty = typeof(TypeWithPrivateProperty) .GetProperty("PrivateProperty", BindingFlags.Instance | BindingFlags.NonPublic); diff --git a/Src/AutoMoqUnitTest/MockTypeTest.cs b/Src/AutoMoqUnitTest/MockTypeTest.cs index f92793dc9..8b30ffa83 100644 --- a/Src/AutoMoqUnitTest/MockTypeTest.cs +++ b/Src/AutoMoqUnitTest/MockTypeTest.cs @@ -54,9 +54,9 @@ public void ReturnsUsingFixtureSetsMockUpLazily() // Act setup.ReturnsUsingFixture(fixture.Object); // Assert - fixture.Verify(f => f.Create(typeof (string), It.IsAny()), Times.Never()); + fixture.Verify(f => f.Create(typeof(string), It.IsAny()), Times.Never()); var result = mock.Object.Property; - fixture.Verify(f => f.Create(typeof (string), It.IsAny()), Times.Once()); + fixture.Verify(f => f.Create(typeof(string), It.IsAny()), Times.Once()); } [Fact] @@ -65,7 +65,7 @@ public void ReturnsUsingFixture_SetsMockUpWithNull_WhenContextReturnsNull_AndMem // Arrange var mock = new Mock(); var fixture = new Mock(); - fixture.Setup(f => f.Create(typeof (string), It.IsAny())) + fixture.Setup(f => f.Create(typeof(string), It.IsAny())) .Returns(null as string); // Act mock.Setup(x => x.Property).ReturnsUsingFixture(fixture.Object); @@ -79,7 +79,7 @@ public void ReturnsUsingFixture_SetsMockUpWithNull_WhenContextReturnsNull_AndMem // Arrange var mock = new Mock(); var fixture = new Mock(); - fixture.Setup(f => f.Create(typeof (int?), It.IsAny())) + fixture.Setup(f => f.Create(typeof(int?), It.IsAny())) .Returns(null as int?); // Act mock.Setup(x => x.Property).ReturnsUsingFixture(fixture.Object); @@ -93,7 +93,7 @@ public void ReturnsUsingFixture_Throws_WhenContextReturnsNull_AndMemberIsNonNull // Arrange var mock = new Mock(); var fixture = new Mock(); - fixture.Setup(f => f.Create(typeof (int), It.IsAny())) + fixture.Setup(f => f.Create(typeof(int), It.IsAny())) .Returns(null as object); // Act mock.Setup(x => x.Property).ReturnsUsingFixture(fixture.Object); @@ -104,17 +104,17 @@ public void ReturnsUsingFixture_Throws_WhenContextReturnsNull_AndMemberIsNonNull } [Theory] - [InlineData(typeof (OmitSpecimen))] - [InlineData(typeof (NoSpecimen))] - [InlineData(typeof (object))] - [InlineData(typeof (StringBuilder))] + [InlineData(typeof(OmitSpecimen))] + [InlineData(typeof(NoSpecimen))] + [InlineData(typeof(object))] + [InlineData(typeof(StringBuilder))] public void ReturnsUsingFixture_Throws_WhenContextReturnsUnexpectedSpecimen(Type specimenType) { // Arrange var mock = new Mock(); var specimen = Activator.CreateInstance(specimenType); var fixture = new Mock(); - fixture.Setup(f => f.Create(typeof (string), It.IsAny())) + fixture.Setup(f => f.Create(typeof(string), It.IsAny())) .Returns(specimen); var expectedExceptionMessage = string.Format( diff --git a/Src/AutoMoqUnitTest/MockVirtualMethodsCommandTest.cs b/Src/AutoMoqUnitTest/MockVirtualMethodsCommandTest.cs index f44810d52..715cbc19e 100644 --- a/Src/AutoMoqUnitTest/MockVirtualMethodsCommandTest.cs +++ b/Src/AutoMoqUnitTest/MockVirtualMethodsCommandTest.cs @@ -9,7 +9,7 @@ namespace AutoFixture.AutoMoq.UnitTest public class MockVirtualMethodsCommandTest { [Theory] - [ClassData(typeof (ValidNonMockSpecimens))] + [ClassData(typeof(ValidNonMockSpecimens))] public void ExecuteShouldNotThrowWhenSpecimenIsValidNonMockSpecimen(object validNonMockSpecimen) { // Arrange @@ -353,7 +353,7 @@ public void SetsUpOutParametersWithNullWhenContextReturnsNull() { // Arrange var contextMock = new Mock(); - contextMock.Setup(ctx => ctx.Resolve(typeof (string))) + contextMock.Setup(ctx => ctx.Resolve(typeof(string))) .Returns(null); var mock = new Mock(); @@ -371,7 +371,7 @@ public void DoesNotSetupMethodsWithOutParametersWhenContextReturnsOmitSpecimen() { // Arrange var contextMock = new Mock(); - contextMock.Setup(ctx => ctx.Resolve(typeof (int))) + contextMock.Setup(ctx => ctx.Resolve(typeof(int))) .Returns(new OmitSpecimen()); var mock = new Mock(MockBehavior.Strict); diff --git a/Src/AutoMoqUnitTest/Properties/AssemblyInfo.cs b/Src/AutoMoqUnitTest/Properties/AssemblyInfo.cs index 753fce46a..acac187e7 100644 --- a/Src/AutoMoqUnitTest/Properties/AssemblyInfo.cs +++ b/Src/AutoMoqUnitTest/Properties/AssemblyInfo.cs @@ -1,13 +1,13 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoMoqUnitTest/StubPropertiesCommandTest.cs b/Src/AutoMoqUnitTest/StubPropertiesCommandTest.cs index 2b9f49805..67168d4c1 100644 --- a/Src/AutoMoqUnitTest/StubPropertiesCommandTest.cs +++ b/Src/AutoMoqUnitTest/StubPropertiesCommandTest.cs @@ -9,7 +9,7 @@ namespace AutoFixture.AutoMoq.UnitTest public class StubPropertiesCommandTest { [Theory] - [ClassData(typeof (ValidNonMockSpecimens))] + [ClassData(typeof(ValidNonMockSpecimens))] public void ExecuteDoesNotThrowsWhenSpecimenIsValidNonMockSpecimen(object validNonMockSpecimen) { // Arrange diff --git a/Src/AutoMoqUnitTest/TestTypes/IInterfaceWithNewMethod.cs b/Src/AutoMoqUnitTest/TestTypes/IInterfaceWithNewMethod.cs index 4c41cae7e..20e8c539c 100644 --- a/Src/AutoMoqUnitTest/TestTypes/IInterfaceWithNewMethod.cs +++ b/Src/AutoMoqUnitTest/TestTypes/IInterfaceWithNewMethod.cs @@ -1,14 +1,14 @@ namespace AutoFixture.AutoMoq.UnitTest.TestTypes { - public interface IInterfaceWithShadowedMethod + public interface IInterfaceWithNewMethod : IInterfaceWithShadowedMethod { - //shadowed method - string Method(int i); + // new method + new string Method(int i); } - public interface IInterfaceWithNewMethod : IInterfaceWithShadowedMethod + public interface IInterfaceWithShadowedMethod { - //new method - new string Method(int i); + // shadowed method + string Method(int i); } } diff --git a/Src/AutoMoqUnitTest/TestTypes/TypeWithGetOnlyProperty.cs b/Src/AutoMoqUnitTest/TestTypes/TypeWithGetOnlyProperty.cs index 259dac079..ed4020409 100644 --- a/Src/AutoMoqUnitTest/TestTypes/TypeWithGetOnlyProperty.cs +++ b/Src/AutoMoqUnitTest/TestTypes/TypeWithGetOnlyProperty.cs @@ -4,7 +4,7 @@ public class TypeWithGetOnlyProperty { public string GetOnlyProperty { - get { return ""; } + get { return string.Empty; } } } } diff --git a/Src/AutoMoqUnitTest/TestTypes/TypeWithIndexer.cs b/Src/AutoMoqUnitTest/TestTypes/TypeWithIndexer.cs index 03a79d06f..cc1f65589 100644 --- a/Src/AutoMoqUnitTest/TestTypes/TypeWithIndexer.cs +++ b/Src/AutoMoqUnitTest/TestTypes/TypeWithIndexer.cs @@ -2,7 +2,7 @@ { public class TypeWithIndexer { - private readonly int[] array = new[] {-99, -99, -99}; + private readonly int[] array = new[] { -99, -99, -99 }; public int this[int index] { diff --git a/Src/AutoMoqUnitTest/TestTypes/TypeWithPrivateField.cs b/Src/AutoMoqUnitTest/TestTypes/TypeWithPrivateField.cs index 6612a1240..0672c2ef9 100644 --- a/Src/AutoMoqUnitTest/TestTypes/TypeWithPrivateField.cs +++ b/Src/AutoMoqUnitTest/TestTypes/TypeWithPrivateField.cs @@ -2,7 +2,7 @@ { public class TypeWithPrivateField { - private string field = ""; + private string field = string.Empty; public string GetPrivateField() { diff --git a/Src/AutoMoqUnitTest/TestTypes/TypeWithReadonlyField.cs b/Src/AutoMoqUnitTest/TestTypes/TypeWithReadonlyField.cs index 1a36348ef..360317419 100644 --- a/Src/AutoMoqUnitTest/TestTypes/TypeWithReadonlyField.cs +++ b/Src/AutoMoqUnitTest/TestTypes/TypeWithReadonlyField.cs @@ -2,6 +2,6 @@ { public class TypeWithReadonlyField { - public readonly string ReadonlyField = ""; + public readonly string ReadonlyField = string.Empty; } } diff --git a/Src/AutoMoqUnitTest/TestTypes/TypeWithSealedMembers.cs b/Src/AutoMoqUnitTest/TestTypes/TypeWithSealedMembers.cs index 9bc3aecfb..7b5cc3f08 100644 --- a/Src/AutoMoqUnitTest/TestTypes/TypeWithSealedMembers.cs +++ b/Src/AutoMoqUnitTest/TestTypes/TypeWithSealedMembers.cs @@ -1,11 +1,5 @@ namespace AutoFixture.AutoMoq.UnitTest.TestTypes { - public abstract class TypeWithSealedMembersTemp - { - public abstract string ExplicitlySealedProperty { get; set; } - public abstract string ExplicitlySealedMethod(); - } - public class TypeWithSealedMembers : TypeWithSealedMembersTemp { public sealed override string ExplicitlySealedProperty { get; set; } @@ -21,4 +15,11 @@ public string ImplicitlySealedMethod() return "Awesome string"; } } + + public abstract class TypeWithSealedMembersTemp + { + public abstract string ExplicitlySealedProperty { get; set; } + + public abstract string ExplicitlySealedMethod(); + } } diff --git a/Src/AutoMoqUnitTest/TestTypes/TypeWithStaticField.cs b/Src/AutoMoqUnitTest/TestTypes/TypeWithStaticField.cs index cd8a6bb37..2ab64c3a6 100644 --- a/Src/AutoMoqUnitTest/TestTypes/TypeWithStaticField.cs +++ b/Src/AutoMoqUnitTest/TestTypes/TypeWithStaticField.cs @@ -2,6 +2,6 @@ { public class TypeWithStaticField { - public static string StaticField = ""; + public static string StaticField = string.Empty; } } diff --git a/Src/AutoMoqUnitTest/ValidNonMockSpecimens.cs b/Src/AutoMoqUnitTest/ValidNonMockSpecimens.cs index 09f4bce40..98b7946a1 100644 --- a/Src/AutoMoqUnitTest/ValidNonMockSpecimens.cs +++ b/Src/AutoMoqUnitTest/ValidNonMockSpecimens.cs @@ -8,9 +8,9 @@ internal class ValidNonMockSpecimens : IEnumerable { public IEnumerator GetEnumerator() { - yield return new object[] {new NoSpecimen()}; - yield return new object[] {new OmitSpecimen()}; - yield return new object[] {null}; + yield return new object[] { new NoSpecimen() }; + yield return new object[] { new OmitSpecimen() }; + yield return new object[] { null }; } IEnumerator IEnumerable.GetEnumerator() diff --git a/Src/AutoNSubstitute/AutoNSubstituteCustomization.cs b/Src/AutoNSubstitute/AutoNSubstituteCustomization.cs index a7aeaf7d2..4e65429f4 100644 --- a/Src/AutoNSubstitute/AutoNSubstituteCustomization.cs +++ b/Src/AutoNSubstitute/AutoNSubstituteCustomization.cs @@ -6,7 +6,7 @@ namespace AutoFixture.AutoNSubstitute { /// Enables auto-mocking with NSubstitute. /// - /// NOTICE! You can assign the customization properties to tweak the features you would like to enable. Example: + /// NOTICE! You can assign the customization properties to tweak the features you would like to enable. See example. ///
/// new AutoNSubstituteCustomization { ConfigureMembers = true } ///
diff --git a/Src/AutoNSubstitute/CustomCallHandler/CallResultCache.cs b/Src/AutoNSubstitute/CustomCallHandler/CallResultCache.cs index 79e3c8e9a..fae2363c3 100644 --- a/Src/AutoNSubstitute/CustomCallHandler/CallResultCache.cs +++ b/Src/AutoNSubstitute/CustomCallHandler/CallResultCache.cs @@ -33,6 +33,7 @@ public bool TryGetResult(ICall callInfo, out CallResultData callResult) private class ResultForCallSpec { private readonly ICallSpecification callSpecification; + public CallResultData Result { get; } public ResultForCallSpec(ICallSpecification callSpecification, CallResultData result) diff --git a/Src/AutoNSubstitute/CustomCallHandler/CallResultResolver.cs b/Src/AutoNSubstitute/CustomCallHandler/CallResultResolver.cs index 99bf29a5a..90c451dee 100644 --- a/Src/AutoNSubstitute/CustomCallHandler/CallResultResolver.cs +++ b/Src/AutoNSubstitute/CustomCallHandler/CallResultResolver.cs @@ -30,7 +30,7 @@ static CallResultResolver() public ISpecimenContext SpecimenContext { get; } /// - /// Creates a new instance of + /// Creates a new instance of . /// public CallResultResolver(ISpecimenContext specimenContext) { @@ -43,7 +43,7 @@ public CallResultData ResolveResult(ICall callInfo) var returnValue = this.ResolveReturnValue(callInfo); var returnMaybe = returnValue is OmitSpecimen ? Maybe.Nothing() : Maybe.Just(returnValue); - //Resolve ref/out parameter values. + // Resolve ref/out parameter values. var argumentValues = new List(); var parameterInfos = GetMethodParameters(callInfo); for (var i = 0; i < parameterInfos.Length; i++) diff --git a/Src/AutoNSubstitute/CustomCallHandler/ICallResultCacheFactory.cs b/Src/AutoNSubstitute/CustomCallHandler/ICallResultCacheFactory.cs index 8cc3831b5..20f2ff13d 100644 --- a/Src/AutoNSubstitute/CustomCallHandler/ICallResultCacheFactory.cs +++ b/Src/AutoNSubstitute/CustomCallHandler/ICallResultCacheFactory.cs @@ -1,7 +1,7 @@ namespace AutoFixture.AutoNSubstitute.CustomCallHandler { /// - /// Factory to create an instance of the cache used later to store resolved call results. + /// Factory to create an instance of the cache used later to store resolved call results. /// public interface ICallResultCacheFactory { diff --git a/Src/AutoNSubstitute/Extensions/MethodInfoExtensions.cs b/Src/AutoNSubstitute/Extensions/MethodInfoExtensions.cs index 59082b97b..a063daa41 100644 --- a/Src/AutoNSubstitute/Extensions/MethodInfoExtensions.cs +++ b/Src/AutoNSubstitute/Extensions/MethodInfoExtensions.cs @@ -8,10 +8,10 @@ internal static bool IsOverridable(this MethodInfo method) { /* * From MSDN (http://goo.gl/WvOgYq) - * + * * To determine if a method is overridable, it is not sufficient to check that IsVirtual is true. * For a method to be overridable, IsVirtual must be true and IsFinal must be false. - * + * * For example, interface implementations are marked as "virtual final". * Methods marked with "override sealed" are also marked as "virtual final". */ diff --git a/Src/AutoNSubstitute/GlobalSuppressions.cs b/Src/AutoNSubstitute/GlobalSuppressions.cs index be96c266c..fa7c0b5d6 100644 --- a/Src/AutoNSubstitute/GlobalSuppressions.cs +++ b/Src/AutoNSubstitute/GlobalSuppressions.cs @@ -1,21 +1,21 @@ -// This file is used by Code Analysis to maintain SuppressMessage +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. -// Project-level suppressions either have no target or are given +// Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. // -// To add a suppression to this file, right-click the message in the -// Code Analysis results, point to "Suppress Message", and click +// To add a suppression to this file, right-click the message in the +// Code Analysis results, point to "Suppress Message", and click // "In Suppression File". // You do not need to add suppressions to this file manually. using System.Diagnostics.CodeAnalysis; [assembly: - SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", - Scope = "namespace", Target = "AutoFixture.AutoNSubstitute", + SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", + Scope = "namespace", Target = "AutoFixture.AutoNSubstitute", Justification = "This is the root namespace of the project. There is no other namespace those types could be merged with.")] [assembly: - SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames", + SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames", Justification = "AutoFixture itself currently doesn't have a strong name.")] [assembly: diff --git a/Src/AutoNSubstitute/NSubstituteMethodQuery.cs b/Src/AutoNSubstitute/NSubstituteMethodQuery.cs index dc71916bf..8b4ff9464 100644 --- a/Src/AutoNSubstitute/NSubstituteMethodQuery.cs +++ b/Src/AutoNSubstitute/NSubstituteMethodQuery.cs @@ -47,9 +47,10 @@ public static IMethod Create(Type type) } } - [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", + [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "It's activated via reflection.")] - private class SubstituteMethod : IMethod where T : class + private class SubstituteMethod : IMethod + where T : class { public SubstituteMethod(IEnumerable parameterInfos) { @@ -63,6 +64,5 @@ public object Invoke(IEnumerable parameters) return Substitute.For(parameters.ToArray()); } } - } } diff --git a/Src/AutoNSubstitute/NSubstituteRegisterCallHandlerCommand.cs b/Src/AutoNSubstitute/NSubstituteRegisterCallHandlerCommand.cs index 226174c82..73044b5da 100644 --- a/Src/AutoNSubstitute/NSubstituteRegisterCallHandlerCommand.cs +++ b/Src/AutoNSubstitute/NSubstituteRegisterCallHandlerCommand.cs @@ -21,8 +21,8 @@ namespace AutoFixture.AutoNSubstitute /// Notes: /// - Calling a method more than once with the same parameters will return the same value by default. /// To override that behavior pass a custom instance. - /// - Methods inherited from are not set up due to a limitation in NSubstitute - /// (http://stackoverflow.com/a/21787891) + /// - Methods inherited from are not set up due to a limitation in NSubstitute + /// (http://stackoverflow.com/a/21787891). /// public class NSubstituteRegisterCallHandlerCommand : ISpecimenCommand { @@ -42,7 +42,7 @@ public class NSubstituteRegisterCallHandlerCommand : ISpecimenCommand public ICallResultResolverFactory CallResultResolverFactory { get; } /// - /// Creates a new instance + /// Creates a new instance /// with default and instances. /// public NSubstituteRegisterCallHandlerCommand(ISubstitutionContext substitutionContext) diff --git a/Src/AutoNSubstitute/NSubstituteSealedPropertiesCommand.cs b/Src/AutoNSubstitute/NSubstituteSealedPropertiesCommand.cs index 8a68b2eb1..f6e6dff3b 100644 --- a/Src/AutoNSubstitute/NSubstituteSealedPropertiesCommand.cs +++ b/Src/AutoNSubstitute/NSubstituteSealedPropertiesCommand.cs @@ -48,11 +48,11 @@ public bool IsSatisfiedBy(object request) { switch (request) { - //exclude non-sealed properties + // exclude non-sealed properties case PropertyInfo pi: return pi.GetSetMethod().IsSealed(); - - //exclude interceptor fields + + // exclude interceptor fields case FieldInfo fi: return !IsDynamicProxyMember(fi); } diff --git a/Src/AutoNSubstitute/NSubstituteType.cs b/Src/AutoNSubstitute/NSubstituteType.cs index 80b9ed216..5296eb7c3 100644 --- a/Src/AutoNSubstitute/NSubstituteType.cs +++ b/Src/AutoNSubstitute/NSubstituteType.cs @@ -15,12 +15,12 @@ internal static IEnumerable GetPublicAndProtectedConstructors(t internal static IEnumerable GetSubstituteTypes(this Type type) { - var substitute = Substitute.For(); - var interfaces = substitute.GetType().GetInterfaces(); + var substitute = Substitute.For(); + var interfaces = substitute.GetType().GetInterfaces(); return type.GetInterfaces() .Where(i => !interfaces.Contains(i)) - .Concat(new[] {type.GetTypeInfo().BaseType}); + .Concat(new[] { type.GetTypeInfo().BaseType }); } } } \ No newline at end of file diff --git a/Src/AutoNSubstitute/NSubstituteVirtualMethodsCommand.cs b/Src/AutoNSubstitute/NSubstituteVirtualMethodsCommand.cs index 62b047a04..a5420099a 100644 --- a/Src/AutoNSubstitute/NSubstituteVirtualMethodsCommand.cs +++ b/Src/AutoNSubstitute/NSubstituteVirtualMethodsCommand.cs @@ -15,11 +15,10 @@ namespace AutoFixture.AutoNSubstitute { - /// /// Sets up a substitute object's methods so that the return values will be retrieved from a fixture, /// instead of being created directly by NSubstitute. - /// + /// /// This will setup any non-void virtual methods. /// /// @@ -27,14 +26,14 @@ namespace AutoFixture.AutoNSubstitute /// This includes: /// - interface's methods/property getters; /// - class's abstract/virtual/overridden/non-sealed methods/property getters. - /// + /// /// Notes: - /// - Automatic mocking of generic methods isn't feasible - we'd have to antecipate any type - /// parameters that this method could be called with. + /// - Automatic mocking of generic methods isn't feasible - we'd have to antecipate any type + /// parameters that this method could be called with. /// - Void methods are not set up due to a limitation in NSubstitute that When..Do setups can't be overriden /// - Calling a method more than once with the same parameters will always return the same value - /// - Methods inherited from are not set up due to a limitation in NSubstitute - /// (http://stackoverflow.com/a/21787891) + /// - Methods inherited from are not set up due to a limitation in NSubstitute + /// (http://stackoverflow.com/a/21787891). /// [Obsolete("This class belongs to the legacy integration approach. " + "Use the NSubstituteRegisterCallHandlerCommand class and its dependencies instead.")] @@ -130,10 +129,12 @@ private static string GetTypeArguments(MethodInfo methodInfo) private static string GetFriendlyName(Type type) { if (type.GetTypeInfo().IsGenericType) + { return string.Format(CultureInfo.CurrentCulture, "{0}<{1}>", type.Name.Split('`')[0], string.Join(", ", type.GetGenericArguments().Select(GetFriendlyName))); + } return type.Name; } @@ -171,14 +172,14 @@ public void ReturnsUsingContext(MethodInfo methodInfo) // 3. NoSetupCallbackHandler uses substitute state to check whether we already have result for the call. // That could happen if client already configured return value for particular property/method manually. // Also, that happens if we already configured return value for the call. - // + // // If value is not already present: // 3.1 Resolve result using the AutoFixture. // 3.2 Configure NSubstitute to return that value using the `Returns()` method. - // 3.3 Invoke the method again. The points 1-3 will be repeated, + // 3.3 Invoke the method again. The points 1-3 will be repeated, // but this time the NoSetupCallbackHandler will do nothing - we have a result. // - // + // // Consider the following things during the code analysis: // - Each time consumer invokes property/method, we set our custom route and pass control to it. // We need that to access substitute state and check whether we already have a result for the call. @@ -189,7 +190,6 @@ public void ReturnsUsingContext(MethodInfo methodInfo) // That is because Do() {} callback is executed before known return values are returned. // After our substitute is configured in When-Do, NSubstitute checks whether there is return value for current call. // Return value is, of course, present and it returns that value to the consumer. - this.Substitute .WhenForAnyArgs(_ => this.InvokeMethod(methodInfo)) .Do(callInfo => @@ -200,8 +200,10 @@ public void ReturnsUsingContext(MethodInfo methodInfo) SubstitutionContext.Current.GetCallRouterFor(this.Substitute); callRouter.SetRoute(state => new Route( - new ICallHandler[] { - new NoSetupCallbackHandler(state, () => { + new ICallHandler[] + { + new NoSetupCallbackHandler(state, () => + { var value = this.Resolve(methodInfo.ReturnType); if (value is OmitSpecimen) return; @@ -226,7 +228,6 @@ private object Resolve(Type type) // otherwise, NSubstitute would not be able to set up the methods // that return a circular reference. // See discussion at https://github.com/AutoFixture/AutoFixture/pull/397 - using (var cancelableTokenSource = new CancellationTokenSource()) { var cancelableToken = cancelableTokenSource.Token; @@ -276,8 +277,10 @@ public void Setup(MethodInfo methodInfo) private static void SetRefValues(CallInfo callInfo, IEnumerable>> values) { foreach (var value in values) + { if (!(value.Item2.Value is OmitSpecimen)) callInfo[value.Item1] = value.Item2.Value; + } } private static IEnumerable> GetRefParameters(MethodInfo methodInfo) diff --git a/Src/AutoNSubstitute/Properties/AssemblyInfo.cs b/Src/AutoNSubstitute/Properties/AssemblyInfo.cs index cf27f8073..817ad3d49 100644 --- a/Src/AutoNSubstitute/Properties/AssemblyInfo.cs +++ b/Src/AutoNSubstitute/Properties/AssemblyInfo.cs @@ -2,13 +2,13 @@ using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoNSubstitute/SubstituteAttribute.cs b/Src/AutoNSubstitute/SubstituteAttribute.cs index 598df401d..e584a1fee 100644 --- a/Src/AutoNSubstitute/SubstituteAttribute.cs +++ b/Src/AutoNSubstitute/SubstituteAttribute.cs @@ -3,17 +3,17 @@ namespace AutoFixture.AutoNSubstitute { /// - /// An attribute that can be applied to code elements to indicate they should be auto-generated by creating a + /// An attribute that can be applied to code elements to indicate they should be auto-generated by creating a /// substitute. /// /// - /// When this attribute is applied to a parameter in a data-driven test, such as xUnit's [Theory], - /// the test must also have a test conventions attribute that enables automatic generation of the - /// with the . For xUnit, this is done by deriving + /// When this attribute is applied to a parameter in a data-driven test, such as xUnit's [Theory], + /// the test must also have a test conventions attribute that enables automatic generation of the + /// with the . For xUnit, this is done by deriving /// the test conventions attribute from the AutoDataAttribute supplied by the AutoFixture for xUnit.net. /// [AttributeUsage( - AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field, + AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public sealed class SubstituteAttribute : Attribute { diff --git a/Src/AutoNSubstitute/SubstituteAttributeRelay.cs b/Src/AutoNSubstitute/SubstituteAttributeRelay.cs index 0ef83d0b0..1aa327e71 100644 --- a/Src/AutoNSubstitute/SubstituteAttributeRelay.cs +++ b/Src/AutoNSubstitute/SubstituteAttributeRelay.cs @@ -7,18 +7,18 @@ namespace AutoFixture.AutoNSubstitute { /// - /// Relays a request for a code element marked with the to a - /// of element's type. + /// Relays a request for a code element marked with the to a + /// of element's type. /// public class SubstituteAttributeRelay : ISpecimenBuilder { /// - /// Creates a relayed request based on the applied to a code element and + /// Creates a relayed request based on the applied to a code element and /// resolves it from the given . /// /// /// A specimen resolved from the based on a relayed request. - /// If the code element does not have applied, + /// If the code element does not have applied, /// returns . /// public object Create(object request, ISpecimenContext context) diff --git a/Src/AutoNSubstitute/SubstituteRelay.cs b/Src/AutoNSubstitute/SubstituteRelay.cs index 42e6a78db..77935795a 100644 --- a/Src/AutoNSubstitute/SubstituteRelay.cs +++ b/Src/AutoNSubstitute/SubstituteRelay.cs @@ -10,7 +10,7 @@ namespace AutoFixture.AutoNSubstitute /// Relays a request for an interface or an abstract class to a request for a substitute of that type. /// /// - /// This class serves as a residue collector, catching unanswered requests for an instance of an abstract type and + /// This class serves as a residue collector, catching unanswered requests for an instance of an abstract type and /// converting them to requests for a substitute of that type, dynamically generated by NSubstitute. /// /// @@ -42,7 +42,7 @@ public SubstituteRelay() /// Creates a substitute when request is an abstract type. /// /// - /// An attempt to resolve a substitute from the returned an object that was not + /// An attempt to resolve a substitute from the returned an object that was not /// created by NSubstitute. /// public object Create(object request, ISpecimenContext context) diff --git a/Src/AutoNSubstitute/SubstituteRequest.cs b/Src/AutoNSubstitute/SubstituteRequest.cs index 4e6b11544..6826b7d4f 100644 --- a/Src/AutoNSubstitute/SubstituteRequest.cs +++ b/Src/AutoNSubstitute/SubstituteRequest.cs @@ -7,8 +7,8 @@ namespace AutoFixture.AutoNSubstitute /// /// /// Unlike some other test isolation frameworks which define types that represent the dynamically generated proxies, - /// such as Mock{T} in Moq and Fake{T} in FakeItEasy, NSubstitute does not. This class fills this gap and allows - /// AutoFixture to distinguish an explicit request for a substitute from a request for a regular type. This is + /// such as Mock{T} in Moq and Fake{T} in FakeItEasy, NSubstitute does not. This class fills this gap and allows + /// AutoFixture to distinguish an explicit request for a substitute from a request for a regular type. This is /// necessary to support creation of substitutes for concrete types. /// public class SubstituteRequest diff --git a/Src/AutoNSubstitute/SubstituteRequestHandler.cs b/Src/AutoNSubstitute/SubstituteRequestHandler.cs index 697c30312..09eb9f845 100644 --- a/Src/AutoNSubstitute/SubstituteRequestHandler.cs +++ b/Src/AutoNSubstitute/SubstituteRequestHandler.cs @@ -8,18 +8,18 @@ namespace AutoFixture.AutoNSubstitute /// /// /// This class serves as a fixture customization, responding to explicit substitute requests in the form of the - /// instances. The actual construction of the substitute is delegated to a + /// instances. The actual construction of the substitute is delegated to a /// substitute factory, responsible for invoking an appropriate constructor for the target type with /// automatically generated arguments. /// public class SubstituteRequestHandler : ISpecimenBuilder { /// - /// Initializes a new instance of the class with the specified + /// Initializes a new instance of the class with the specified /// . /// /// - /// An responsible for creating a substitute instance from a requested + /// An responsible for creating a substitute instance from a requested /// . /// public SubstituteRequestHandler(ISpecimenBuilder substituteFactory) @@ -37,7 +37,7 @@ public SubstituteRequestHandler(ISpecimenBuilder substituteFactory) /// Creates a substitute when is an explicit . /// /// - /// A substitute created by the when is a + /// A substitute created by the when is a /// or for all other requests. /// public object Create(object request, ISpecimenContext context) diff --git a/Src/AutoNSubstituteUnitTest/AutoConfiguredFixtureIntegrationTest.cs b/Src/AutoNSubstituteUnitTest/AutoConfiguredFixtureIntegrationTest.cs index 0f380b391..52ecfe735 100644 --- a/Src/AutoNSubstituteUnitTest/AutoConfiguredFixtureIntegrationTest.cs +++ b/Src/AutoNSubstituteUnitTest/AutoConfiguredFixtureIntegrationTest.cs @@ -136,7 +136,7 @@ public void RefMethodsReturnValuesFromFixture() // Act & Assert var result = fixture.Create(); - string refResult = ""; + string refResult = string.Empty; string returnValue = result.Method(ref refResult); Assert.Equal(frozenString, refResult); @@ -701,9 +701,9 @@ public void CachedResultIsMatchedByOtherInterfaceSubstituteForGenerics() /// /// Subsitute clear is used to reset manually configured user returns. /// The values configured by AutoFixture are not being manually-configured. - /// + /// /// If user needs that, it could easily override the auto-generated value using the - /// substitute.Method(...).Returns(...); + /// substitute.Method(...).Returns(...);. /// [Theory] [InlineData(ClearOptions.CallActions)] @@ -729,7 +729,7 @@ public void ShouldNotResetCachedValuesOnSubsituteClear(ClearOptions options) /// /// Current implementation of NSubsitute doesn't call custom handlers for the Received.InOrder() scope (which /// we use for our integration with NSubstitute). That shouldsn't cause any usability issues for users. - /// + /// /// Asserting that behavior via test to get a notification when that behavior changes, so we can make a decision /// whether we need to alter something in AF or not to respect that change. /// @@ -755,22 +755,22 @@ public void IsNotExpectedToReturnValueInReceivedInOrderBlock() private class Issue630_TryingAlwaysSatisfyInlineTaskScheduler : TaskScheduler { - private const int DELAY_MSEC = 100; - private readonly object _syncRoot = new object(); + private const int DelayMSec = 100; + private readonly object syncRoot = new object(); private HashSet Tasks { get; } = new HashSet(); protected override void QueueTask(Task task) { - lock (this._syncRoot) + lock (this.syncRoot) { this.Tasks.Add(task); } ThreadPool.QueueUserWorkItem(delegate { - Thread.Sleep(DELAY_MSEC); + Thread.Sleep(DelayMSec); - //If task cannot be dequeued - it was already executed. + // If task cannot be dequeued - it was already executed. if (this.TryDequeue(task)) { this.TryExecuteTask(task); @@ -780,7 +780,7 @@ protected override void QueueTask(Task task) protected override bool TryDequeue(Task task) { - lock (this._syncRoot) + lock (this.syncRoot) { return this.Tasks.Remove(task); } @@ -788,8 +788,7 @@ protected override bool TryDequeue(Task task) protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued) { - - //If was queued, try to remove from queue before inlining. Ignore otherwise - it's already executed. + // If was queued, try to remove from queue before inlining. Ignore otherwise - it's already executed. if (taskWasPreviouslyQueued && !this.TryDequeue(task)) { return false; @@ -801,9 +800,9 @@ protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQu protected override IEnumerable GetScheduledTasks() { - lock (this._syncRoot) + lock (this.syncRoot) { - //Create copy to ensure that it's not modified during enumeration + // Create copy to ensure that it's not modified during enumeration return this.Tasks.ToArray(); } } @@ -812,8 +811,7 @@ protected override IEnumerable GetScheduledTasks() [Fact] public void Issue630_DontFailIfAllTasksAreInlinedInInlinePhase() { - //Test for the following issue fix: https://github.com/AutoFixture/AutoFixture/issues/630 - + // Test for the following issue fix: https://github.com/AutoFixture/AutoFixture/issues/630 var fixture = new Fixture().Customize(new AutoConfiguredNSubstituteCustomization()); var interfaceSource = fixture.Create(); @@ -823,7 +821,7 @@ public void Issue630_DontFailIfAllTasksAreInlinedInInlinePhase() * Simulate situation when tasks are always inlined on current thread. * To do that we implement our custom scheduler which put some delay before running task. * That gives a chance for task to be inlined. - * + * * Schedulers are propagated to the nested tasks, so we are resolving IInterfaceWithMethod inside the task. * All the tasks created during that resolve will be inlined, if that is possible. */ @@ -832,7 +830,7 @@ public void Issue630_DontFailIfAllTasksAreInlinedInInlinePhase() var instance = task.Result; - //This test should not fail. Assertion is dummy and to specify that we use instance. + // This test should not fail. Assertion is dummy and to specify that we use instance. Assert.NotNull(instance); } @@ -849,7 +847,6 @@ protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQu } protected override IEnumerable GetScheduledTasks() => Enumerable.Empty(); - } [Fact] @@ -857,11 +854,11 @@ public void DontFailIfAllTasksInlinedOnQueueByCurrentScheduler() { var task = new Task(() => { - //arrange + // arrange var fixture = new Fixture().Customize(new AutoConfiguredNSubstituteCustomization()); var interfaceSource = fixture.Create(); - //act & assert not throw + // act & assert not throw var result = interfaceSource.Method(); }); task.Start(new InlineOnQueueTaskScheduler()); @@ -877,11 +874,10 @@ public void Issue653_ResolvesPropertyValueViaPropertyRequest() var subsitute = fixture.Create(); var expected = fixture.Create(); - fixture.Customizations.Insert(0, + fixture.Customizations.Insert(0, new FilteringSpecimenBuilder( new FixedBuilder(expected), - new PropertySpecification(typeof(string), nameof(IInterfaceWithProperty.Property)) - )); + new PropertySpecification(typeof(string), nameof(IInterfaceWithProperty.Property)))); // Act var result = subsitute.Property; @@ -901,7 +897,11 @@ public void Issue707_CanConfigureOutMethodParameters() var result = fixture.Create(); // Act - substitute.Method(parameter, out int dummy).Returns(c => { c[1] = result; return true; }); + substitute.Method(parameter, out int dummy).Returns(c => + { + c[1] = result; + return true; + }); int actualResult; substitute.Method(parameter, out actualResult); @@ -923,15 +923,14 @@ public async Task Issue592_ShouldNotFailForConcurrency(int degreeOfParallelism) var tasks = Enumerable .Range(0, degreeOfParallelism) - .Select(_ => Task.Run - (async () => + .Select(_ => Task.Run( + async () => { await start.WaitAsync(cts.Token).ConfigureAwait(false); substitute.Method(); }, cts.Token)); - // Act start.Release(degreeOfParallelism); await Task.WhenAll(tasks).ConfigureAwait(false); diff --git a/Src/AutoNSubstituteUnitTest/CustomCallHandler/AutoFixtureValuesHandlerTest.cs b/Src/AutoNSubstituteUnitTest/CustomCallHandler/AutoFixtureValuesHandlerTest.cs index 6b792d15e..8b2e34330 100644 --- a/Src/AutoNSubstituteUnitTest/CustomCallHandler/AutoFixtureValuesHandlerTest.cs +++ b/Src/AutoNSubstituteUnitTest/CustomCallHandler/AutoFixtureValuesHandlerTest.cs @@ -90,8 +90,8 @@ public void ShouldReturnValueFromCacheIfPresent() var cachedResult = "cachedResult"; - CallResultData _; - sut.ResultCache.TryGetResult(call, out _) + CallResultData ignored; + sut.ResultCache.TryGetResult(call, out ignored) .Returns(c => { c[1] = new CallResultData(Maybe.Just(cachedResult), @@ -137,12 +137,12 @@ public void ShouldSetRefArgumentValue() var sut = CreateSutWithMockedDependencies(); var target = Substitute.For(); - int _ = 0; - var call = CallHelper.CreateCallMock(() => target.Method(ref _)); + int ignored = 0; + var call = CallHelper.CreateCallMock(() => target.Method(ref ignored)); var callResult = new CallResultData( Maybe.Nothing(), - new[] {new CallResultData.ArgumentValue(0, 42)}); + new[] { new CallResultData.ArgumentValue(0, 42) }); sut.ResultResolver.ResolveResult(call).Returns(callResult); @@ -160,12 +160,12 @@ public void ShouldSetOutArgumentValue() var sut = CreateSutWithMockedDependencies(); var target = Substitute.For(); - int _; - var call = CallHelper.CreateCallMock(() => target.Method(out _)); + int ignored; + var call = CallHelper.CreateCallMock(() => target.Method(out ignored)); var callResult = new CallResultData( Maybe.Nothing(), - new[] {new CallResultData.ArgumentValue(0, 42)}); + new[] { new CallResultData.ArgumentValue(0, 42) }); sut.ResultResolver.ResolveResult(call).Returns(callResult); @@ -176,7 +176,6 @@ public void ShouldSetOutArgumentValue() Assert.Equal(42, call.GetArguments()[0]); } - [Fact] public void ShouldNotUpdateModifiedRefArgument() { @@ -196,7 +195,7 @@ public void ShouldNotUpdateModifiedRefArgument() .Returns( new CallResultData( Maybe.Nothing(), - new[] {new CallResultData.ArgumentValue(0, 84)})); + new[] { new CallResultData.ArgumentValue(0, 84) })); // Act sut.Handle(call); @@ -217,13 +216,12 @@ public void ShouldNotUpdateModifiedOutArgument() var call = CallHelper.CreateCallMock(() => target.Method(out origValue)); call.GetArguments()[0] = 42; - sut.ResultResolver .ResolveResult(call) .Returns( new CallResultData( Maybe.Nothing(), - new[] {new CallResultData.ArgumentValue(0, 84)})); + new[] { new CallResultData.ArgumentValue(0, 84) })); // Act sut.Handle(call); diff --git a/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallHelper.cs b/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallHelper.cs index 3bf130344..f0c2dd0f9 100644 --- a/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallHelper.cs +++ b/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallHelper.cs @@ -11,7 +11,7 @@ public static class CallHelper { public static ICall CreateCallMock(Expression method) { - var methodExpression = (MethodCallExpression) method.Body; + var methodExpression = (MethodCallExpression)method.Body; var args = new List(); foreach (var argExpression in methodExpression.Arguments) { diff --git a/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallResultCacheTest.cs b/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallResultCacheTest.cs index 4a728c62d..218c92433 100644 --- a/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallResultCacheTest.cs +++ b/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallResultCacheTest.cs @@ -86,7 +86,6 @@ public void ShouldCorrectlyHandleConcurrency() int threadsCount = 5; int itemsPerThread = 10; - var dataRows = Enumerable.Range(0, threadsCount * itemsPerThread) .Select(_ => { diff --git a/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallResultResolverTests.cs b/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallResultResolverTest.cs similarity index 97% rename from Src/AutoNSubstituteUnitTest/CustomCallHandler/CallResultResolverTests.cs rename to Src/AutoNSubstituteUnitTest/CustomCallHandler/CallResultResolverTest.cs index 3e495108a..e07ebe2d0 100644 --- a/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallResultResolverTests.cs +++ b/Src/AutoNSubstituteUnitTest/CustomCallHandler/CallResultResolverTest.cs @@ -62,8 +62,8 @@ public void ShouldResolveOutParameterValue() var sut = new CallResultResolver(specimenContext); var target = Substitute.For(); - int _; - var call = CallHelper.CreateCallMock(() => target.Method(null, out _)); + int ignored; + var call = CallHelper.CreateCallMock(() => target.Method(null, out ignored)); specimenContext.Resolve(typeof(int)).Returns(42); @@ -98,7 +98,6 @@ public void ShouldResolveRefParameterValue() Assert.Equal(42, callResult.ArgumentValues.First().Value); } - [Fact] public void ShouldNotReturnValueIfOmitted() { @@ -127,8 +126,8 @@ public void ShouldNotResolveArgumentValueIfOmitted() var target = Substitute.For(); - int _ = 0; - var call = CallHelper.CreateCallMock(() => target.Method(ref _)); + int ignored = 0; + var call = CallHelper.CreateCallMock(() => target.Method(ref ignored)); specimenContext.Resolve(typeof(int)).Returns(new OmitSpecimen()); diff --git a/Src/AutoNSubstituteUnitTest/FixtureIntegrationTest.cs b/Src/AutoNSubstituteUnitTest/FixtureIntegrationTest.cs index 7a94dd177..7fdfa3644 100644 --- a/Src/AutoNSubstituteUnitTest/FixtureIntegrationTest.cs +++ b/Src/AutoNSubstituteUnitTest/FixtureIntegrationTest.cs @@ -256,7 +256,7 @@ public void WithConfigureMembers_RefMethodsReturnValuesFromFixture() // Act & Assert var result = fixture.Create(); - string refResult = ""; + string refResult = string.Empty; string returnValue = result.Method(ref refResult); Assert.Equal(frozenString, refResult); @@ -896,7 +896,7 @@ public void WithConfigureMembers_CachedResultIsMatchedByOtherInterfaceSubstitute /// The values configured by AutoFixture are not being manually-configured. /// /// If user needs that, it could easily override the auto-generated value using the - /// substitute.Method(...).Returns(...); + /// substitute.Method(...).Returns(...);. /// [Theory] [InlineData(ClearOptions.CallActions)] @@ -945,7 +945,7 @@ public void WithConfigureMembers_IsNotExpectedToReturnValueInReceivedInOrderBloc private class Issue630_TryingAlwaysSatisfyInlineTaskScheduler : TaskScheduler { - private const int DELAY_MSEC = 100; + private const int DelayMSec = 100; private readonly object syncRoot = new object(); private HashSet Tasks { get; } = new HashSet(); @@ -958,7 +958,7 @@ protected override void QueueTask(Task task) ThreadPool.QueueUserWorkItem(delegate { - Thread.Sleep(DELAY_MSEC); + Thread.Sleep(DelayMSec); // If task cannot be dequeued - it was already executed. if (this.TryDequeue(task)) @@ -1043,11 +1043,11 @@ public void WithConfigureMembers_DontFailIfAllTasksInlinedOnQueueByCurrentSchedu { var task = new Task(() => { - //arrange + // arrange var fixture = new Fixture().Customize(new AutoNSubstituteCustomization { ConfigureMembers = true }); var interfaceSource = fixture.Create(); - //act & assert not throw + // act & assert not throw var result = interfaceSource.Method(); }); task.Start(new InlineOnQueueTaskScheduler()); @@ -1066,8 +1066,7 @@ public void Issue653_ResolvesPropertyValueViaPropertyRequest() fixture.Customizations.Insert(0, new FilteringSpecimenBuilder( new FixedBuilder(expected), - new PropertySpecification(typeof(string), nameof(IInterfaceWithProperty.Property)) - )); + new PropertySpecification(typeof(string), nameof(IInterfaceWithProperty.Property)))); // Act var result = subsitute.Property; @@ -1120,7 +1119,6 @@ public async Task Issue592_ShouldNotFailForConcurrency(int degreeOfParallelism) }, cts.Token)); - // Act start.Release(degreeOfParallelism); await Task.WhenAll(tasks).ConfigureAwait(false); diff --git a/Src/AutoNSubstituteUnitTest/NSubstituteRegisterCallHandlerCommandTest.cs b/Src/AutoNSubstituteUnitTest/NSubstituteRegisterCallHandlerCommandTest.cs index 4713435e5..ba375be93 100644 --- a/Src/AutoNSubstituteUnitTest/NSubstituteRegisterCallHandlerCommandTest.cs +++ b/Src/AutoNSubstituteUnitTest/NSubstituteRegisterCallHandlerCommandTest.cs @@ -68,7 +68,7 @@ public void ShouldUseValueFromCallResultsCacheFactory() // Assert var handler = - (AutoFixtureValuesHandler) callRouter.RegisteredFactory.Invoke(Substitute.For()); + (AutoFixtureValuesHandler)callRouter.RegisteredFactory.Invoke(Substitute.For()); Assert.Equal(expectedResultsCache, handler.ResultCache); } @@ -96,11 +96,10 @@ public void ShouldUseValueFromCallResultResolverFactory() // Assert var handler = - (AutoFixtureValuesHandler) callRouter.RegisteredFactory.Invoke(Substitute.For()); + (AutoFixtureValuesHandler)callRouter.RegisteredFactory.Invoke(Substitute.For()); Assert.Equal(expectedResultResolver, handler.ResultResolver); } - [Fact] public void ShouldSilentlySkipNotASubstituteSpecimen() { @@ -138,8 +137,8 @@ public void ResultCacheAndCallResultResolverShouldBeSameForEachHandler() var instance2 = callRouter.RegisteredFactory.Invoke(substituteState); // Assert - var handler1 = (AutoFixtureValuesHandler) instance1; - var handler2 = (AutoFixtureValuesHandler) instance2; + var handler1 = (AutoFixtureValuesHandler)instance1; + var handler2 = (AutoFixtureValuesHandler)instance2; Assert.NotSame(handler1, handler2); Assert.Same(handler1.ResultResolver, handler2.ResultResolver); @@ -163,10 +162,10 @@ public void ShouldPassCorrectSpecimenContextToCallResultResolver() sut.Execute(specimen, context); // Act - var handler = (AutoFixtureValuesHandler) callRouter.RegisteredFactory.Invoke(substituteState); + var handler = (AutoFixtureValuesHandler)callRouter.RegisteredFactory.Invoke(substituteState); // Assert - Assert.Equal(context, ((CallResultResolver) handler.ResultResolver).SpecimenContext); + Assert.Equal(context, ((CallResultResolver)handler.ResultResolver).SpecimenContext); } [Fact] @@ -189,13 +188,12 @@ public void ValidCallSpecificationFactoryIsPassedToHandler() sut.Execute(specimen, context); // Act - var handler = (AutoFixtureValuesHandler) callRouter.RegisteredFactory.Invoke(substituteState); + var handler = (AutoFixtureValuesHandler)callRouter.RegisteredFactory.Invoke(substituteState); // Assert Assert.Equal(callSpecFactory, handler.CallSpecificationFactory); } - /// /// It's required to create custom mock, because NSubstitute cannot create fully functional /// mock for the ICallRouter interface - it plays a special role inside NSubstitute. diff --git a/Src/AutoNSubstituteUnitTest/Properties/AssemblyInfo.cs b/Src/AutoNSubstituteUnitTest/Properties/AssemblyInfo.cs index 58c5ba1a6..4ddc543d8 100644 --- a/Src/AutoNSubstituteUnitTest/Properties/AssemblyInfo.cs +++ b/Src/AutoNSubstituteUnitTest/Properties/AssemblyInfo.cs @@ -1,13 +1,13 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoNSubstituteUnitTest/SubstituteRelayTest.cs b/Src/AutoNSubstituteUnitTest/SubstituteRelayTest.cs index 3f4d94068..ba9181c7a 100644 --- a/Src/AutoNSubstituteUnitTest/SubstituteRelayTest.cs +++ b/Src/AutoNSubstituteUnitTest/SubstituteRelayTest.cs @@ -111,7 +111,7 @@ public void CreateThrowsInvalidOperationExceptionWhenResolvedObjectIsNotSubstitu var e = Assert.Throws(() => sut.Create(request, context)); // Assert Assert.Contains(request.FullName, e.Message); - Assert.Contains(typeof(SubstituteRequestHandler).FullName, e.Message); + Assert.Contains(typeof(SubstituteRequestHandler).FullName, e.Message); Assert.IsType(e.InnerException); } diff --git a/Src/AutoNSubstituteUnitTest/SubstituteRequestHandlerTest.cs b/Src/AutoNSubstituteUnitTest/SubstituteRequestHandlerTest.cs index 49f8a30d4..f1de98003 100644 --- a/Src/AutoNSubstituteUnitTest/SubstituteRequestHandlerTest.cs +++ b/Src/AutoNSubstituteUnitTest/SubstituteRequestHandlerTest.cs @@ -59,7 +59,7 @@ public void CreatePassesRequestedSubstituteTypeAndSpecimenContextToSubstituteCon // Arrange var context = Substitute.For(); Type targetType = typeof(IComparable); - var constructedSubstute = Substitute.For(new[] { targetType}, new object[0]); + var constructedSubstute = Substitute.For(new[] { targetType }, new object[0]); var constructor = Substitute.For(); constructor.Create(targetType, context).Returns(constructedSubstute); var sut = new SubstituteRequestHandler(constructor); diff --git a/Src/AutoNSubstituteUnitTest/TestTypes/IDerivedFromEnumerableInterface.cs b/Src/AutoNSubstituteUnitTest/TestTypes/IDerivedFromEnumerableInterface.cs index 41056a413..3d3f68548 100644 --- a/Src/AutoNSubstituteUnitTest/TestTypes/IDerivedFromEnumerableInterface.cs +++ b/Src/AutoNSubstituteUnitTest/TestTypes/IDerivedFromEnumerableInterface.cs @@ -2,7 +2,7 @@ namespace AutoFixture.AutoNSubstitute.UnitTest.TestTypes { - public interface IDerivedFromEnumerableInterface: IEnumerable + public interface IDerivedFromEnumerableInterface : IEnumerable { } } \ No newline at end of file diff --git a/Src/AutoNSubstituteUnitTest/TestTypes/IDerivedInterfaceWithOwnMethod.cs b/Src/AutoNSubstituteUnitTest/TestTypes/IDerivedInterfaceWithOwnMethod.cs index 3612b4472..86b56525d 100644 --- a/Src/AutoNSubstituteUnitTest/TestTypes/IDerivedInterfaceWithOwnMethod.cs +++ b/Src/AutoNSubstituteUnitTest/TestTypes/IDerivedInterfaceWithOwnMethod.cs @@ -1,6 +1,6 @@ namespace AutoFixture.AutoNSubstitute.UnitTest.TestTypes { - public interface IDerivedInterfaceWithOwnMethod: IInterfaceWithParameterVoidMethod + public interface IDerivedInterfaceWithOwnMethod : IInterfaceWithParameterVoidMethod { int IntMethod(); } diff --git a/Src/AutoNSubstituteUnitTest/TestTypes/IInterfaceWithNewMethod.cs b/Src/AutoNSubstituteUnitTest/TestTypes/IInterfaceWithNewMethod.cs index e1d533119..4496bf91c 100644 --- a/Src/AutoNSubstituteUnitTest/TestTypes/IInterfaceWithNewMethod.cs +++ b/Src/AutoNSubstituteUnitTest/TestTypes/IInterfaceWithNewMethod.cs @@ -2,7 +2,7 @@ { public interface IInterfaceWithNewMethod : IInterfaceWithShadowedMethod { - //new method + // new method new string Method(int i); } } diff --git a/Src/AutoNSubstituteUnitTest/TestTypes/IInterfaceWithShadowedMethod.cs b/Src/AutoNSubstituteUnitTest/TestTypes/IInterfaceWithShadowedMethod.cs index 7eb298289..68f7a658c 100644 --- a/Src/AutoNSubstituteUnitTest/TestTypes/IInterfaceWithShadowedMethod.cs +++ b/Src/AutoNSubstituteUnitTest/TestTypes/IInterfaceWithShadowedMethod.cs @@ -2,7 +2,7 @@ { public interface IInterfaceWithShadowedMethod { - //shadowed method + // shadowed method string Method(int i); } } \ No newline at end of file diff --git a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithGetOnlyProperty.cs b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithGetOnlyProperty.cs index 415b7e088..12cd913f0 100644 --- a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithGetOnlyProperty.cs +++ b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithGetOnlyProperty.cs @@ -4,7 +4,7 @@ public abstract class TypeWithGetOnlyProperty { public string GetOnlyProperty { - get { return ""; } + get { return string.Empty; } } } } diff --git a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithIndexer.cs b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithIndexer.cs index 96bd2aa21..c1206e067 100644 --- a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithIndexer.cs +++ b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithIndexer.cs @@ -2,7 +2,7 @@ { public abstract class TypeWithIndexer { - private readonly int[] array = new[] {-99, -99, -99}; + private readonly int[] array = new[] { -99, -99, -99 }; public int this[int index] { diff --git a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithPrivateField.cs b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithPrivateField.cs index 7a7c4bad6..831ec0c6a 100644 --- a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithPrivateField.cs +++ b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithPrivateField.cs @@ -2,7 +2,7 @@ { public abstract class TypeWithPrivateField { - private string field = ""; + private string field = string.Empty; public string GetPrivateField() { diff --git a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithReadonlyField.cs b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithReadonlyField.cs index 9bc697a3f..567581374 100644 --- a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithReadonlyField.cs +++ b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithReadonlyField.cs @@ -2,6 +2,6 @@ { public abstract class TypeWithReadonlyField { - public readonly string ReadonlyField = ""; + public readonly string ReadonlyField = string.Empty; } } diff --git a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithSealedMembers.cs b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithSealedMembers.cs index 487e8dfc3..d3d3821a5 100644 --- a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithSealedMembers.cs +++ b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithSealedMembers.cs @@ -1,15 +1,5 @@ namespace AutoFixture.AutoNSubstitute.UnitTest.TestTypes { - public abstract class TypeWithSealedMembersTemp - { - public abstract string ExplicitlySealedProperty { get; set; } - public abstract string ExplicitlySealedMethod(); - } - - public class ConcreteTypeWithSealedMembers : TypeWithSealedMembers - { - } - public abstract class TypeWithSealedMembers : TypeWithSealedMembersTemp { public override sealed string ExplicitlySealedProperty { get; set; } @@ -25,4 +15,15 @@ public string ImplicitlySealedMethod() return "Awesome string"; } } + + public abstract class TypeWithSealedMembersTemp + { + public abstract string ExplicitlySealedProperty { get; set; } + + public abstract string ExplicitlySealedMethod(); + } + + public class ConcreteTypeWithSealedMembers : TypeWithSealedMembers + { + } } diff --git a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithStaticField.cs b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithStaticField.cs index 02e8e92f7..0dd166e63 100644 --- a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithStaticField.cs +++ b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithStaticField.cs @@ -2,6 +2,6 @@ { public abstract class TypeWithStaticField { - public static string StaticField = ""; + public static string StaticField = string.Empty; } } diff --git a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithVirtualMembers.cs b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithVirtualMembers.cs index 5fd6c8599..81a416579 100644 --- a/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithVirtualMembers.cs +++ b/Src/AutoNSubstituteUnitTest/TestTypes/TypeWithVirtualMembers.cs @@ -1,9 +1,5 @@ namespace AutoFixture.AutoNSubstitute.UnitTest.TestTypes { - public class ConcreteTypeWithVirtualMembers : TypeWithVirtualMembers - { - } - public abstract class TypeWithVirtualMembers { public virtual string VirtualProperty { get; set; } @@ -13,4 +9,8 @@ public virtual string VirtualMethod() return "Awesome string"; } } + + public class ConcreteTypeWithVirtualMembers : TypeWithVirtualMembers + { + } } diff --git a/Src/AutoRhinoMock/GlobalSuppressions.cs b/Src/AutoRhinoMock/GlobalSuppressions.cs index b98fc6099..a669f7cd2 100644 --- a/Src/AutoRhinoMock/GlobalSuppressions.cs +++ b/Src/AutoRhinoMock/GlobalSuppressions.cs @@ -1,13 +1,13 @@ -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. -// Project-level suppressions either have no target or are given -// a specific target and scoped to a namespace, type, member, etc. +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. // -// To add a suppression to this file, right-click the message in the -// Error List, point to "Suppress Message(s)", and click -// "In Project Suppression File". -// You do not need to add suppressions to this file manually. +// To add a suppression to this file, right-click the message in the +// Error List, point to "Suppress Message(s)", and click +// "In Project Suppression File". +// You do not need to add suppressions to this file manually. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", - Scope = "namespace", Target = "AutoFixture.AutoRhinoMock", +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", + Scope = "namespace", Target = "AutoFixture.AutoRhinoMock", Justification = "False positive. There's only one namespace in this assembly.")] diff --git a/Src/AutoRhinoMock/Properties/AssemblyInfo.cs b/Src/AutoRhinoMock/Properties/AssemblyInfo.cs index 85619533c..3819459a1 100644 --- a/Src/AutoRhinoMock/Properties/AssemblyInfo.cs +++ b/Src/AutoRhinoMock/Properties/AssemblyInfo.cs @@ -1,15 +1,15 @@ using System; using System.Reflection; -using System.Runtime.InteropServices; using System.Resources; +using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoRhinoMockUnitTest/FixtureIntegrationTest.cs b/Src/AutoRhinoMockUnitTest/FixtureIntegrationTest.cs index 6005ab443..35a3ba039 100644 --- a/Src/AutoRhinoMockUnitTest/FixtureIntegrationTest.cs +++ b/Src/AutoRhinoMockUnitTest/FixtureIntegrationTest.cs @@ -18,7 +18,7 @@ public void FixtureDoesNotMockConcreteType() // Act var result = fixture.Create(); // Assert - Assert.Throws( () => result.GetMockRepository()); + Assert.Throws(() => result.GetMockRepository()); } [Fact] @@ -200,7 +200,6 @@ public void FixtureCanCreateList() var result = fixture.Create>(); // Assert Assert.True(result.Any()); - } [Fact] diff --git a/Src/AutoRhinoMockUnitTest/Properties/AssemblyInfo.cs b/Src/AutoRhinoMockUnitTest/Properties/AssemblyInfo.cs index 00970471f..e11907128 100644 --- a/Src/AutoRhinoMockUnitTest/Properties/AssemblyInfo.cs +++ b/Src/AutoRhinoMockUnitTest/Properties/AssemblyInfo.cs @@ -2,13 +2,13 @@ using System.Runtime.InteropServices; using Xunit; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/AutoRhinoMockUnitTest/RhinoMockConstructorMethodTest.cs b/Src/AutoRhinoMockUnitTest/RhinoMockConstructorMethodTest.cs index c1aa9cfc1..bf5de67ab 100644 --- a/Src/AutoRhinoMockUnitTest/RhinoMockConstructorMethodTest.cs +++ b/Src/AutoRhinoMockUnitTest/RhinoMockConstructorMethodTest.cs @@ -23,7 +23,7 @@ public void SutImplementsISpecimenBuilder() public void ConstructorWithNullConstructorMethodThrows() { // Act & Assert - Assert.Throws(() => + Assert.Throws(() => new RhinoMockConstructorMethod(null, Enumerable.Empty().ToArray())); } diff --git a/Src/AutoRhinoMockUnitTest/RhinoMockTestTypes.cs b/Src/AutoRhinoMockUnitTest/RhinoMockTestTypes.cs index a1ff557c9..215c8bbde 100644 --- a/Src/AutoRhinoMockUnitTest/RhinoMockTestTypes.cs +++ b/Src/AutoRhinoMockUnitTest/RhinoMockTestTypes.cs @@ -11,32 +11,27 @@ protected AnotherAbstractTypeWithNonDefaultConstructor(T value) this.value = value; } } - + public sealed class ConcreteGenericType { - private readonly T value; - public ConcreteGenericType(T value) { - this.value = value; + this.Value = value; } - public T Value { get { return this.value; } } + public T Value { get; } } public sealed class ConcreteDoublyGenericType { - private readonly T1 value1; - private readonly T2 value2; - public ConcreteDoublyGenericType(T1 value1, T2 value2) { - this.value1 = value1; - this.value2 = value2; + this.Value1 = value1; + this.Value2 = value2; } - public T1 Value1 { get { return this.value1; } } - public T2 Value2 { get { return this.value2; } } + public T1 Value1 { get; } + public T2 Value2 { get; } } } } \ No newline at end of file diff --git a/Src/CodeAnalysis.AutoFixture.ruleset b/Src/CodeAnalysis.AutoFixture.ruleset new file mode 100644 index 000000000..83b97bf75 --- /dev/null +++ b/Src/CodeAnalysis.AutoFixture.ruleset @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Src/CodeAnalysis.Empty.ruleset b/Src/CodeAnalysis.Empty.ruleset new file mode 100644 index 000000000..e7f77cafc --- /dev/null +++ b/Src/CodeAnalysis.Empty.ruleset @@ -0,0 +1,844 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Src/Empty.ruleset b/Src/CodeAnalysis.Test.ruleset similarity index 96% rename from Src/Empty.ruleset rename to Src/CodeAnalysis.Test.ruleset index a08e329ea..18e040c68 100644 --- a/Src/Empty.ruleset +++ b/Src/CodeAnalysis.Test.ruleset @@ -1,6 +1,6 @@ - + - + @@ -139,7 +139,7 @@ - + @@ -598,4 +598,12 @@ - \ No newline at end of file + + + + + + + + + diff --git a/Src/Common.Test.props b/Src/Common.Test.props index 0e6d97f50..d38828713 100644 --- a/Src/Common.Test.props +++ b/Src/Common.Test.props @@ -7,7 +7,7 @@ true false - $(MSBuildThisFileDirectory)\Empty.ruleset + $(MSBuildThisFileDirectory)\CodeAnalysis.Test.ruleset false diff --git a/Src/Common.props b/Src/Common.props index b2fb49893..2cbe830eb 100644 --- a/Src/Common.props +++ b/Src/Common.props @@ -7,7 +7,7 @@ false en-US - $(MSBuildThisFileDirectory)\AutoFixture.ruleset + $(MSBuildThisFileDirectory)\CodeAnalysis.Empty.ruleset IOperation True @@ -59,12 +59,14 @@ true true true + $(MSBuildThisFileDirectory)\CodeAnalysis.AutoFixture.ruleset + diff --git a/Src/Idioms/CompositeIdiomaticAssertion.cs b/Src/Idioms/CompositeIdiomaticAssertion.cs index 4614b2101..f0c4ccc38 100644 --- a/Src/Idioms/CompositeIdiomaticAssertion.cs +++ b/Src/Idioms/CompositeIdiomaticAssertion.cs @@ -99,7 +99,7 @@ public void Verify(Assembly assembly) assertion.Verify(assembly); } } - + /// /// Verifies the behaviour of the types by delegating the implementation to /// all . @@ -276,7 +276,7 @@ public void Verify(params PropertyInfo[] propertyInfos) /// The field whose behavior must be verified. public void Verify(FieldInfo fieldInfo) { - foreach(var assertion in this.Assertions) + foreach (var assertion in this.Assertions) { assertion.Verify(fieldInfo); } diff --git a/Src/Idioms/ConstructorInitializedMemberAssertion.cs b/Src/Idioms/ConstructorInitializedMemberAssertion.cs index 5cd64d522..ec375adb0 100644 --- a/Src/Idioms/ConstructorInitializedMemberAssertion.cs +++ b/Src/Idioms/ConstructorInitializedMemberAssertion.cs @@ -24,8 +24,8 @@ public class ConstructorInitializedMemberAssertion : IdiomaticAssertion /// such as the owner of the property, as well as the value to be assigned and read from /// the member. /// - /// An instance, which is used - /// to determine if each member has the same value which was passed to the matching + /// An instance, which is used + /// to determine if each member has the same value which was passed to the matching /// constructor parameter. /// /// Provides a way to customize the way parameters @@ -141,7 +141,7 @@ public override void Verify(ConstructorInfo constructorInfo) /// reads from the field. The assertion passes if the value read from the property is the same as /// the value passed to the constructor. If more than one constructor has an argument with the /// same name and type, all constructors are checked. If any constructor (with a matching argument) - /// does not initialise the property with the correct value, a + /// does not initialise the property with the correct value, a /// is thrown. /// /// @@ -194,7 +194,7 @@ public override void Verify(PropertyInfo propertyInfo) /// reads from the field. The assertion passes if the value read from the field is the same as /// the value passed to the constructor. If more than one constructor has an argument with the /// same name and type, all constructors are checked. If any constructor does not initialise - /// the field with the correct value, a + /// the field with the correct value, a /// is thrown. /// /// @@ -237,7 +237,7 @@ private static bool CouldLeadToFalsePositive(Type type) { if (type.IsEnum) { - //Check for a default value only enum + // Check for a default value only enum var values = Enum.GetValues(type); return values.Length == 1 && values.GetValue(0).Equals(Activator.CreateInstance(type)); } @@ -332,6 +332,7 @@ public ExpectedAndActual(object expected, object actual) } public object Expected { get; } + public object Actual { get; } } diff --git a/Src/Idioms/ConstructorInitializedMemberException.cs b/Src/Idioms/ConstructorInitializedMemberException.cs index bda4afe6c..2bae7117a 100644 --- a/Src/Idioms/ConstructorInitializedMemberException.cs +++ b/Src/Idioms/ConstructorInitializedMemberException.cs @@ -16,7 +16,7 @@ public class ConstructorInitializedMemberException : Exception { [NonSerialized] private readonly MemberInfo memberInfo; - + [NonSerialized] private readonly ParameterInfo missingParameter; diff --git a/Src/Idioms/CopyAndUpdateAssertion.cs b/Src/Idioms/CopyAndUpdateAssertion.cs index bebb86dfe..6efafa70b 100644 --- a/Src/Idioms/CopyAndUpdateAssertion.cs +++ b/Src/Idioms/CopyAndUpdateAssertion.cs @@ -38,7 +38,7 @@ public class CopyAndUpdateAssertion : IdiomaticAssertion /// A composer which can create instances required to implement the idiomatic unit test. /// /// A comparer that compares public member values from the - /// specimen with public member values from the 'copied' and updated' instance + /// specimen with public member values from the 'copied' and updated' instance. /// Allows customizing the way 'updated' parameters /// are matched to members. The boolean value returned from /// indicates if the parameter and member @@ -66,7 +66,7 @@ public class CopyAndUpdateAssertion : IdiomaticAssertion /// A composer which can create instances required to implement the idiomatic unit test. /// /// A comparer that compares public member values from the - /// specimen with public member values from the 'copied' and updated' instance + /// specimen with public member values from the 'copied' and updated' instance. /// /// /// will typically be a instance. @@ -78,7 +78,7 @@ public class CopyAndUpdateAssertion : IdiomaticAssertion : this(builder, comparer, new DefaultParameterMemberMatcher()) { } - + /// /// Initializes a new instance of the class. /// @@ -108,22 +108,22 @@ public class CopyAndUpdateAssertion : IdiomaticAssertion public IEqualityComparer Comparer { get; } /// - /// Gets the comparer instance which is used to determine if a 'copy and update' method + /// Gets the comparer instance which is used to determine if a 'copy and update' method /// parameter matches a given public member (property or field). /// /// /// If the parameter and member are matched, the member is expected to be initialized /// from the value given to the parameter. A return value of from - /// the method means the parameter and + /// the method means the parameter and /// member are 'matched'. /// public IEqualityComparer ParameterMemberMatcher { get; } /// - /// Verifies that a method correctly makes a copy of an object while changing + /// Verifies that a method correctly makes a copy of an object while changing /// one or more public properties or fields. /// - /// The 'copy and update' method to verify + /// The 'copy and update' method to verify. public override void Verify(MethodInfo methodInfo) { if (methodInfo == null) throw new ArgumentNullException(nameof(methodInfo)); @@ -232,7 +232,7 @@ private bool AreMemberValuesEqual(object specimen, object copiedAndUpdatedSpecim } else { - var fieldInfo = (FieldInfo) member; + var fieldInfo = (FieldInfo)member; specimenMemberValue = fieldInfo.GetValue(specimen); copiedAndUpdatedMemberValue = fieldInfo.GetValue(copiedAndUpdatedSpecimen); } diff --git a/Src/Idioms/EmptyGuidBehaviorExpectation.cs b/Src/Idioms/EmptyGuidBehaviorExpectation.cs index 2a9022cf9..da175d496 100644 --- a/Src/Idioms/EmptyGuidBehaviorExpectation.cs +++ b/Src/Idioms/EmptyGuidBehaviorExpectation.cs @@ -26,7 +26,7 @@ public class EmptyGuidBehaviorExpectation : IBehaviorExpectation public void Verify(IGuardClauseCommand command) { if (command == null) throw new ArgumentNullException(nameof(command)); - + if (command.RequestedType != typeof(Guid)) return; diff --git a/Src/Idioms/EqualsNewObjectAssertion.cs b/Src/Idioms/EqualsNewObjectAssertion.cs index 8ebe7bda9..b42b9667e 100644 --- a/Src/Idioms/EqualsNewObjectAssertion.cs +++ b/Src/Idioms/EqualsNewObjectAssertion.cs @@ -36,11 +36,11 @@ public EqualsNewObjectAssertion(ISpecimenBuilder builder) public ISpecimenBuilder Builder { get; } /// - /// Verifies that calling `x.Equals(new object())` on an instance of the type - /// returns false, if the supplied method is an override of the + /// Verifies that calling `x.Equals(new object())` on an instance of the type + /// returns false, if the supplied method is an override of the /// . /// - /// The method to verify + /// The method to verify. public override void Verify(MethodInfo methodInfo) { if (methodInfo == null) throw new ArgumentNullException(nameof(methodInfo)); diff --git a/Src/Idioms/EqualsNullAssertion.cs b/Src/Idioms/EqualsNullAssertion.cs index ef3f0d054..85a55fefa 100644 --- a/Src/Idioms/EqualsNullAssertion.cs +++ b/Src/Idioms/EqualsNullAssertion.cs @@ -39,12 +39,12 @@ public EqualsNullAssertion(ISpecimenBuilder builder) /// Verifies that calling `x.Equals(null)` on the method returns false, if the supplied /// method is an override of the . /// - /// The Equals method to verify + /// The Equals method to verify. public override void Verify(MethodInfo methodInfo) { if (methodInfo == null) throw new ArgumentNullException(nameof(methodInfo)); - if (methodInfo.ReflectedType == null || + if (methodInfo.ReflectedType == null || !methodInfo.IsObjectEqualsOverrideMethod()) { // The method is not an override of the Object.Equals(object) method @@ -61,7 +61,5 @@ public override void Verify(MethodInfo methodInfo) methodInfo.DeclaringType.FullName)); } } - } - } diff --git a/Src/Idioms/EqualsOverrideException.cs b/Src/Idioms/EqualsOverrideException.cs index eea8151c6..65730728e 100644 --- a/Src/Idioms/EqualsOverrideException.cs +++ b/Src/Idioms/EqualsOverrideException.cs @@ -4,7 +4,7 @@ namespace AutoFixture.Idioms { /// - /// Represents an error about an ill-behaved override of the + /// Represents an error about an ill-behaved override of the /// method. /// [Serializable] diff --git a/Src/Idioms/EqualsSelfAssertion.cs b/Src/Idioms/EqualsSelfAssertion.cs index 6550be616..ecc326c8a 100644 --- a/Src/Idioms/EqualsSelfAssertion.cs +++ b/Src/Idioms/EqualsSelfAssertion.cs @@ -39,7 +39,7 @@ public EqualsSelfAssertion(ISpecimenBuilder builder) /// Verifies that `calling `x.Equals(x)' on an instance of the type returns true /// if the supplied method is an override of the . /// - /// The method to verify + /// The method to verify. public override void Verify(MethodInfo methodInfo) { if (methodInfo == null) throw new ArgumentNullException(nameof(methodInfo)); @@ -61,6 +61,5 @@ public override void Verify(MethodInfo methodInfo) methodInfo.ReflectedType.FullName)); } } - } } diff --git a/Src/Idioms/EqualsSuccessiveAssertion.cs b/Src/Idioms/EqualsSuccessiveAssertion.cs index fbbee9d2f..4581cc60f 100644 --- a/Src/Idioms/EqualsSuccessiveAssertion.cs +++ b/Src/Idioms/EqualsSuccessiveAssertion.cs @@ -38,10 +38,10 @@ public EqualsSuccessiveAssertion(ISpecimenBuilder builder) /// /// Verifies that `x.Equals(y)` 3 times on an instance of the type returns same - /// value, if the supplied method is an override of the + /// value, if the supplied method is an override of the /// . /// - /// The method to verify + /// The method to verify. public override void Verify(MethodInfo methodInfo) { if (methodInfo == null) throw new ArgumentNullException(nameof(methodInfo)); diff --git a/Src/Idioms/GetHashCodeOverrideException.cs b/Src/Idioms/GetHashCodeOverrideException.cs index 9c0948935..d438c582b 100644 --- a/Src/Idioms/GetHashCodeOverrideException.cs +++ b/Src/Idioms/GetHashCodeOverrideException.cs @@ -4,7 +4,7 @@ namespace AutoFixture.Idioms { /// - /// Represents an error about an ill-behaved override of the + /// Represents an error about an ill-behaved override of the /// method. /// [Serializable] diff --git a/Src/Idioms/GetHashCodeSuccessiveAssertion.cs b/Src/Idioms/GetHashCodeSuccessiveAssertion.cs index 3dceacb16..b6eff5e8a 100644 --- a/Src/Idioms/GetHashCodeSuccessiveAssertion.cs +++ b/Src/Idioms/GetHashCodeSuccessiveAssertion.cs @@ -38,13 +38,13 @@ public GetHashCodeSuccessiveAssertion(ISpecimenBuilder builder) public ISpecimenBuilder Builder { get; } /// - /// Verifies that `x.GetHashCode()` 3 times on the same instance of the type returns - /// the same value, if the supplied method is an override of the + /// Verifies that `x.GetHashCode()` 3 times on the same instance of the type returns + /// the same value, if the supplied method is an override of the /// . /// - /// The method to verify - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", - MessageId = "GetHashCode", + /// The method to verify. + [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", + MessageId = "GetHashCode", Justification = "Workaround for a bug in CA: https://connect.microsoft.com/VisualStudio/feedback/details/521030/")] public override void Verify(MethodInfo methodInfo) { @@ -71,6 +71,5 @@ public override void Verify(MethodInfo methodInfo) methodInfo.ReflectedType.FullName)); } } - } } \ No newline at end of file diff --git a/Src/Idioms/GuardClauseAssertion.cs b/Src/Idioms/GuardClauseAssertion.cs index 334049abb..e638bb372 100644 --- a/Src/Idioms/GuardClauseAssertion.cs +++ b/Src/Idioms/GuardClauseAssertion.cs @@ -171,7 +171,7 @@ private static bool IsNonDeferredEnumerable(Type t) return t.IsArray || nonGenericCollectionTypes.Any(gt => gt.IsAssignableFrom(t)) || - (isGeneric && (genericCollectionTypeGtds.Any(gtd => gtdInterfaces.Contains(gtd)))); + (isGeneric && genericCollectionTypeGtds.Any(gtd => gtdInterfaces.Contains(gtd))); } /// diff --git a/Src/Idioms/IdiomaticAssertion.cs b/Src/Idioms/IdiomaticAssertion.cs index 638a48fb4..4c8579927 100644 --- a/Src/Idioms/IdiomaticAssertion.cs +++ b/Src/Idioms/IdiomaticAssertion.cs @@ -285,8 +285,8 @@ public virtual void Verify(PropertyInfo propertyInfo) private static IEnumerable GetMethodsForAssertion(Type type) { - return IsStaticClass(type) - ? GetMethodsExceptPropertyAccessors(type).Where(m => m.IsStatic) + return IsStaticClass(type) + ? GetMethodsExceptPropertyAccessors(type).Where(m => m.IsStatic) : GetMethodsExceptPropertyAccessors(type); } diff --git a/Src/Idioms/IndexedReplacement.cs b/Src/Idioms/IndexedReplacement.cs index d841f8ebd..670ffd172 100644 --- a/Src/Idioms/IndexedReplacement.cs +++ b/Src/Idioms/IndexedReplacement.cs @@ -46,7 +46,7 @@ public IndexedReplacement(int replacementIndex, params T[] source) /// the new value. The index is zero-based. /// /// - /// + /// public IndexedReplacement(int replacementIndex, IEnumerable source) : this(replacementIndex, source.ToArray()) { diff --git a/Src/Idioms/MethodInfoExtensions.cs b/Src/Idioms/MethodInfoExtensions.cs index bcde2da6f..7e7bf0d01 100644 --- a/Src/Idioms/MethodInfoExtensions.cs +++ b/Src/Idioms/MethodInfoExtensions.cs @@ -35,7 +35,7 @@ internal static bool IsGetType(this MethodInfo method) /// /// Gets a value that indicates if the method is the - /// method declared on the type. + /// method declared on the type. /// internal static bool IsObjectEqualsMethod(this MethodInfo method) { @@ -44,7 +44,7 @@ internal static bool IsObjectEqualsMethod(this MethodInfo method) /// /// Gets a value that indicates if the method is the - /// method declared on the type. + /// method declared on the type. /// internal static bool IsObjectGetHashCodeMethod(this MethodInfo method) { diff --git a/Src/Idioms/NameAndType.cs b/Src/Idioms/NameAndType.cs index c87195b45..e502a209e 100644 --- a/Src/Idioms/NameAndType.cs +++ b/Src/Idioms/NameAndType.cs @@ -9,7 +9,7 @@ namespace AutoFixture.Idioms internal class NameAndType { public string Name { get; } - + [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721:Property names should not match get methods", Justification = "It's fine to have the 'Type' property and we cannot re-use the GetType() method intead.")] public Type Type { get; } diff --git a/Src/Idioms/NameAndTypeCollectingVisitor.cs b/Src/Idioms/NameAndTypeCollectingVisitor.cs index 5cb731162..96fd2b8f1 100644 --- a/Src/Idioms/NameAndTypeCollectingVisitor.cs +++ b/Src/Idioms/NameAndTypeCollectingVisitor.cs @@ -29,7 +29,7 @@ internal class NameAndTypeCollectingVisitor : ReflectionVisitor> Visit( @@ -40,7 +40,7 @@ internal class NameAndTypeCollectingVisitor : ReflectionVisitor> Visit( @@ -51,7 +51,7 @@ internal class NameAndTypeCollectingVisitor : ReflectionVisitor /// The Verify method attempts to invoke the instance's /// with . The expected - /// result is that this action throws an with proper parameter name, + /// result is that this action throws an with proper parameter name, /// in which case the expected behavior is considered verified. If any other exception is thrown, or /// if no exception is thrown at all, the verification fails and an exception is thrown. /// diff --git a/Src/Idioms/Properties/AssemblyInfo.cs b/Src/Idioms/Properties/AssemblyInfo.cs index d7e10b24a..d5ff0f57d 100644 --- a/Src/Idioms/Properties/AssemblyInfo.cs +++ b/Src/Idioms/Properties/AssemblyInfo.cs @@ -3,13 +3,13 @@ using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/Idioms/ReflectionVisitorElementComparer.cs b/Src/Idioms/ReflectionVisitorElementComparer.cs index 4d04e505a..33bb40182 100644 --- a/Src/Idioms/ReflectionVisitorElementComparer.cs +++ b/Src/Idioms/ReflectionVisitorElementComparer.cs @@ -8,7 +8,7 @@ namespace AutoFixture.Idioms /// /// Allows comparing instances, where the comparison /// is implemented by collecting the elements using an - /// then comparing them using + /// then comparing them using. /// /// internal abstract class ReflectionVisitorElementComparer : IEqualityComparer diff --git a/Src/Idioms/WritablePropertyException.cs b/Src/Idioms/WritablePropertyException.cs index f6f6e1d9b..4f980bfd7 100644 --- a/Src/Idioms/WritablePropertyException.cs +++ b/Src/Idioms/WritablePropertyException.cs @@ -79,7 +79,7 @@ protected WritablePropertyException(SerializationInfo info, StreamingContext con /// Gets the property supplied via the constructor. /// /// Notice, value might null after deserialization on platforms that don't support serialization. - /// + /// /// public PropertyInfo PropertyInfo => this.propertyInfo; diff --git a/Src/IdiomsUnitTest/CompositeIdiomaticAssertionTest.cs b/Src/IdiomsUnitTest/CompositeIdiomaticAssertionTest.cs index 421a1516d..abbc41161 100644 --- a/Src/IdiomsUnitTest/CompositeIdiomaticAssertionTest.cs +++ b/Src/IdiomsUnitTest/CompositeIdiomaticAssertionTest.cs @@ -62,10 +62,10 @@ public void VerifyConstructorInfoVerifiesAllIdiomaticAssertions() // Arrange var observedConstructors = new List(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnConstructorInfoVerify = observedConstructors.Add}, 3).ToArray(); + new DelegatingIdiomaticAssertion { OnConstructorInfoVerify = observedConstructors.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); - Type typeWithConstructor = typeof (UnguardedConstructorHost); + Type typeWithConstructor = typeof(UnguardedConstructorHost); ConstructorInfo ctor = typeWithConstructor.GetConstructors().First(); // Act sut.Verify(ctor); @@ -79,10 +79,10 @@ public void VerifyMethodInfoVerifiesAllIdiomaticAssertions() // Arrange var observedMethods = new List(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnMethodInfoVerify = observedMethods.Add}, 3).ToArray(); + new DelegatingIdiomaticAssertion { OnMethodInfoVerify = observedMethods.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); - Type typeWithMethod = typeof (TypeWithConcreteParameterMethod); + Type typeWithMethod = typeof(TypeWithConcreteParameterMethod); MethodInfo method = typeWithMethod.GetMethods().First(); // Act sut.Verify(method); @@ -96,10 +96,10 @@ public void VerifyPropertyInfoVerifiesAllIdiomaticAssertions() // Arrange var observedProperties = new List(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnPropertyInfoVerify = observedProperties.Add}, 3).ToArray(); + new DelegatingIdiomaticAssertion { OnPropertyInfoVerify = observedProperties.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); - Type typeWithMethod = typeof (PropertyHolder); + Type typeWithMethod = typeof(PropertyHolder); PropertyInfo property = typeWithMethod.GetProperties().First(); // Act sut.Verify(property); @@ -113,10 +113,10 @@ public void VerifyFieldInfoVerifiesAllIdiomaticAssertions() // Arrange var observedFields = new List(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnFieldInfoVerify = observedFields.Add}, 3).ToArray(); + new DelegatingIdiomaticAssertion { OnFieldInfoVerify = observedFields.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); - Type typeWithField = typeof (FieldHolder); + Type typeWithField = typeof(FieldHolder); FieldInfo field = typeWithField.GetFields().First(); // Act sut.Verify(field); @@ -130,10 +130,10 @@ public void VerifyAssemblyVerifiesAllIdiomaticAssertions() // Arrange var observedAssemblies = new List(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnAssemblyVerify = observedAssemblies.Add}, 3).ToArray(); + new DelegatingIdiomaticAssertion { OnAssemblyVerify = observedAssemblies.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); - Assembly assembly = typeof (AbstractType).Assembly; + Assembly assembly = typeof(AbstractType).Assembly; // Act sut.Verify(assembly); // Assert @@ -146,10 +146,10 @@ public void VerifyTypeVerifiesAllIdiomaticAssertions() // Arrange var observedTypes = new List(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnTypeVerify = observedTypes.Add}, 3).ToArray(); + new DelegatingIdiomaticAssertion { OnTypeVerify = observedTypes.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); - Type type = typeof (AbstractType); + Type type = typeof(AbstractType); // Act sut.Verify(type); // Assert @@ -162,14 +162,14 @@ public void VerifyAssemblyArrayVerifiesAllIdiomaticAssertions() // Arrange var observedAssemblies = new List(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnAssemblyArrayVerify = observedAssemblies.Add}, 3) + new DelegatingIdiomaticAssertion { OnAssemblyArrayVerify = observedAssemblies.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var assemblies = new Assembly[] { - typeof (AbstractType).Assembly, - typeof (System.String).Assembly, + typeof(AbstractType).Assembly, + typeof(string).Assembly, }; // Act @@ -184,14 +184,14 @@ public void VerifyEnumerableAssemblyVerifiesAllIdiomaticAssertions() // Arrange var observedAssemblies = new List>(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnAssembliesVerify = observedAssemblies.Add}, 3) + new DelegatingIdiomaticAssertion { OnAssembliesVerify = observedAssemblies.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var assemblies = new[] { - typeof (AbstractType).Assembly, - typeof (System.String).Assembly, + typeof(AbstractType).Assembly, + typeof(string).Assembly, } .AsEnumerable(); @@ -207,14 +207,14 @@ public void VerifyTypeArrayVerifiesAllIdiomaticAssertions() // Arrange var observedTypeArrays = new List(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnTypeArrayVerify = observedTypeArrays.Add}, 3) + new DelegatingIdiomaticAssertion { OnTypeArrayVerify = observedTypeArrays.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var types = new[] { - typeof (AbstractType), - typeof (System.String), + typeof(AbstractType), + typeof(string), }; // Act @@ -229,14 +229,14 @@ public void VerifyEnumerableTypesVerifiesAllIdiomaticAssertions() // Arrange var observedTypes = new List>(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnTypesVerify = observedTypes.Add}, 3) + new DelegatingIdiomaticAssertion { OnTypesVerify = observedTypes.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var assemblies = new[] { - typeof (AbstractType), - typeof (System.String), + typeof(AbstractType), + typeof(string), } .AsEnumerable(); @@ -252,14 +252,14 @@ public void VerifyMemberInfoArrayVerifiesAllIdiomaticAssertions() // Arrange var observedMemberInfoArrays = new List(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnMemberInfoArrayVerify = observedMemberInfoArrays.Add}, 3) + new DelegatingIdiomaticAssertion { OnMemberInfoArrayVerify = observedMemberInfoArrays.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var members = new[] { - typeof (AbstractType).GetMembers().First(), - typeof (System.String).GetMembers().First(), + typeof(AbstractType).GetMembers().First(), + typeof(string).GetMembers().First(), }; // Act @@ -274,14 +274,14 @@ public void VerifyEnumerableMemberInfoVerifiesAllIdiomaticAssertions() // Arrange var observedMemberInfos = new List>(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnMemberInfosVerify = observedMemberInfos.Add}, 3) + new DelegatingIdiomaticAssertion { OnMemberInfosVerify = observedMemberInfos.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); IEnumerable members = new[] { - typeof (AbstractType).GetMembers().First(), - typeof (System.String).GetMembers().First(), + typeof(AbstractType).GetMembers().First(), + typeof(string).GetMembers().First(), } .AsEnumerable(); @@ -297,14 +297,14 @@ public void VerifyEnumerableConstructorInfoVerifiesAllIdiomaticAssertions() // Arrange var observedConstructors = new List>(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnConstructorInfosVerify = observedConstructors.Add}, 3) + new DelegatingIdiomaticAssertion { OnConstructorInfosVerify = observedConstructors.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); IEnumerable ctors = new[] { - typeof (ConcreteType).GetConstructors().First(), - typeof (System.String).GetConstructors().First(), + typeof(ConcreteType).GetConstructors().First(), + typeof(string).GetConstructors().First(), } .AsEnumerable(); @@ -320,14 +320,14 @@ public void VerifyEnumerableMethodInfoVerifiesAllIdiomaticAssertions() // Arrange var observedMethods = new List>(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnMethodInfosVerify = observedMethods.Add}, 3) + new DelegatingIdiomaticAssertion { OnMethodInfosVerify = observedMethods.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); IEnumerable methods = new[] { - typeof (AbstractType).GetMethods().First(), - typeof (System.String).GetMethods().First(), + typeof(AbstractType).GetMethods().First(), + typeof(string).GetMethods().First(), } .AsEnumerable(); @@ -343,14 +343,14 @@ public void VerifyPropertyInfoArrayVerifiesAllIdiomaticAssertions() // Arrange var observedPropertyArrays = new List(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnPropertyInfoArrayVerify = observedPropertyArrays.Add}, 3) + new DelegatingIdiomaticAssertion { OnPropertyInfoArrayVerify = observedPropertyArrays.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var properties = new[] { - typeof (AbstractType).GetProperties().First(), - typeof (System.String).GetProperties().First(), + typeof(AbstractType).GetProperties().First(), + typeof(string).GetProperties().First(), }; // Act @@ -365,14 +365,14 @@ public void VerifyEnumerablePropertyInfoVerifiesAllIdiomaticAssertions() // Arrange var observedProperties = new List>(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnPropertyInfosVerify = observedProperties.Add}, 3) + new DelegatingIdiomaticAssertion { OnPropertyInfosVerify = observedProperties.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); IEnumerable properties = new[] { - typeof (AbstractType).GetProperties().First(), - typeof (System.String).GetProperties().First(), + typeof(AbstractType).GetProperties().First(), + typeof(string).GetProperties().First(), } .AsEnumerable(); @@ -388,14 +388,14 @@ public void VerifyFieldInfoArrayVerifiesAllIdiomaticAssertions() // Arrange var observedFieldArrays = new List(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnFieldInfoArrayVerify = observedFieldArrays.Add}, 3) + new DelegatingIdiomaticAssertion { OnFieldInfoArrayVerify = observedFieldArrays.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var fields = new[] { - typeof (FieldHolder).GetFields().First(), - typeof (System.String).GetFields().First(), + typeof(FieldHolder).GetFields().First(), + typeof(string).GetFields().First(), }; // Act @@ -410,14 +410,14 @@ public void VerifyEnumerableFieldInfoVerifiesAllIdiomaticAssertions() // Arrange var observedFields = new List>(); var expectations = Enumerable.Repeat( - new DelegatingIdiomaticAssertion {OnFieldInfosVerify = observedFields.Add}, 3) + new DelegatingIdiomaticAssertion { OnFieldInfosVerify = observedFields.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); IEnumerable fields = new[] { - typeof (FieldHolder).GetFields().First(), - typeof (System.String).GetFields().First(), + typeof(FieldHolder).GetFields().First(), + typeof(string).GetFields().First(), } .AsEnumerable(); diff --git a/Src/IdiomsUnitTest/ConstructorInitializedMemberAssertionTest.cs b/Src/IdiomsUnitTest/ConstructorInitializedMemberAssertionTest.cs index 0a54bde38..ee4f00731 100644 --- a/Src/IdiomsUnitTest/ConstructorInitializedMemberAssertionTest.cs +++ b/Src/IdiomsUnitTest/ConstructorInitializedMemberAssertionTest.cs @@ -139,7 +139,7 @@ public void VerifyDefaultConstructorDoesNotThrow() var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); // Act & Assert - var constructorWithNoParameters = typeof (PropertyHolder).GetConstructors().First(); + var constructorWithNoParameters = typeof(PropertyHolder).GetConstructors().First(); Assert.Empty(constructorWithNoParameters.GetParameters()); Assert.Null(Record.Exception(() => sut.Verify(constructorWithNoParameters))); @@ -212,7 +212,7 @@ public void VerifyIllBehavedPropertiesInitializedViaConstructorThrows() // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); - var illBehavedType = typeof (PropertiesIncorrectlyInitializedViaConstructor); + var illBehavedType = typeof(PropertiesIncorrectlyInitializedViaConstructor); var propertyInfo1 = illBehavedType.GetProperty("Property1"); var propertyInfo2 = illBehavedType.GetProperty("Property2"); // Act & Assert @@ -266,8 +266,8 @@ public void VerifyWhenNotAllConstructorArgumentsAreExposedAsFieldsThrows() // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); - var ctor = typeof (FieldsInitializedViaConstructor) - .GetConstructor(new[] {typeof (object), typeof (int), typeof (TriState)}); + var ctor = typeof(FieldsInitializedViaConstructor) + .GetConstructor(new[] { typeof(object), typeof(int), typeof(TriState) }); // Act & Assert var e = Assert.Throws(() => sut.Verify(ctor)); var expectedMissingParam = ctor.GetParameters().Single(p => p.Name == "noMatchingField"); @@ -556,7 +556,7 @@ public void VerifyDefaultOnlyEnumDoesThrowBecauseOfPotentialFalsePositive(Type t Assert.Throws(() => sut.Verify(type)); } - static void AssertExceptionPropertiesEqual(ConstructorInitializedMemberException ex, ConstructorInfo ctor, ParameterInfo param) + private static void AssertExceptionPropertiesEqual(ConstructorInitializedMemberException ex, ConstructorInfo ctor, ParameterInfo param) { Assert.Equal(param, ex.MissingParameter); Assert.Equal(ctor, ex.MemberInfo); @@ -565,7 +565,7 @@ static void AssertExceptionPropertiesEqual(ConstructorInitializedMemberException Assert.Null(ex.PropertyInfo); } - static void AssertExceptionPropertiesEqual(ConstructorInitializedMemberException ex, PropertyInfo pi) + private static void AssertExceptionPropertiesEqual(ConstructorInitializedMemberException ex, PropertyInfo pi) { Assert.Null(ex.ConstructorInfo); Assert.Null(ex.MissingParameter); @@ -574,7 +574,7 @@ static void AssertExceptionPropertiesEqual(ConstructorInitializedMemberException Assert.Equal(pi, ex.PropertyInfo); } - static void AssertExceptionPropertiesEqual(ConstructorInitializedMemberException ex, FieldInfo fi) + private static void AssertExceptionPropertiesEqual(ConstructorInitializedMemberException ex, FieldInfo fi) { Assert.Null(ex.ConstructorInfo); Assert.Null(ex.MissingParameter); @@ -583,19 +583,19 @@ static void AssertExceptionPropertiesEqual(ConstructorInitializedMemberException Assert.Null(ex.PropertyInfo); } - class PublicReadOnlyFieldNotInitializedByConstructor + private class PublicReadOnlyFieldNotInitializedByConstructor { #pragma warning disable 649 public readonly int Field; #pragma warning restore 649 } - class ReadOnlyPropertyWithNoSetterHolder + private class ReadOnlyPropertyWithNoSetterHolder { - public T Property { get { return default(T); } } + public T Property => default(T); } - class WritablePropertyAndIllBehavedConstructor + private class WritablePropertyAndIllBehavedConstructor { public WritablePropertyAndIllBehavedConstructor(int property) { @@ -604,7 +604,7 @@ public WritablePropertyAndIllBehavedConstructor(int property) public int Property { get; set; } } - class WriteOnlyPropertyHolder + private class WriteOnlyPropertyHolder { private T writeOnlyPropertyBackingField; @@ -627,7 +627,7 @@ public T WriteOnlyProperty } } - class ComplexType + private class ComplexType { public ComplexType() { @@ -637,12 +637,12 @@ public ComplexType() public ICollection Children { get; set; } } - class ComplexTypeChild + private class ComplexTypeChild { public string Name { get; set; } } - class PropertyIsAssignableFromConstructorArgumentType + private class PropertyIsAssignableFromConstructorArgumentType { private readonly IEnumerable bribbets; @@ -657,7 +657,7 @@ public IEnumerable Bribbets } } - class ReadOnlyFieldInitializedViaConstructorWithDifferentType + private class ReadOnlyFieldInitializedViaConstructorWithDifferentType { public readonly string Field; @@ -667,7 +667,7 @@ public ReadOnlyFieldInitializedViaConstructorWithDifferentType(int value) } } - class ReadOnlyFieldInitializedViaConstructor + private class ReadOnlyFieldInitializedViaConstructor { public readonly T Field; @@ -677,7 +677,7 @@ public ReadOnlyFieldInitializedViaConstructor(T field) } } - class ReadOnlyFieldIncorrectlyInitializedViaConstructor + private class ReadOnlyFieldIncorrectlyInitializedViaConstructor { #pragma warning disable 649 public readonly T Field; @@ -688,7 +688,7 @@ public ReadOnlyFieldIncorrectlyInitializedViaConstructor(T field) } } - class ReadOnlyPropertiesInitializedViaConstructor + private class ReadOnlyPropertiesInitializedViaConstructor { public ReadOnlyPropertiesInitializedViaConstructor(T1 property1) { @@ -716,7 +716,7 @@ public ReadOnlyPropertiesInitializedViaConstructor(T1 property1, T2 property2, T public T2 Property2 { get; private set; } } - class PropertiesIncorrectlyInitializedViaConstructor + private class PropertiesIncorrectlyInitializedViaConstructor { public PropertiesIncorrectlyInitializedViaConstructor(T1 property1, T2 property2) { @@ -734,7 +734,7 @@ public PropertiesIncorrectlyInitializedViaConstructor(T2 property2) public T2 Property2 { get; set; } } - class FieldsInitializedViaConstructor + private class FieldsInitializedViaConstructor { public FieldsInitializedViaConstructor(T1 field1) { @@ -762,7 +762,7 @@ public FieldsInitializedViaConstructor(T1 field1, T2 field2, TriState noMatching public T2 Field2; } - class ReadOnlyPropertyInitializedViaConstructor + private class ReadOnlyPropertyInitializedViaConstructor { public ReadOnlyPropertyInitializedViaConstructor(T property) { @@ -772,7 +772,7 @@ public ReadOnlyPropertyInitializedViaConstructor(T property) public T Property { get; private set; } } - class ReadOnlyPropertyIncorrectlyInitializedViaConstructor + private class ReadOnlyPropertyIncorrectlyInitializedViaConstructor { public ReadOnlyPropertyIncorrectlyInitializedViaConstructor(T property) { @@ -781,7 +781,7 @@ public ReadOnlyPropertyIncorrectlyInitializedViaConstructor(T property) public T Property { get; private set; } } - class FakeReflectionElementComparer : IEqualityComparer + private class FakeReflectionElementComparer : IEqualityComparer { public bool Equals(IReflectionElement x, IReflectionElement y) { @@ -794,7 +794,7 @@ public int GetHashCode(IReflectionElement obj) } } - class FakeEqualityComparer : IEqualityComparer + private class FakeEqualityComparer : IEqualityComparer { bool IEqualityComparer.Equals(object x, object y) { @@ -807,19 +807,72 @@ int IEqualityComparer.GetHashCode(object obj) } } - //All approved enum type variants : https://msdn.microsoft.com/en-us/library/sbbt4032.aspx?f=255&MSPPError=-2147217396 - enum TestIntEnum { none = 0, one, two, three }; - enum TestByteEnum : byte { none = 0, one, two, three }; - enum TestSByteEnum : sbyte { none = 0, one, two, three }; - enum TestShortEnum : short { none = 0, one, two, three }; - enum TestUShortEnum : ushort { none = 0, one, two, three }; - enum TestUIntEnum : uint { none = 0, one, two, three }; - enum TestLongEnum : long { none = 0, one, two, three }; - enum TestULongEnum : ulong { none = 0, one, two, three }; - - enum TestDefaultOnlyEnum { none = 0 }; + // All approved enum type variants : https://msdn.microsoft.com/en-us/library/sbbt4032.aspx?f=255&MSPPError=-2147217396 + private enum TestIntEnum + { + None = 0, + One, + Two, + Three + } + private enum TestByteEnum : byte + { + None = 0, + One, + Two, + Three + } + private enum TestSByteEnum : sbyte + { + None = 0, + One, + Two, + Three + } + private enum TestShortEnum : short + { + None = 0, + One, + Two, + Three + } + private enum TestUShortEnum : ushort + { + None = 0, + One, + Two, + Three + } + private enum TestUIntEnum : uint + { + None = 0, + One, + Two, + Three + } + private enum TestLongEnum : long + { + None = 0, + One, + Two, + Three + } + private enum TestULongEnum : ulong + { + None = 0, + One, + Two, + Three + } - enum TestSingleNonDefaultEnum { none = 1 }; + private enum TestDefaultOnlyEnum + { + None = 0 + } + private enum TestSingleNonDefaultEnum + { + None = 1 + } } } diff --git a/Src/IdiomsUnitTest/CopyAndUpdateAssertionTest.cs b/Src/IdiomsUnitTest/CopyAndUpdateAssertionTest.cs index 93cd22315..917c06fc5 100644 --- a/Src/IdiomsUnitTest/CopyAndUpdateAssertionTest.cs +++ b/Src/IdiomsUnitTest/CopyAndUpdateAssertionTest.cs @@ -101,16 +101,16 @@ public void VerifyNullMethodInfoThrows() var sut = new CopyAndUpdateAssertion(dummyComposer); // Act & Assert Assert.Throws(() => - sut.Verify((MethodInfo) null)); + sut.Verify((MethodInfo)null)); } [Theory] - [InlineData(typeof (ImmutableWellBehavedCopyMethods), "WithFirst")] - [InlineData(typeof (ImmutableWellBehavedCopyMethods), "WithSecond")] - [InlineData(typeof (ImmutableWellBehavedCopyMethods), "WithThird")] - [InlineData(typeof (MutableWellBehavedCopyMethods), "WithFirst")] - [InlineData(typeof (MutableWellBehavedCopyMethods), "WithSecond")] - [InlineData(typeof (MutableWellBehavedCopyMethods), "WithThird")] + [InlineData(typeof(ImmutableWellBehavedCopyMethods), "WithFirst")] + [InlineData(typeof(ImmutableWellBehavedCopyMethods), "WithSecond")] + [InlineData(typeof(ImmutableWellBehavedCopyMethods), "WithThird")] + [InlineData(typeof(MutableWellBehavedCopyMethods), "WithFirst")] + [InlineData(typeof(MutableWellBehavedCopyMethods), "WithSecond")] + [InlineData(typeof(MutableWellBehavedCopyMethods), "WithThird")] public void VerifyWellBehavedDoesNotThrow(Type typeWithCopyUpdateMethod, string copyUpdateMethodName) { // Arrange @@ -123,15 +123,15 @@ public void VerifyWellBehavedDoesNotThrow(Type typeWithCopyUpdateMethod, string } [Theory] - [InlineData(typeof (MutableIllBehavedCopyMethods), "WithFirstButFirstDifferent", "First")] - [InlineData(typeof (MutableIllBehavedCopyMethods), "WithSecondButSecondDifferent", "Second")] - [InlineData(typeof (MutableIllBehavedCopyMethods), "WithThirdButThirdDifferent", "Third")] - [InlineData(typeof (ImmutableIllBehavedCopyMethods), "WithFirstButSecondDefault", "Second")] - [InlineData(typeof (ImmutableIllBehavedCopyMethods), "WithSecondButThirdDefault", "Third")] - [InlineData(typeof (ImmutableIllBehavedCopyMethods), "WithThirdButFirstDefault", "First")] - [InlineData(typeof (MutableIllBehavedCopyMethods), "WithFirstButSecondDefault", "Second")] - [InlineData(typeof (MutableIllBehavedCopyMethods), "WithSecondButThirdDefault", "Third")] - [InlineData(typeof (MutableIllBehavedCopyMethods), "WithThirdButFirstDefault", "First")] + [InlineData(typeof(MutableIllBehavedCopyMethods), "WithFirstButFirstDifferent", "First")] + [InlineData(typeof(MutableIllBehavedCopyMethods), "WithSecondButSecondDifferent", "Second")] + [InlineData(typeof(MutableIllBehavedCopyMethods), "WithThirdButThirdDifferent", "Third")] + [InlineData(typeof(ImmutableIllBehavedCopyMethods), "WithFirstButSecondDefault", "Second")] + [InlineData(typeof(ImmutableIllBehavedCopyMethods), "WithSecondButThirdDefault", "Third")] + [InlineData(typeof(ImmutableIllBehavedCopyMethods), "WithThirdButFirstDefault", "First")] + [InlineData(typeof(MutableIllBehavedCopyMethods), "WithFirstButSecondDefault", "Second")] + [InlineData(typeof(MutableIllBehavedCopyMethods), "WithSecondButThirdDefault", "Third")] + [InlineData(typeof(MutableIllBehavedCopyMethods), "WithThirdButFirstDefault", "First")] public void VerifyIllBehavedWithInvalidMemberValueThrows( Type typeWithCopyUpdateMethod, string copyUpdateMethodName, @@ -149,9 +149,9 @@ public void VerifyWellBehavedDoesNotThrow(Type typeWithCopyUpdateMethod, string } [Theory] - [InlineData(typeof (ImmutableWithDifferentName), "With", "differentName")] - [InlineData(typeof (ImmutableWithDifferentType), "With", "differentType")] - [InlineData(typeof (ImmutableWithDifferentBoth), "With", "differentBoth")] + [InlineData(typeof(ImmutableWithDifferentName), "With", "differentName")] + [InlineData(typeof(ImmutableWithDifferentType), "With", "differentType")] + [InlineData(typeof(ImmutableWithDifferentBoth), "With", "differentBoth")] public void VerifyWhenMethodHasNoMatchingPublicMembersThrows( Type copyUpdateMethodType, string methodName, @@ -283,7 +283,7 @@ public MutableIllBehavedCopyMethods WithThirdButThirdDifferent(ComplexMutable { - First = third.First+1, + First = third.First + 1, Second = third.Second, Third = third.Third, }; @@ -375,7 +375,7 @@ private class ComplexMutable Assert.Equal(memberWithInvalidValue, ex.MemberWithInvalidValue); } - class DummyReflectionElementComparer : IEqualityComparer + private class DummyReflectionElementComparer : IEqualityComparer { public bool Equals(IReflectionElement x, IReflectionElement y) { @@ -388,7 +388,7 @@ public int GetHashCode(IReflectionElement obj) } } - class DummyEqualityComparer : IEqualityComparer + private class DummyEqualityComparer : IEqualityComparer { bool IEqualityComparer.Equals(object x, object y) { diff --git a/Src/IdiomsUnitTest/EmptyGuidBehaviorExpectationTest.cs b/Src/IdiomsUnitTest/EmptyGuidBehaviorExpectationTest.cs index 68c8179b6..4a496a44c 100644 --- a/Src/IdiomsUnitTest/EmptyGuidBehaviorExpectationTest.cs +++ b/Src/IdiomsUnitTest/EmptyGuidBehaviorExpectationTest.cs @@ -72,7 +72,7 @@ public void VerifyCorrectlyInvokesExecuteWhenRequestedTypeIsGuid() public void VerifySuccedsWhenCommandThrowsCorrectException() { // Arrange - var cmd = new DelegatingGuardClauseCommand + var cmd = new DelegatingGuardClauseCommand { OnExecute = v => { throw new ArgumentException(); }, RequestedType = typeof(Guid) diff --git a/Src/IdiomsUnitTest/EqualsNewObjectAssertionTest.cs b/Src/IdiomsUnitTest/EqualsNewObjectAssertionTest.cs index 1a31542ec..9704554a2 100644 --- a/Src/IdiomsUnitTest/EqualsNewObjectAssertionTest.cs +++ b/Src/IdiomsUnitTest/EqualsNewObjectAssertionTest.cs @@ -85,7 +85,7 @@ public void VerifyIllbehavedEqualsNullBehaviourThrows() } #pragma warning disable 659 - class WellBehavedEqualsNewObjectOverride + private class WellBehavedEqualsNewObjectOverride { public override bool Equals(object obj) { @@ -96,7 +96,7 @@ public override bool Equals(object obj) } } - class IllBehavedEqualsNewObjectOverride + private class IllBehavedEqualsNewObjectOverride { public override bool Equals(object obj) { @@ -108,9 +108,8 @@ public override bool Equals(object obj) } #pragma warning restore 659 - class ClassThatDoesNotOverrideObjectEquals + private class ClassThatDoesNotOverrideObjectEquals { } } - } diff --git a/Src/IdiomsUnitTest/EqualsNullAssertionTest.cs b/Src/IdiomsUnitTest/EqualsNullAssertionTest.cs index e9d5d1147..8796657ca 100644 --- a/Src/IdiomsUnitTest/EqualsNullAssertionTest.cs +++ b/Src/IdiomsUnitTest/EqualsNullAssertionTest.cs @@ -90,14 +90,14 @@ public void VerifyAnonymousMethodWithNoDeclaringOrReflectedTypeDoesNothing() // Arrange var dummyComposer = new Fixture(); var sut = new EqualsNullAssertion(dummyComposer); - var method = (MethodInfo)(new MethodInfoWithNullDeclaringAndReflectedType()); + var method = (MethodInfo)new MethodInfoWithNullDeclaringAndReflectedType(); // Act & Assert Assert.Null(Record.Exception(() => sut.Verify(method))); } - class MethodInfoWithNullDeclaringAndReflectedType : MethodInfo + private class MethodInfoWithNullDeclaringAndReflectedType : MethodInfo { public override Type ReflectedType { @@ -109,8 +109,6 @@ public override Type DeclaringType get { return null; } } - #region Other - public override MethodInfo GetBaseDefinition() { throw new NotImplementedException(); @@ -165,12 +163,10 @@ public override string Name { get { throw new NotImplementedException(); } } - - #endregion } #pragma warning disable 659 - class IllbehavedEqualsNullOverride + private class IllbehavedEqualsNullOverride { public override bool Equals(object obj) { @@ -182,7 +178,7 @@ public override bool Equals(object obj) } } - class WellBehavedEqualsNullOverride + private class WellBehavedEqualsNullOverride { public override bool Equals(object obj) { @@ -195,9 +191,8 @@ public override bool Equals(object obj) } #pragma warning restore 659 - class ClassThatDoesNotOverrideObjectEquals + private class ClassThatDoesNotOverrideObjectEquals { } } - } diff --git a/Src/IdiomsUnitTest/EqualsSelfAssertionTest.cs b/Src/IdiomsUnitTest/EqualsSelfAssertionTest.cs index 5e5f92d02..5539c3fb0 100644 --- a/Src/IdiomsUnitTest/EqualsSelfAssertionTest.cs +++ b/Src/IdiomsUnitTest/EqualsSelfAssertionTest.cs @@ -85,22 +85,22 @@ public void VerifyIllbehavedEqualsSelfBehaviourThrows() } #pragma warning disable 659 - class WellBehavedEqualsSelfObjectOverride + private class WellBehavedEqualsSelfObjectOverride { public override bool Equals(object obj) { - if (obj != null && Object.ReferenceEquals(this, obj)) + if (obj != null && object.ReferenceEquals(this, obj)) return true; throw new Exception(); } } - class IllBehavedEqualsSelfObjectOverride + private class IllBehavedEqualsSelfObjectOverride { public override bool Equals(object obj) { - if (obj != null && Object.ReferenceEquals(this, obj)) + if (obj != null && object.ReferenceEquals(this, obj)) return false; throw new Exception(); @@ -108,9 +108,8 @@ public override bool Equals(object obj) } #pragma warning restore 659 - class ClassThatDoesNotOverrideObjectEquals + private class ClassThatDoesNotOverrideObjectEquals { } } - } diff --git a/Src/IdiomsUnitTest/EqualsSuccessiveAssertionTest.cs b/Src/IdiomsUnitTest/EqualsSuccessiveAssertionTest.cs index 9f4978ddc..eb0f4630d 100644 --- a/Src/IdiomsUnitTest/EqualsSuccessiveAssertionTest.cs +++ b/Src/IdiomsUnitTest/EqualsSuccessiveAssertionTest.cs @@ -85,7 +85,7 @@ public void VerifyIllbehavedEqualsSuccessiveBehaviourThrows() } #pragma warning disable 659 - class WellBehavedEqualsSuccessiveObjectOverride + private class WellBehavedEqualsSuccessiveObjectOverride { public override bool Equals(object obj) { @@ -93,21 +93,19 @@ public override bool Equals(object obj) } } - class IllBehavedEqualsSuccessiveObjectOverride + private class IllBehavedEqualsSuccessiveObjectOverride { - public int equalsCallCount; + public int EqualsCallCount; public override bool Equals(object obj) { - return (++this.equalsCallCount % 2 == 0); + return ++this.EqualsCallCount % 2 == 0; } } #pragma warning restore 659 - - class ClassThatDoesNotOverrideObjectEquals + private class ClassThatDoesNotOverrideObjectEquals { } } - } diff --git a/Src/IdiomsUnitTest/GetHashCodeSuccessiveAssertionTest.cs b/Src/IdiomsUnitTest/GetHashCodeSuccessiveAssertionTest.cs index 7a56fa5a2..89867cf13 100644 --- a/Src/IdiomsUnitTest/GetHashCodeSuccessiveAssertionTest.cs +++ b/Src/IdiomsUnitTest/GetHashCodeSuccessiveAssertionTest.cs @@ -85,7 +85,7 @@ public void VerifyIllbehavedEqualsSelfBehaviourThrows() } #pragma warning disable 659 - class WellBehavedGetHashCodeSelfObjectOverride + private class WellBehavedGetHashCodeSelfObjectOverride { public override int GetHashCode() { @@ -93,7 +93,7 @@ public override int GetHashCode() } } - class IllBehavedEqualsSelfObjectOverride + private class IllBehavedEqualsSelfObjectOverride { private static readonly Random HashCodeGenerator = new Random(); @@ -104,7 +104,7 @@ public override int GetHashCode() } #pragma warning restore 659 - class ClassThatDoesNotOverrideObjectGetHashCode + private class ClassThatDoesNotOverrideObjectGetHashCode { } } diff --git a/Src/IdiomsUnitTest/GuardClauseAssertionTest.cs b/Src/IdiomsUnitTest/GuardClauseAssertionTest.cs index c521eac51..f849f0248 100644 --- a/Src/IdiomsUnitTest/GuardClauseAssertionTest.cs +++ b/Src/IdiomsUnitTest/GuardClauseAssertionTest.cs @@ -15,8 +15,8 @@ namespace AutoFixture.IdiomsUnitTest { - [SuppressMessage("ReSharper", "UnusedMember.Local")] - [SuppressMessage("ReSharper", "UnusedParameter.Local")] + [SuppressMessage("ReSharper", "UnusedMember.Local", Justification="Used via reflection.")] + [SuppressMessage("ReSharper", "UnusedParameter.Local", Justification="Required for testing.")] public class GuardClauseAssertionTest { [Fact] @@ -373,7 +373,6 @@ public void VerifyConstructorInvokesBehaviorExpectationWithCorrectParameterInfo( Assert.Equal(parameters, observedParameters); } - public static TheoryData> MethodData => new TheoryData> { MemberRef.MethodByName(typeof(GuardedMethodHost), nameof(GuardedMethodHost.ConsumeString)), @@ -444,9 +443,11 @@ private class ClassWithDeferredGuidGuard public IEnumerable GetValues(Guid someGuid) { if (someGuid == null) + { throw new ArgumentException( "Guid.Empty not allowed.", nameof(someGuid)); + } yield return someGuid; yield return someGuid; @@ -459,9 +460,11 @@ private class ClassWithDeferredGuidGuardReturningEnumerator public IEnumerator GetValues(Guid someGuid) { if (someGuid == null) + { throw new ArgumentException( "Guid.Empty not allowed.", nameof(someGuid)); + } yield return someGuid; yield return someGuid; @@ -522,7 +525,7 @@ public Stack GetValues(string someString) private class ClassWithEnumerableNonDeferredReadOnlyCollectionBaseMissingGuard { - class ReadOnlyCollection : ReadOnlyCollectionBase + private class ReadOnlyCollection : ReadOnlyCollectionBase { public ReadOnlyCollection(params object[] items) { @@ -613,7 +616,7 @@ private class ClassWithEnumerableNonDeferredGenericReadOnlyCollectionMissingGuar { public ReadOnlyCollection GetValues(string someString) { - return new ReadOnlyCollection(new[] {someString, someString, someString }); + return new ReadOnlyCollection(new[] { someString, someString, someString }); } } @@ -621,7 +624,7 @@ private class ClassWithEnumerableNonDeferredGenericDictionaryMissingGuard { public Dictionary GetValues(string someString) { - return new Dictionary + return new Dictionary { { "uniqueKey1", someString }, { "uniqueKey2", someString } @@ -629,7 +632,9 @@ private class ClassWithEnumerableNonDeferredGenericDictionaryMissingGuard } } - private interface IHaveNoImplementers { } + private interface IHaveNoImplementers + { + } [Fact] public void VerifyNullConstructorThrows() @@ -892,7 +897,6 @@ public void VerifyMethodOnGenericManyTimeLoadsOnlyUniqueAssemblies() sut.Verify(methodInfo); sut.Verify(methodInfo); // Assert - var assembliesAfter = AppDomain.CurrentDomain.GetAssemblies(); Assert.Equal(assembliesBefore, assembliesAfter); @@ -947,7 +951,7 @@ public void DynamicDummyTypeIfReturnMethodIsCalledReturnsAnonymousValue() mockVerification = true; } }; - + var sut = new GuardClauseAssertion(fixture, behaviorExpectation); var methodInfo = typeof(DynamicInstanceTestConstraint<>).GetMethod("Method"); // Act @@ -1048,7 +1052,7 @@ public Task TaskOfTWithCorrectGuardClause(object obj) return Task.Run(() => obj.ToString()); } - + public Task TaskWithCorrectGuardClause(object obj) { if (obj == null) throw new ArgumentNullException(nameof(obj)); @@ -1082,7 +1086,7 @@ public Task TaskWithInnerGuardClause(object obj) public void VerifyNonProperlyGuardedConstructorThrowsException() { var sut = new GuardClauseAssertion(new Fixture()); - var constructorInfo = typeof (NonProperlyGuardedClass).GetConstructors().Single(); + var constructorInfo = typeof(NonProperlyGuardedClass).GetConstructors().Single(); var exception = Assert.Throws(() => sut.Verify(constructorInfo)); Assert.Contains("Guard Clause prevented it, however", exception.Message); @@ -1119,7 +1123,6 @@ public void VerifyNonProperlyGuardedMethodThrowsException(string methodName, str typeof(ParameterizedConstructorTestConstraint<>), typeof(UnclosedGenericMethodTestType<>), typeof(NestedGenericParameterTestType<,>) - }; public static TheoryData> ConstructorsOnGuardedOpenGenericTypes => @@ -1191,7 +1194,8 @@ public void Method(T argument) } } - private class InterfacesContraint where T : IInterfaceTestType, IEnumerable + private class InterfacesContraint + where T : IInterfaceTestType, IEnumerable { public InterfacesContraint(T argument) { @@ -1204,7 +1208,8 @@ public void Method(T argument) } } - private class StructureAndInterfacesContraint where T : struct, IInterfaceTestType, IEnumerable + private class StructureAndInterfacesContraint + where T : struct, IInterfaceTestType, IEnumerable { public StructureAndInterfacesContraint(T argument) { @@ -1226,7 +1231,8 @@ public interface IInterfaceTestType void Method(object argument); } - private class ClassContraint where T : class + private class ClassContraint + where T : class { public ClassContraint(T argument) { @@ -1239,7 +1245,8 @@ public void Method(T argument) } } - private class CertainClassContraint where T : ConcreteType + private class CertainClassContraint + where T : ConcreteType { public CertainClassContraint(T argument) { @@ -1266,7 +1273,8 @@ public void Method(T argument) } } - private class MultipleGenericArguments where T1 : class + private class MultipleGenericArguments + where T1 : class { public MultipleGenericArguments(T1 argument1, T2 argument2) { @@ -1306,9 +1314,11 @@ public abstract class AbstractTestType protected abstract void ProtectedMethod(object argument); } - private class OpenGenericTestType : OpenGenericTestTypeBase where T : class + private class OpenGenericTestType : OpenGenericTestTypeBase + where T : class { - public OpenGenericTestType(T argument) : base(argument) + public OpenGenericTestType(T argument) + : base(argument) { } } @@ -1326,9 +1336,11 @@ public void Method(T argument) } } - private class ConstructedGenericTestType : ConstructedGenericTestTypeBase where T : class + private class ConstructedGenericTestType : ConstructedGenericTestTypeBase + where T : class { - public ConstructedGenericTestType(string argument1, T argument2) : base(argument1, argument2) + public ConstructedGenericTestType(string argument1, T argument2) + : base(argument1, argument2) { } } @@ -1348,7 +1360,8 @@ public void Method(T1 argument1, T2 argument2) } } - private class ParameterizedConstructorTestConstraint where T : ParameterizedConstructorTestType, new() + private class ParameterizedConstructorTestConstraint + where T : ParameterizedConstructorTestType, new() { public void Method(T argument, object test) { @@ -1367,8 +1380,8 @@ public void Method(T argument, object test) public class ParameterizedConstructorTestType { - // to test duplicating with the specimenBuilder field of a dummy type. - public static ISpecimenBuilder specimenBuilder = null; + // to test duplicating with the SpecimenBuilder field of a dummy type. + public static ISpecimenBuilder SpecimenBuilder = null; public ParameterizedConstructorTestType(object argument1, string argument2) { @@ -1381,7 +1394,8 @@ public ParameterizedConstructorTestType(object argument1, string argument2) public string Argument2 { get; } } - private class InternalProtectedConstructorTestConstraint where T : InternalProtectedConstructorTestType + private class InternalProtectedConstructorTestConstraint + where T : InternalProtectedConstructorTestType { public InternalProtectedConstructorTestConstraint(T argument) { @@ -1395,7 +1409,8 @@ protected internal InternalProtectedConstructorTestType() } } - private class ModestConstructorTestConstraint where T : ModestConstructorTestType + private class ModestConstructorTestConstraint + where T : ModestConstructorTestType { public ModestConstructorTestConstraint(T argument) { @@ -1419,7 +1434,8 @@ protected ModestConstructorTestType(object argument) } } - private class NoAccessibleConstructorTestConstraint where T : NoAccessibleConstructorTestType + private class NoAccessibleConstructorTestConstraint + where T : NoAccessibleConstructorTestType { public NoAccessibleConstructorTestConstraint(T argument) { @@ -1433,7 +1449,8 @@ private NoAccessibleConstructorTestType() } } - public class DynamicInstanceTestConstraint where T : IDynamicInstanceTestType + public class DynamicInstanceTestConstraint + where T : IDynamicInstanceTestType { public void Method(T argument) { @@ -1449,10 +1466,12 @@ public interface IDynamicInstanceTestType int ReturnMethod(object argument1, int argument2); } - private class UnclosedGenericMethodTestType where T1 : class + private class UnclosedGenericMethodTestType + where T1 : class { public void Method(T1 argument1, int argument2, T2 argument3, T3 argument4, T4 argument5) - where T2 : class where T4 : class + where T2 : class + where T4 : class { if (argument1 == null) { @@ -1469,7 +1488,8 @@ private class UnclosedGenericMethodTestType where T1 : class } } - private class ConstructorMatchTestType where T1 : class + private class ConstructorMatchTestType + where T1 : class { public ConstructorMatchTestType(T1 argument) { @@ -1488,7 +1508,8 @@ public ConstructorMatchTestType(T2 argument1, object argument2) } } - private class MethodMatchTestType where T1 : class + private class MethodMatchTestType + where T1 : class { public MethodMatchTestType(T1 argument) { @@ -1522,7 +1543,8 @@ public void Method(T1 argument1, T3 argument2) } } - private class ByRefTestType where T1 : class + private class ByRefTestType + where T1 : class { public ByRefTestType(T1 argument) { @@ -1532,10 +1554,11 @@ public void Method(ref T1 argument) { } - public void Method(ref T2 argument) where T2 : class + public void Method(ref T2 argument) + where T2 : class { } - + public void Method(ref T1 argument1, int argument2) { } @@ -1654,9 +1677,10 @@ private abstract class AbstractTypeWithAbstractMethod } /// - /// Wrapper around member to produce nice theory name + /// Wrapper around member to produce nice theory name. /// - public class MemberRef where T : MemberInfo + public class MemberRef + where T : MemberInfo { public MemberRef(T member) { @@ -1721,7 +1745,6 @@ private static bool IsNotEqualsMethod(MethodInfo method) } } - private static TheoryData MakeTheoryData(IEnumerable entries) { var result = new TheoryData(); diff --git a/Src/IdiomsUnitTest/IdiomaticAssertionTest.cs b/Src/IdiomsUnitTest/IdiomaticAssertionTest.cs index d0228f134..6a546222e 100644 --- a/Src/IdiomsUnitTest/IdiomaticAssertionTest.cs +++ b/Src/IdiomsUnitTest/IdiomaticAssertionTest.cs @@ -143,7 +143,7 @@ public void VerifyNullTypeThrows() [Theory] [InlineData(typeof(object))] [InlineData(typeof(string))] - [InlineData(typeof(int))] + [InlineData(typeof(int))] [InlineData(typeof(Version))] public void VerifyTypeCorrectlyInvokesConstructorsVerify(Type type) { @@ -179,7 +179,7 @@ public void VerifyStaticTypeCorrectlyInvokesMethodsVerify() { // Arrange Type type = typeof(UnguardedStaticMethodOnStaticTypeHost); - var expectedMethods = new[] { type.GetMethod("Method")}; + var expectedMethods = new[] { type.GetMethod("Method") }; var mockVerified = false; var sut = new DelegatingIdiomaticAssertion { diff --git a/Src/IdiomsUnitTest/IndexedReplacementTest.cs b/Src/IdiomsUnitTest/IndexedReplacementTest.cs index 106ac7657..c7c541133 100644 --- a/Src/IdiomsUnitTest/IndexedReplacementTest.cs +++ b/Src/IdiomsUnitTest/IndexedReplacementTest.cs @@ -6,44 +6,6 @@ namespace AutoFixture.IdiomsUnitTest { - #region - public class IndexedReplacementTestOfObject : IndexedReplacementTest - { - protected override object CreateItem() - { - return new object(); - } - } - #endregion - #region - public class IndexedReplacementTestOfInt : IndexedReplacementTest - { - private int i; - - protected override int CreateItem() - { - return this.i++; - } - } - #endregion - #region - public class IndexedReplacementTestOfString : IndexedReplacementTest - { - protected override string CreateItem() - { - return Guid.NewGuid().ToString(); - } - } - #endregion - #region - public class IndexedReplacementTestOfVersion : IndexedReplacementTest - { - protected override Version CreateItem() - { - return new Version(); - } - } - #endregion public abstract class IndexedReplacementTest { [Fact] @@ -133,4 +95,38 @@ public void ExpandReturnsCorrectResult(int replacementIndex) protected abstract T CreateItem(); } + + public class IndexedReplacementTestOfObject : IndexedReplacementTest + { + protected override object CreateItem() + { + return new object(); + } + } + + public class IndexedReplacementTestOfInt : IndexedReplacementTest + { + private int i; + + protected override int CreateItem() + { + return this.i++; + } + } + + public class IndexedReplacementTestOfString : IndexedReplacementTest + { + protected override string CreateItem() + { + return Guid.NewGuid().ToString(); + } + } + + public class IndexedReplacementTestOfVersion : IndexedReplacementTest + { + protected override Version CreateItem() + { + return new Version(); + } + } } diff --git a/Src/IdiomsUnitTest/NullReferenceBehaviorExpectationTest.cs b/Src/IdiomsUnitTest/NullReferenceBehaviorExpectationTest.cs index c779d6297..58ca9049b 100644 --- a/Src/IdiomsUnitTest/NullReferenceBehaviorExpectationTest.cs +++ b/Src/IdiomsUnitTest/NullReferenceBehaviorExpectationTest.cs @@ -93,7 +93,7 @@ public void VerifyThrowsWhenCommandThrowsArgumentNullExceptionWithInvalidParamNa OnExecute = v => throw new ArgumentNullException(invalidParamName) }; var sut = new NullReferenceBehaviorExpectation(); - Assert.Throws(() => + Assert.Throws(() => sut.Verify(cmd)); } diff --git a/Src/IdiomsUnitTest/Properties/AssemblyInfo.cs b/Src/IdiomsUnitTest/Properties/AssemblyInfo.cs index 7c0b82527..249c1176b 100644 --- a/Src/IdiomsUnitTest/Properties/AssemblyInfo.cs +++ b/Src/IdiomsUnitTest/Properties/AssemblyInfo.cs @@ -1,13 +1,13 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM componenets. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM componenets. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/IdiomsUnitTest/ReflectionExceptionUnwrappingCommandTest.cs b/Src/IdiomsUnitTest/ReflectionExceptionUnwrappingCommandTest.cs index 499ec4a55..845c27192 100644 --- a/Src/IdiomsUnitTest/ReflectionExceptionUnwrappingCommandTest.cs +++ b/Src/IdiomsUnitTest/ReflectionExceptionUnwrappingCommandTest.cs @@ -29,7 +29,7 @@ public void CommandIsCorrect() // Assert Assert.Equal(expectedCommand, result); } - + [Fact] public void RequestedParamNameIsCorrect() { diff --git a/Src/IdiomsUnitTest/Scenario.cs b/Src/IdiomsUnitTest/Scenario.cs index 50023d016..c551189a4 100644 --- a/Src/IdiomsUnitTest/Scenario.cs +++ b/Src/IdiomsUnitTest/Scenario.cs @@ -106,7 +106,7 @@ public void VerifyReadOnlyPropertyInitializedByConstructor() { var fixture = new Fixture(); var assertion = new ConstructorInitializedMemberAssertion(fixture); - var members = typeof (UnguardedConstructorHost).GetProperties(); + var members = typeof(UnguardedConstructorHost).GetProperties(); assertion.Verify(members); } @@ -136,7 +136,7 @@ public void VerifyPublicPropertiesAssignableFromConstructorAreCorrectlyInitializ assertion.Verify(properties); } - class PublicPropertiesAreAssignableFromConstructorParameterTypes + private class PublicPropertiesAreAssignableFromConstructorParameterTypes { public PublicPropertiesAreAssignableFromConstructorParameterTypes( string[] bribbets, int[] numbers) @@ -161,7 +161,7 @@ public PublicPropertiesAreAssignableFromConstructorParameterTypes WithNumbers(in } } - class NameAndType + private class NameAndType { public NameAndType(string name, Type type) { @@ -173,7 +173,7 @@ public NameAndType(string name, Type type) public Type Type { get; private set; } } - class NameAndTypeAssignableComparer : IEqualityComparer + private class NameAndTypeAssignableComparer : IEqualityComparer { public bool Equals(NameAndType x, NameAndType y) { @@ -187,7 +187,7 @@ public int GetHashCode(NameAndType obj) } } - class NameAndTypeCollectingVisitor + private class NameAndTypeCollectingVisitor : ReflectionVisitor> { private readonly NameAndType[] values; @@ -237,7 +237,7 @@ public override IEnumerable Value } } - class VisitorEqualityComparer : IEqualityComparer + private class VisitorEqualityComparer : IEqualityComparer { private readonly IReflectionVisitor> visitor; private readonly IEqualityComparer comparer; @@ -301,7 +301,8 @@ public void VerifyCompositeEqualityBehaviourOnManyTypes() new EqualsSelfAssertion(fixture), new EqualsSuccessiveAssertion(fixture)); - var typesToExclude = new[] { + var typesToExclude = new[] + { // Needs parameters of type object to be IComparable typeof(RangedNumberRequest), diff --git a/Src/IdiomsUnitTest/WritablePropertyAssertionTest.cs b/Src/IdiomsUnitTest/WritablePropertyAssertionTest.cs index 7f0e8cc4c..614ee11e6 100644 --- a/Src/IdiomsUnitTest/WritablePropertyAssertionTest.cs +++ b/Src/IdiomsUnitTest/WritablePropertyAssertionTest.cs @@ -58,7 +58,7 @@ public void VerifyIllBehavedPropertyGetterThrows() // Arrange var composer = new Fixture(); var sut = new WritablePropertyAssertion(composer); - + var propertyInfo = typeof(IllBehavedPropertyHolder).GetProperty("PropertyIllBehavedGet"); // Act & Assert var e = Assert.Throws(() => diff --git a/Src/TestTypeFoundation/AbstractClassWithPublicConstructor.cs b/Src/TestTypeFoundation/AbstractClassWithPublicConstructor.cs index f96ced800..8b46b99b2 100644 --- a/Src/TestTypeFoundation/AbstractClassWithPublicConstructor.cs +++ b/Src/TestTypeFoundation/AbstractClassWithPublicConstructor.cs @@ -2,6 +2,8 @@ { public abstract class AbstractClassWithPublicConstructor { - public AbstractClassWithPublicConstructor() { } + public AbstractClassWithPublicConstructor() + { + } } } diff --git a/Src/TestTypeFoundation/EmptyEnum.cs b/Src/TestTypeFoundation/EmptyEnum.cs index 762371899..680c38e47 100644 --- a/Src/TestTypeFoundation/EmptyEnum.cs +++ b/Src/TestTypeFoundation/EmptyEnum.cs @@ -2,6 +2,6 @@ { public enum EmptyEnum { - //this must not contain any values + // this must not contain any values } } diff --git a/Src/TestTypeFoundation/GenericType.cs b/Src/TestTypeFoundation/GenericType.cs index 7d7becc5f..1d998be9b 100644 --- a/Src/TestTypeFoundation/GenericType.cs +++ b/Src/TestTypeFoundation/GenericType.cs @@ -2,7 +2,8 @@ namespace TestTypeFoundation { - public class GenericType where T : class + public class GenericType + where T : class { public GenericType(T t) { diff --git a/Src/TestTypeFoundation/GuardedConstructorHost.cs b/Src/TestTypeFoundation/GuardedConstructorHost.cs index 0777c567f..925df031e 100644 --- a/Src/TestTypeFoundation/GuardedConstructorHost.cs +++ b/Src/TestTypeFoundation/GuardedConstructorHost.cs @@ -2,7 +2,8 @@ namespace TestTypeFoundation { - public class GuardedConstructorHost where T : class + public class GuardedConstructorHost + where T : class { public GuardedConstructorHost(T item) { diff --git a/Src/TestTypeFoundation/GuardedConstructorHostHoldingStaticReadOnlyField.cs b/Src/TestTypeFoundation/GuardedConstructorHostHoldingStaticReadOnlyField.cs index a449be1f8..f3648fc12 100644 --- a/Src/TestTypeFoundation/GuardedConstructorHostHoldingStaticReadOnlyField.cs +++ b/Src/TestTypeFoundation/GuardedConstructorHostHoldingStaticReadOnlyField.cs @@ -2,7 +2,8 @@ namespace TestTypeFoundation { - public class GuardedConstructorHostHoldingStaticReadOnlyField where TItem : class + public class GuardedConstructorHostHoldingStaticReadOnlyField + where TItem : class { public static readonly TStaticField Field = default(TStaticField); diff --git a/Src/TestTypeFoundation/GuardedConstructorHostHoldingStaticReadOnlyProperty.cs b/Src/TestTypeFoundation/GuardedConstructorHostHoldingStaticReadOnlyProperty.cs index be72d4af4..ba93ded87 100644 --- a/Src/TestTypeFoundation/GuardedConstructorHostHoldingStaticReadOnlyProperty.cs +++ b/Src/TestTypeFoundation/GuardedConstructorHostHoldingStaticReadOnlyProperty.cs @@ -2,7 +2,8 @@ namespace TestTypeFoundation { - public class GuardedConstructorHostHoldingStaticReadOnlyProperty where TItem : class + public class GuardedConstructorHostHoldingStaticReadOnlyProperty + where TItem : class { static GuardedConstructorHostHoldingStaticReadOnlyProperty() { @@ -19,7 +20,7 @@ public GuardedConstructorHostHoldingStaticReadOnlyProperty(TItem item) this.Item = item; } - public static TStaticProperty Property { get;private set;} + public static TStaticProperty Property { get; private set; } public TItem Item { get; private set; } } diff --git a/Src/TestTypeFoundation/GuardedPropertyHolder.cs b/Src/TestTypeFoundation/GuardedPropertyHolder.cs index c6df1ce27..e2b098ad3 100644 --- a/Src/TestTypeFoundation/GuardedPropertyHolder.cs +++ b/Src/TestTypeFoundation/GuardedPropertyHolder.cs @@ -2,7 +2,8 @@ namespace TestTypeFoundation { - public class GuardedPropertyHolder where T : class + public class GuardedPropertyHolder + where T : class { private T property; @@ -10,7 +11,7 @@ public T Property { get { - return this.property; + return this.property; } set @@ -20,8 +21,8 @@ public T Property throw new ArgumentNullException(nameof(value)); } - this.property = value; + this.property = value; } - } + } } } \ No newline at end of file diff --git a/Src/TestTypeFoundation/IllBehavedPropertyHolder.cs b/Src/TestTypeFoundation/IllBehavedPropertyHolder.cs index 8afbef32d..ae59196d4 100644 --- a/Src/TestTypeFoundation/IllBehavedPropertyHolder.cs +++ b/Src/TestTypeFoundation/IllBehavedPropertyHolder.cs @@ -10,7 +10,7 @@ public T PropertyIllBehavedGet { return default(T); } - + set { } diff --git a/Src/TestTypeFoundation/MutableValueType.cs b/Src/TestTypeFoundation/MutableValueType.cs index 6484fa285..010b4df27 100644 --- a/Src/TestTypeFoundation/MutableValueType.cs +++ b/Src/TestTypeFoundation/MutableValueType.cs @@ -2,7 +2,8 @@ { public struct MutableValueType { - public MutableValueType(object property1, object property2, object property3): this() + public MutableValueType(object property1, object property2, object property3) + : this() { this.Property1 = property1; this.Property2 = property2; diff --git a/Src/TestTypeFoundation/Properties/AssemblyInfo.cs b/Src/TestTypeFoundation/Properties/AssemblyInfo.cs index 05b5482de..1d950fa9f 100644 --- a/Src/TestTypeFoundation/Properties/AssemblyInfo.cs +++ b/Src/TestTypeFoundation/Properties/AssemblyInfo.cs @@ -3,8 +3,8 @@ [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/Src/TestTypeFoundation/TypeWithCastOperatorsWithoutPublicConstructor.cs b/Src/TestTypeFoundation/TypeWithCastOperatorsWithoutPublicConstructor.cs index b5e64cdc4..659f7d1c5 100644 --- a/Src/TestTypeFoundation/TypeWithCastOperatorsWithoutPublicConstructor.cs +++ b/Src/TestTypeFoundation/TypeWithCastOperatorsWithoutPublicConstructor.cs @@ -6,12 +6,12 @@ private TypeWithCastOperatorsWithoutPublicConstructor() { } - public static implicit operator TypeWithCastOperatorsWithoutPublicConstructor(int _) + public static implicit operator TypeWithCastOperatorsWithoutPublicConstructor(int ignored) { return new TypeWithCastOperatorsWithoutPublicConstructor(); } - public static explicit operator TypeWithCastOperatorsWithoutPublicConstructor(string _) + public static explicit operator TypeWithCastOperatorsWithoutPublicConstructor(string ignored) { return new TypeWithCastOperatorsWithoutPublicConstructor(); } diff --git a/Src/TestTypeFoundation/TypeWithFactoryMethod.cs b/Src/TestTypeFoundation/TypeWithFactoryMethod.cs index 9d331c4aa..c25bd31c4 100644 --- a/Src/TestTypeFoundation/TypeWithFactoryMethod.cs +++ b/Src/TestTypeFoundation/TypeWithFactoryMethod.cs @@ -4,7 +4,7 @@ namespace TestTypeFoundation { public class TypeWithFactoryMethod { - private TypeWithFactoryMethod() + private TypeWithFactoryMethod() { } diff --git a/Src/TestTypeFoundation/TypeWithIndexer.cs b/Src/TestTypeFoundation/TypeWithIndexer.cs index 77000e952..810435cea 100644 --- a/Src/TestTypeFoundation/TypeWithIndexer.cs +++ b/Src/TestTypeFoundation/TypeWithIndexer.cs @@ -11,7 +11,7 @@ public TypeWithIndexer() this.dict = new Dictionary(); } - public string this[string index] + public string this[string index] { get { diff --git a/Src/TestTypeFoundation/TypeWithPseudoFactoryMethod.cs b/Src/TestTypeFoundation/TypeWithPseudoFactoryMethod.cs index 83478e4cb..84a46c8b0 100644 --- a/Src/TestTypeFoundation/TypeWithPseudoFactoryMethod.cs +++ b/Src/TestTypeFoundation/TypeWithPseudoFactoryMethod.cs @@ -1,9 +1,9 @@ namespace TestTypeFoundation { /// - /// This type contains a method that returns an instance of the same type - /// so that it looks like a Factory Method. In fact, it is not because it - /// receives a parameter of the same type, so using it as a factory inevitably + /// This type contains a method that returns an instance of the same type + /// so that it looks like a Factory Method. In fact, it is not because it + /// receives a parameter of the same type, so using it as a factory inevitably /// leads to circular dependencies. /// public class TypeWithPseudoFactoryMethod