Skip to content

Commit

Permalink
GH-153 - missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tpodolak committed Sep 11, 2022
1 parent 9f8e892 commit cc80645
Show file tree
Hide file tree
Showing 27 changed files with 308 additions and 229 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace NSubstitute.Analyzers.Tests.CSharp.CodeFixProviderTests.SubstituteForI

public class ForAsGenericMethodTests : SubstituteForInternalMemberCodeFixVerifier
{
public override async Task AppendsInternalsVisibleTo_ToTopLevelCompilationUnit_WhenUsedWithInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_ToTopLevelCompilationUnit_WhenUsedWithInternalClass()
{
var oldSource = @"using NSubstitute;
namespace MyNamespace
Expand Down Expand Up @@ -48,7 +48,7 @@ public void Test()
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass()
{
var oldSource = @"using NSubstitute;
namespace MyNamespace
Expand Down Expand Up @@ -86,7 +86,7 @@ public void Test()
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass_AndArgumentListNotEmpty(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass_AndArgumentListNotEmpty()
{
var oldSource = @"using System.Reflection;
using NSubstitute;
Expand Down Expand Up @@ -127,7 +127,7 @@ public void Test()
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithNestedInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithNestedInternalClass()
{
var oldSource = @"using NSubstitute;
namespace MyNamespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace NSubstitute.Analyzers.Tests.CSharp.CodeFixProviderTests.SubstituteForI

public class ForAsNonGenericMethodTests : SubstituteForInternalMemberCodeFixVerifier
{
public override async Task AppendsInternalsVisibleTo_ToTopLevelCompilationUnit_WhenUsedWithInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_ToTopLevelCompilationUnit_WhenUsedWithInternalClass()
{
var oldSource = @"using NSubstitute;
namespace MyNamespace
Expand All @@ -20,8 +20,6 @@ public class FooTests
public void Test()
{
var substitute = Substitute.For(new[] {typeof(Foo)}, null);
var otherSubstitute = Substitute.For(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = Substitute.For(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}
Expand All @@ -43,16 +41,14 @@ public class FooTests
public void Test()
{
var substitute = Substitute.For(new[] {typeof(Foo)}, null);
var otherSubstitute = Substitute.For(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = Substitute.For(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}
}";
await VerifyFix(oldSource, newSource, diagnosticIndex: diagnosticIndex);
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass()
{
var oldSource = @"using NSubstitute;
namespace MyNamespace
Expand All @@ -66,8 +62,6 @@ public class FooTests
public void Test()
{
var substitute = Substitute.For(new[] {typeof(Foo)}, null);
var otherSubstitute = Substitute.For(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = Substitute.For(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}";
Expand All @@ -86,15 +80,13 @@ public class FooTests
public void Test()
{
var substitute = Substitute.For(new[] {typeof(Foo)}, null);
var otherSubstitute = Substitute.For(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = Substitute.For(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}";
await VerifyFix(oldSource, newSource, diagnosticIndex: diagnosticIndex);
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass_AndArgumentListNotEmpty(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass_AndArgumentListNotEmpty()
{
var oldSource = @"using System.Reflection;
using NSubstitute;
Expand All @@ -110,8 +102,6 @@ public class FooTests
public void Test()
{
var substitute = Substitute.For(new[] {typeof(Foo)}, null);
var otherSubstitute = Substitute.For(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = Substitute.For(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}";
Expand All @@ -131,15 +121,13 @@ public class FooTests
public void Test()
{
var substitute = Substitute.For(new[] {typeof(Foo)}, null);
var otherSubstitute = Substitute.For(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = Substitute.For(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}";
await VerifyFix(oldSource, newSource, diagnosticIndex: diagnosticIndex);
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithNestedInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithNestedInternalClass()
{
var oldSource = @"using NSubstitute;
namespace MyNamespace
Expand All @@ -157,8 +145,6 @@ public class FooTests
public void Test()
{
var substitute = Substitute.For(new[] {typeof(Foo.Bar)}, null);
var otherSubstitute = Substitute.For(typesToProxy: new[] {typeof(Foo.Bar)}, constructorArguments: null);
var yetAnotherSubstitute = Substitute.For(constructorArguments: null, typesToProxy: new[] {typeof(Foo.Bar)});
}
}
}";
Expand All @@ -181,12 +167,10 @@ public class FooTests
public void Test()
{
var substitute = Substitute.For(new[] {typeof(Foo.Bar)}, null);
var otherSubstitute = Substitute.For(typesToProxy: new[] {typeof(Foo.Bar)}, constructorArguments: null);
var yetAnotherSubstitute = Substitute.For(constructorArguments: null, typesToProxy: new[] {typeof(Foo.Bar)});
}
}
}";
await VerifyFix(oldSource, newSource, diagnosticIndex: diagnosticIndex);
await VerifyFix(oldSource, newSource);
}

public override async Task DoesNot_AppendsInternalsVisibleTo_WhenUsedWithPublicClass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace NSubstitute.Analyzers.Tests.CSharp.CodeFixProviderTests.SubstituteForI

public class ForPartsOfMethodTests : SubstituteForInternalMemberCodeFixVerifier
{
public override async Task AppendsInternalsVisibleTo_ToTopLevelCompilationUnit_WhenUsedWithInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_ToTopLevelCompilationUnit_WhenUsedWithInternalClass()
{
var oldSource = @"using NSubstitute;
namespace MyNamespace
Expand Down Expand Up @@ -48,7 +48,7 @@ public void Test()
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass()
{
var oldSource = @"using NSubstitute;
namespace MyNamespace
Expand Down Expand Up @@ -86,8 +86,7 @@ public void Test()
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass_AndArgumentListNotEmpty(
int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass_AndArgumentListNotEmpty()
{
var oldSource = @"using System.Reflection;
using NSubstitute;
Expand Down Expand Up @@ -128,7 +127,7 @@ public void Test()
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithNestedInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithNestedInternalClass()
{
var oldSource = @"using NSubstitute;
namespace MyNamespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace NSubstitute.Analyzers.Tests.CSharp.CodeFixProviderTests.SubstituteForI

public class SubstituteFactoryCreateMethodTests : SubstituteForInternalMemberCodeFixVerifier
{
public override async Task AppendsInternalsVisibleTo_ToTopLevelCompilationUnit_WhenUsedWithInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_ToTopLevelCompilationUnit_WhenUsedWithInternalClass()
{
var oldSource = @"using NSubstitute.Core;
namespace MyNamespace
Expand All @@ -20,8 +20,6 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.Create(new[] {typeof(Foo)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}
Expand All @@ -43,16 +41,14 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.Create(new[] {typeof(Foo)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}
}";
await VerifyFix(oldSource, newSource, diagnosticIndex: diagnosticIndex);
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass()
{
var oldSource = @"using NSubstitute.Core;
namespace MyNamespace
Expand Down Expand Up @@ -90,7 +86,7 @@ public void Test()
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass_AndArgumentListNotEmpty(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass_AndArgumentListNotEmpty()
{
var oldSource = @"using System.Reflection;
using NSubstitute.Core;
Expand All @@ -106,8 +102,6 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.Create(new[] {typeof(Foo)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}";
Expand All @@ -127,15 +121,13 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.Create(new[] {typeof(Foo)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}";
await VerifyFix(oldSource, newSource, diagnosticIndex: diagnosticIndex);
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithNestedInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithNestedInternalClass()
{
var oldSource = @"using NSubstitute.Core;
namespace MyNamespace
Expand All @@ -153,8 +145,6 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.Create(new[] {typeof(Foo.Bar)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(typesToProxy: new[] {typeof(Foo.Bar)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(constructorArguments: null, typesToProxy: new[] {typeof(Foo.Bar)});
}
}
}";
Expand All @@ -177,12 +167,10 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.Create(new[] {typeof(Foo.Bar)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(typesToProxy: new[] {typeof(Foo.Bar)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.Create(constructorArguments: null, typesToProxy: new[] {typeof(Foo.Bar)});
}
}
}";
await VerifyFix(oldSource, newSource, diagnosticIndex: diagnosticIndex);
await VerifyFix(oldSource, newSource);
}

public override async Task DoesNot_AppendsInternalsVisibleTo_WhenUsedWithPublicClass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace NSubstitute.Analyzers.Tests.CSharp.CodeFixProviderTests.SubstituteForI

public class SubstituteFactoryCreatePartialMethodTests : SubstituteForInternalMemberCodeFixVerifier
{
public override async Task AppendsInternalsVisibleTo_ToTopLevelCompilationUnit_WhenUsedWithInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_ToTopLevelCompilationUnit_WhenUsedWithInternalClass()
{
var oldSource = @"using NSubstitute.Core;
namespace MyNamespace
Expand All @@ -20,8 +20,6 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(new[] {typeof(Foo)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}
Expand All @@ -43,16 +41,14 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(new[] {typeof(Foo)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}
}";
await VerifyFix(oldSource, newSource, diagnosticIndex: diagnosticIndex);
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass()
{
var oldSource = @"using NSubstitute.Core;
namespace MyNamespace
Expand All @@ -66,8 +62,6 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(new[] {typeof(Foo)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}";
Expand All @@ -86,15 +80,13 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(new[] {typeof(Foo)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}";
await VerifyFix(oldSource, newSource, diagnosticIndex: diagnosticIndex);
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass_AndArgumentListNotEmpty(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithInternalClass_AndArgumentListNotEmpty()
{
var oldSource = @"using System.Reflection;
using NSubstitute.Core;
Expand All @@ -110,8 +102,6 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(new[] {typeof(Foo)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}";
Expand All @@ -131,15 +121,13 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(new[] {typeof(Foo)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(typesToProxy: new[] {typeof(Foo)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(constructorArguments: null, typesToProxy: new[] {typeof(Foo)});
}
}
}";
await VerifyFix(oldSource, newSource, diagnosticIndex: diagnosticIndex);
await VerifyFix(oldSource, newSource);
}

public override async Task AppendsInternalsVisibleTo_WhenUsedWithNestedInternalClass(int diagnosticIndex)
public override async Task AppendsInternalsVisibleTo_WhenUsedWithNestedInternalClass()
{
var oldSource = @"using NSubstitute.Core;
namespace MyNamespace
Expand All @@ -157,8 +145,6 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(new[] {typeof(Foo.Bar)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(typesToProxy: new[] {typeof(Foo.Bar)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(constructorArguments: null, typesToProxy: new[] {typeof(Foo.Bar)});
}
}
}";
Expand All @@ -181,12 +167,10 @@ public class FooTests
public void Test()
{
var substitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(new[] {typeof(Foo.Bar)}, null);
var otherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(typesToProxy: new[] {typeof(Foo.Bar)}, constructorArguments: null);
var yetAnotherSubstitute = SubstitutionContext.Current.SubstituteFactory.CreatePartial(constructorArguments: null, typesToProxy: new[] {typeof(Foo.Bar)});
}
}
}";
await VerifyFix(oldSource, newSource, diagnosticIndex: diagnosticIndex);
await VerifyFix(oldSource, newSource);
}

public override async Task DoesNot_AppendsInternalsVisibleTo_WhenUsedWithPublicClass()
Expand Down
Loading

0 comments on commit cc80645

Please sign in to comment.