public async Task NoServiceProvider()
        {
            var obj    = new TestMethods();
            var method = new ServiceProviderMethodInfo {
                MethodInfo = obj.GetType().GetMethod("Method1")
            };

            Assert.IsNotNull(method, "needed method");
            await Assert.ThrowsExceptionAsync <NullReferenceException>(async() => await ServiceProviderMethodCaller.CallMethodTryAsync(obj, method, new object[] { 123 }));
        }
Exemplo n.º 2
0
        public async Task NoServiceProvider()
        {
            var obj    = new TestMethods();
            var method = obj.GetType().GetMethod("Method1");

            Assert.IsNotNull(method, "needed method");
            var result = (bool)await ServiceProviderMethodCaller.CallMethodTryAsync(obj, method, new object[] { 123 });

            Assert.IsTrue(result);
        }
Exemplo n.º 3
0
        public async Task WithServiceProvider()
        {
            IServiceCollection services = new ServiceCollection();

            services.AddSingleton <ISpeak, Dog>();
            Csla.ApplicationContext.DefaultServiceProvider = services.BuildServiceProvider();

            var obj    = new TestMethods();
            var method = obj.GetType().GetMethod("GetSpeech");

            Assert.IsNotNull(method, "needed method");
            var result = (string)await ServiceProviderMethodCaller.CallMethodTryAsync(obj, method, new object[] { 123 });

            Assert.AreEqual("Bark", result);
        }