Skip to content

Commit

Permalink
Merge pull request #975 from medmondson/MissingTests
Browse files Browse the repository at this point in the history
Added missing tests
  • Loading branch information
thomaslevesque committed Feb 18, 2017
2 parents 21f1b40 + 4f368c1 commit 1fd0e2d
Show file tree
Hide file tree
Showing 2 changed files with 367 additions and 0 deletions.
Expand Up @@ -192,6 +192,66 @@ interface IFoo { int Bar(); }
});
}

[Fact]
[UsingCulture("en-US")] // so that the message is in the expected language regardless of the OS language
public void Diagnostic_Should_Have_The_Correct_Call_Description_If_Triggered_On_CallsTo()
{
var test = @"using FakeItEasy;
namespace TheNamespace
{
class TheClass
{
void Test()
{
var fake = new Fake<IFoo>();
fake.CallsTo(x => x.Bar());
}
}
interface IFoo { int Bar(); }
}";

this.VerifyCSharpDiagnostic(
test,
new DiagnosticResult
{
Id = DiagnosticDefinitions.UnusedCallSpecification.Id,
Message =
"Unused call specification 'fake.CallsTo(x => x.Bar())'; did you forget to configure or assert the call?",
Severity = DiagnosticSeverity.Error,
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 9, 13) }
});
}

[Fact]
[UsingCulture("en-US")] // so that the message is in the expected language regardless of the OS language
public void Diagnostic_Should_Have_The_Correct_Call_Description_If_Triggered_On_AnyCall()
{
var test = @"using FakeItEasy;
namespace TheNamespace
{
class TheClass
{
void Test()
{
var fake = new Fake<IFoo>();
fake.AnyCall();
}
}
interface IFoo { int Bar(); }
}";

this.VerifyCSharpDiagnostic(
test,
new DiagnosticResult
{
Id = DiagnosticDefinitions.UnusedCallSpecification.Id,
Message =
"Unused call specification 'fake.AnyCall()'; did you forget to configure or assert the call?",
Severity = DiagnosticSeverity.Error,
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 9, 13) }
});
}

[Fact]
[UsingCulture("en-US")] // so that the message is in the expected language regardless of the OS language
public void Diagnostic_Should_Have_The_Correct_Call_Description_If_Triggered_On_WithAnyArguments()
Expand Down Expand Up @@ -223,6 +283,37 @@ interface IFoo { int Bar(); }
});
}

[Fact]
[UsingCulture("en-US")] // so that the message is in the expected language regardless of the OS language
public void Diagnostic_Should_Have_The_Correct_Call_Description_If_Triggered_On_WithReturnType_With_No_Return_Specified()
{
var test = @"using FakeItEasy;
namespace TheNamespace
{
class TheClass
{
void Test()
{
var foo = A.Fake<IFoo>();
A.CallTo(foo).WithReturnType<int>();
}
}
interface IFoo { int Bar(); }
}
";

this.VerifyCSharpDiagnostic(
test,
new DiagnosticResult
{
Id = DiagnosticDefinitions.UnusedCallSpecification.Id,
Message =
"Unused call specification 'A.CallTo(foo).WithReturnType<int>()'; did you forget to configure or assert the call?",
Severity = DiagnosticSeverity.Error,
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 9, 13) }
});
}

[Fact]
[UsingCulture("en-US")] // so that the message is in the expected language regardless of the OS language
public void Diagnostic_Should_Have_The_Correct_Call_Description_If_Triggered_On_Where()
Expand Down Expand Up @@ -254,6 +345,67 @@ interface IFoo { int Bar(); }
});
}

[Fact]
[UsingCulture("en-US")] // so that the message is in the expected language regardless of the OS language
public void Diagnostic_Should_Have_The_Correct_Call_Description_If_Triggered_On_Where_With_No_Return_Type()
{
var test = @"using FakeItEasy;
namespace TheNamespace
{
class TheClass
{
void Test()
{
var fake = A.Fake<IFoo>();
A.CallTo(fake).Where(call => true, output => new object());
}
}
interface IFoo { int Bar(); }
}
";

this.VerifyCSharpDiagnostic(
test,
new DiagnosticResult
{
Id = DiagnosticDefinitions.UnusedCallSpecification.Id,
Message =
"Unused call specification 'A.CallTo(fake).Where(call => true, output => new object())'; did you forget to configure or assert the call?",
Severity = DiagnosticSeverity.Error,
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 9, 13) }
});
}

[Fact]
[UsingCulture("en-US")] // so that the message is in the expected language regardless of the OS language
public void Diagnostic_Should_Have_The_Correct_Call_Description_If_Triggered_On_WhenArgumentsMatch_With_No_Return_Specified()
{
var test = @"using FakeItEasy;
namespace TheNamespace
{
class TheClass
{
void Test()
{
var foo = A.Fake<IFoo>();
A.CallTo(foo).WhenArgumentsMatch(x => true);
}
}
interface IFoo { int Bar(); }
}";

this.VerifyCSharpDiagnostic(
test,
new DiagnosticResult
{
Id = DiagnosticDefinitions.UnusedCallSpecification.Id,
Message =
"Unused call specification 'A.CallTo(foo).WhenArgumentsMatch(x => true)'; did you forget to configure or assert the call?",
Severity = DiagnosticSeverity.Error,
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 9, 13) }
});
}

[Fact]
[UsingCulture("en-US")] // so that the message is in the expected language regardless of the OS language
public void Diagnostic_Should_Have_The_Correct_Call_Description_If_Triggered_On_CallToSet()
Expand Down Expand Up @@ -286,6 +438,37 @@ interface IFoo { int Bar { get; set; } }
});
}

[Fact]
[UsingCulture("en-US")] // so that the message is in the expected language regardless of the OS language
public void Diagnostic_Should_Have_The_Correct_Call_Description_If_Triggered_On_CallsToSet()
{
var test = @"using FakeItEasy;
namespace TheNamespace
{
class TheClass
{
void Test()
{
var fake = new Fake<IFoo>();
fake.CallsToSet(x => x.Bar());
}
}
interface IFoo { int Bar(); }
}
";

this.VerifyCSharpDiagnostic(
test,
new DiagnosticResult
{
Id = DiagnosticDefinitions.UnusedCallSpecification.Id,
Message =
"Unused call specification 'fake.CallsToSet(x => x.Bar())'; did you forget to configure or assert the call?",
Severity = DiagnosticSeverity.Error,
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 9, 13) }
});
}

[Fact]
[UsingCulture("en-US")] // so that the message is in the expected language regardless of the OS language
public void Diagnostic_Should_Have_The_Correct_Call_Description_If_Triggered_On_CallToSet_To_Value()
Expand Down

0 comments on commit 1fd0e2d

Please sign in to comment.