Ejemplo n.º 1
0
        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 }));
        }
Ejemplo 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);
        }
Ejemplo 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);
        }