Last active
August 29, 2015 14:02
-
-
Save b1ff/0677b842aa38b42f3d8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void user_context_should_be_registered_per_dependency_scope() | |
{ | |
EnsurePerScopeLifetime<IUserContext>(); | |
} | |
private static void EnsurePerScopeLifetime<T>() | |
where T: class | |
{ | |
var instance1 = TestBootstrapper.Instance.Get<T>(); | |
var dependencyScope = TestBootstrapper.Instance.DependencyResolver.BeginScope(); | |
var instance2 = dependencyScope.GetService(typeof (T)) as T; | |
instance1.Should().NotBeSameAs(instance2); | |
dependencyScope.GetService(typeof (T)).Should().BeSameAs(instance2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment