public void CurrentGenerator_WithNestedAmbientGenerators_ShouldReturnInnermostGenerator() { var outerGenerator = new NineIdGenerator(); var innerGenerator = new EightIdGenerator(); IDistributedIdGenerator result; using (new DistributedIdGeneratorScope(outerGenerator)) using (new DistributedIdGeneratorScope(innerGenerator)) result = DistributedIdGeneratorScope.CurrentGenerator; Assert.Equal(innerGenerator, result); }
public void CurrentGenerator_WithAmbientGeneratorAfterDisposingInnerOne_ShouldReturnExpectedGenerator() { var outerGenerator = new NineIdGenerator(); var innerGenerator = new EightIdGenerator(); IDistributedIdGenerator result; using (new DistributedIdGeneratorScope(outerGenerator)) { using (new DistributedIdGeneratorScope(innerGenerator)) { } result = DistributedIdGeneratorScope.CurrentGenerator; } Assert.Equal(outerGenerator, result); }