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 CreateProtoContextSetsProtoContextAccessor() { // 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); }
public void SetsDefaultPropertiesOnProtoContext() { // Arrange var services = new ServiceCollection() .AddOptions() .BuildServiceProvider(); var contextFactory = new DefaultProtoContextFactory(services); // Act & Assert var context = contextFactory.Create(new FeatureCollection()) as DefaultProtoContext; Assert.NotNull(context); Assert.NotNull(context.FormOptions); Assert.NotNull(context.ServiceScopeFactory); Assert.Same(services.GetRequiredService <IServiceScopeFactory>(), context.ServiceScopeFactory); }