diff --git a/src/Tests/DecoratorTests.cs b/src/Tests/DecoratorTests.cs index 1748085..f154b61 100644 --- a/src/Tests/DecoratorTests.cs +++ b/src/Tests/DecoratorTests.cs @@ -38,17 +38,19 @@ public void ShouldReturnInstance_ResultsShouldBeWrappedAndDifferent() string result1; string result2; - using (_provider.CreateScope()) + using (var scope = _provider.CreateScope()) { - IScopedDecorator decorator = _provider.GetRequiredService(); + IScopedDecorator decorator = scope.ServiceProvider.GetRequiredService(); result1 = decorator.DecoratedResult; + string result1Again = decorator.DecoratedResult; + + Assert.Equal(result1, result1Again); } - using (_provider.CreateScope()) + using (var scope = _provider.CreateScope()) { - IScopedDecorator decorator = _provider.GetRequiredService(); + IScopedDecorator decorator = scope.ServiceProvider.GetRequiredService(); result2 = decorator.DecoratedResult; - } Assert.NotEqual(result1, result2); @@ -97,13 +99,14 @@ public interface IScopedDecorator public class ScopedDecorator : IScopedDecorator { private readonly IScopedDecorator _decoratedInstance; + private readonly Guid _key = Guid.NewGuid(); public ScopedDecorator(IScopedDecorator decoratedInstance) { _decoratedInstance = decoratedInstance; } - public string DecoratedResult => $"{Guid.NewGuid()} " + _decoratedInstance.DecoratedResult; + public string DecoratedResult => $"{_key} " + _decoratedInstance.DecoratedResult; } public class ScopeDecoratedClass : IScopedDecorator