Permalink
Browse files

Test added to verify that I don't forget to pick a valid test name.

  • Loading branch information...
dotnetjunkie committed Apr 14, 2018
1 parent 2f447d4 commit 5e71c5cc8db714a90ffb6aaf775afbcceec00274
@@ -61,7 +61,7 @@ public new void EndRequest()
public class HttpContextScopeTests
{
[TestMethod]
public void MethodUnderTest_Scenario_Behavior()
public void ctor_Always_SetsHttpContextCurrentForCurrentThread()
{
// Arrange
Assert.IsNull(HttpContext.Current, "Test setup failed");
@@ -72,12 +72,25 @@ public void MethodUnderTest_Scenario_Behavior()
// Assert
Assert.IsNotNull(HttpContext.Current, "HttpContext.Current should be set.");
}
}
[TestMethod]
public void Dispose_Always_ClearsHttpContextCurrentForCurrentThread()
{
// Arrange
Assert.IsNull(HttpContext.Current, "Test setup failed");
// Act
using (new HttpContextScope())
{
}
// Assert
Assert.IsNull(HttpContext.Current, "HttpContext.Current should be null after disposing.");
}
[TestMethod]
public void MethodUnderTest_Scenario_Behavior2()
public void ctor_Never_SetsHttpContextCurrentOnDifferentThread()
{
// Arrange
Assert.IsNull(HttpContext.Current, "Test setup failed");
@@ -2474,7 +2474,7 @@ public void RegisterDecorator_WithConstructedGenericServiceType_ThrowsExpectedMe
}
[TestMethod]
public void MethodUnderTest_Scenario_Behaviorx()
public void InjectedScopeDecorateeFactory_WhenSuppliedWithAScopeInstance_CreatesScopedInstancesBasedOnThatScope()
{
// Arrange
var container = ContainerFactory.New();
@@ -1086,7 +1086,7 @@ public void GetInstance_ResolvingAnInstanceDependingOnScopeWithoutAnActiveScopeA
}
[TestMethod]
public void MethodUnderTest_Scenario_Behavior()
public void Verify_RegistrationDependingOnScopeWithDefaultScopedLifestyleSet_Succeeds()
{
var container = ContainerFactory.New();
container.Options.DefaultScopedLifestyle = new ThreadScopedLifestyle();
@@ -0,0 +1,29 @@
namespace SimpleInjector.Tests.Unit
{
using System.Linq;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestTests
{
[TestMethod]
public void VerifyIfAllTestMethodsHaveAValidName()
{
var invalidlyNamedTestMethods =
from type in this.GetType().Assembly.GetTypes()
from m in type.GetMethods()
where m.GetCustomAttributes<TestMethodAttribute>(true).Any() && (
m.Name.Contains("MethodUnderTest")
|| m.Name.Contains("_Scenario")
|| m.Name.Contains("_Behavior"))
select m;
var method = invalidlyNamedTestMethods.FirstOrDefault();
// Act
Assert.IsNull(method,
$"There is a test method, named {method?.Name} in class {method?.DeclaringType?.Name} that is not a good test name.");
}
}
}

0 comments on commit 5e71c5c

Please sign in to comment.