public void IsConfigured_returns_true_if_any_provider_extensions_have_been_added() { var optionsBuilder = new DbContextOptionsBuilder(); Assert.False(optionsBuilder.IsConfigured); var extension = new FakeDbContextOptionsExtension2(); ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension); Assert.True(optionsBuilder.IsConfigured); Assert.False(extension.AppliedServices); }
public void Extensions_can_be_added_to_options() { var optionsBuilder = new DbContextOptionsBuilder(); Assert.Null(optionsBuilder.Options.FindExtension <FakeDbContextOptionsExtension1>()); Assert.Empty(optionsBuilder.Options.Extensions); var extension1 = new FakeDbContextOptionsExtension1(); var extension2 = new FakeDbContextOptionsExtension2(); ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension1); ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension2); Assert.Equal(2, optionsBuilder.Options.Extensions.Count()); Assert.Contains(extension1, optionsBuilder.Options.Extensions); Assert.Contains(extension2, optionsBuilder.Options.Extensions); Assert.Same(extension1, optionsBuilder.Options.FindExtension <FakeDbContextOptionsExtension1>()); Assert.Same(extension2, optionsBuilder.Options.FindExtension <FakeDbContextOptionsExtension2>()); }
public void Extensions_can_be_added_to_options() { var optionsBuilder = new DbContextOptionsBuilder(); Assert.Null(optionsBuilder.Options.FindExtension<FakeDbContextOptionsExtension1>()); Assert.Empty(optionsBuilder.Options.Extensions); var extension1 = new FakeDbContextOptionsExtension1(); var extension2 = new FakeDbContextOptionsExtension2(); ((IOptionsBuilderExtender)optionsBuilder).AddOrUpdateExtension(extension1); ((IOptionsBuilderExtender)optionsBuilder).AddOrUpdateExtension(extension2); Assert.Equal(2, optionsBuilder.Options.Extensions.Count()); Assert.Contains(extension1, optionsBuilder.Options.Extensions); Assert.Contains(extension2, optionsBuilder.Options.Extensions); Assert.Same(extension1, optionsBuilder.Options.FindExtension<FakeDbContextOptionsExtension1>()); Assert.Same(extension2, optionsBuilder.Options.FindExtension<FakeDbContextOptionsExtension2>()); }