public void AllowsCreatingContextWithoutSettingAccessor() { // Arrange var services = new ServiceCollection() .AddOptions() .BuildServiceProvider(); var contextFactory = new DefaultProtoContextFactory(services); // Act & Assert var context = contextFactory.Create(new FeatureCollection()); contextFactory.Dispose(context); }
public void DisposeProtoContextSetsProtoContextAccessorToNull() { // Arrange var services = new ServiceCollection() .AddOptions() .AddProtoContextAccessor() .BuildServiceProvider(); var accessor = services.GetRequiredService <IProtoContextAccessor>(); var contextFactory = new DefaultProtoContextFactory(services); // Act var context = contextFactory.Create(new FeatureCollection()); // Assert Assert.Same(context, accessor.ProtoContext); contextFactory.Dispose(context); Assert.Null(accessor.ProtoContext); }