/// <summary>
        /// Specify the arguments to be used when building the host.
        /// The arguments will be translated into a <see cref="CakeHostOptions"/> instance.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <param name="args">The arguments to parse.</param>
        /// <returns>The same <see cref="ICakeHostBuilder"/> instance so that multiple calls can be chained.</returns>
        public static ICakeHostBuilder WithArguments(this ICakeHostBuilder builder, string[] args)
        {
            Guard.ArgumentNotNull(builder, nameof(builder));

            return(builder.ConfigureServices(services =>
                                             services.RegisterInstance(ArgumentParser.Parse(args)).AsSelf().Singleton()));
        }
        /// <summary>
        /// Specify the startup type to be used by the Cake host.
        /// </summary>
        /// <typeparam name="TStartup">The type of the startup.</typeparam>
        /// <param name="builder">The <see cref="ICakeHostBuilder"/> to configure.</param>
        /// <returns>The same <see cref="ICakeHostBuilder"/> instance so that multiple calls can be chained.</returns>
        public static ICakeHostBuilder UseStartup <TStartup>(this ICakeHostBuilder builder)
            where TStartup : IFrostingStartup, new()
        {
            Guard.ArgumentNotNull(builder, nameof(builder));

            var startup = new TStartup();

            return(builder.ConfigureServices(services => startup.Configure(services)));
        }
Ejemplo n.º 3
0
            public void Should_Throw_If_Builder_Reference_Is_Null()
            {
                // Given
                ICakeHostBuilder builder = null;

                // When
                var result = Record.Exception(() => builder.WithArguments(new string[] { }));

                // Then
                AssertEx.IsArgumentNullException(result, "builder");
            }
Ejemplo n.º 4
0
            public void Should_Throw_If_Builder_Reference_Is_Null()
            {
                // Given
                ICakeHostBuilder builder = null;

                // When
                var result = Record.Exception(() => builder.UseStartup <DummyStartup>());

                // Then
                AssertEx.IsArgumentNullException(result, "builder");
            }