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 }));
        }
Exemple #2
0
        public async Task NoServiceProvider()
        {
            var obj    = new TestMethods();
            var method = new ServiceProviderMethodInfo {
                MethodInfo = obj.GetType().GetMethod("Method1")
            };

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

            Assert.IsTrue(result);
        }
        public async Task WithServiceProvider()
        {
            IServiceCollection services = new ServiceCollection();

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

            var obj    = new TestMethods();
            var method = new ServiceProviderMethodInfo {
                MethodInfo = obj.GetType().GetMethod("GetSpeech")
            };

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

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