/// <summary> /// Setup a generic host. /// </summary> /// <param name="setupConfigurator">The setup configurator.</param> /// <param name="config">The configuration.</param> public static void GenericHost(this ISetupContext setupConfigurator, Action <IGenericHostConfigurator> config) { var spec = new GenericHostSpecification(); config?.Invoke(spec); setupConfigurator.AddHostSpecification(spec); }
public void Given_MultipleComponents_When_Host_Then_NewHostRegisteredWithComponents() { var componentName = "Component"; var component = A.Dummy <Components.IComponent>(); var componentSpecification = A.Dummy <IGenericHostComponentSpecification>(); A.CallTo(() => componentSpecification.Apply(A <IHostBuilder> ._)).Returns(component); A.CallTo(() => componentSpecification.Name).Returns(componentName); var spec = new GenericHostSpecification(); spec.AddComponentSpecification(componentSpecification); var host = spec.Build(); Assert.That(host, Is.Not.Null); Assert.That(host.Components, Does.ContainKey(componentName)); Assert.That(host.Components, Does.ContainValue(component)); }