Ejemplo n.º 1
0
        public async Task Test()
        {
            var prog      = new MyProg();
            var activator = new FakeActivator();

            activator.Add(prog);
            var logger = new MyLogger();
            var host   = TestHelpers.NewJobHost <MyProg>(activator, logger);

            // Invoke with method Info
            var method = prog.GetType().GetMethod("Test");

            host.Call(method);
            prog.AssertValid();
            logger.AssertValid();

            // Invoke with new name.
            await host.CallAsync(MyProg.NewName);

            prog.AssertValid();
            logger.AssertValid();

            // Invoke with original name fails
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await host.CallAsync("Test"));

            await Assert.ThrowsAsync <InvalidOperationException>(async() => await host.CallAsync("MyProg.Test"));
        }
Ejemplo n.º 2
0
        public async Task Test()
        {
            var prog      = new MyProg();
            var activator = new FakeActivator();

            activator.Add(prog);
            var logger = new MyLogger();

            IHost host = new HostBuilder()
                         .ConfigureDefaultTestHost <MyProg>(_ => { }, activator: activator)
                         .ConfigureServices(services =>
            {
                services.AddSingleton <IAsyncCollector <FunctionInstanceLogEntry> >(logger);
            })
                         .Build();

            var jobHost = host.GetJobHost <MyProg>();

            // Invoke with method Info
            var method = prog.GetType().GetMethod("Test");
            await jobHost.CallAsync(method);

            prog.AssertValid();
            logger.AssertValid();

            // Invoke with new name.
            await jobHost.CallAsync(MyProg.NewName);

            prog.AssertValid();
            logger.AssertValid();

            // Invoke with original name fails
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await jobHost.CallAsync("Test"));

            await Assert.ThrowsAsync <InvalidOperationException>(async() => await jobHost.CallAsync("MyProg.Test"));
        }