Example #1
0
                public void Expected_Service()
                {
                    // Arrange
                    var services = new ServiceCollection();
                    var builder  = new CachedOptionsBuilder();

                    builder.AddService(new FakeBuilder());

                    // Act
                    builder.Build(services);
                    ServiceProvider provider = services.BuildServiceProvider();

                    // Assert
                    Assert.Equal("cached service", (string)provider.GetService <object>());
                }
Example #2
0
                public void Without_Removing_PreExisting_Service()
                {
                    // Arrange
                    var services = new ServiceCollection();

                    services.AddScoped <string, string>(provider => "preconditioned");
                    var builder = new CachedOptionsBuilder();

                    builder.AddService(new FakeBuilder());

                    // Act
                    builder.Build(services);

                    // Assert
                    Assert.Equal(2, services.Count);
                }