Пример #1
0
        public void get_response_type_negative()
        {
            var method = ReflectionHelper.GetMethod <IUserService>(x => x.Create(null));

            GeneratedServiceType.DetermineResponseType(method)
            .ShouldBeNull();
        }
Пример #2
0
        public void get_response_type_positive()
        {
            var method = ReflectionHelper.GetMethod <IUserService>(x => x.GetUser(null));

            GeneratedServiceType.DetermineResponseType(method)
            .ShouldBe(typeof(User));
        }
Пример #3
0
        public void try_it_out()
        {
            var container = new Container(x =>
            {
                x.AddSingleton(Substitute.For <IConfiguration>());
                x.AddSingleton(Substitute.For <IHttpClientFactory>());
            });

            var serviceType = GeneratedServiceType.For(typeof(IUserService), container);

            _output.WriteLine(serviceType.SourceCode);
        }
Пример #4
0
        public ServiceFamily Build(Type type, ServiceGraph serviceGraph)
        {
            if (type.GetMethods().Any(x => x.HasAttribute <PathAttribute>()))
            {
                var generatedAssembly = new GeneratedAssembly(new GenerationRules("LamarRest"));
                var generatedType     = new GeneratedServiceType(generatedAssembly, type);

                var container = (IContainer)serviceGraph.RootScope;

                container.CompileWithInlineServices(generatedAssembly);

                return(new ServiceFamily(type, new IDecoratorPolicy[0], new ConstructorInstance(type, generatedType.CompiledType, ServiceLifetime.Singleton)));
            }

            return(null);
        }
Пример #5
0
        public void get_input_type_negative()
        {
            var method = ReflectionHelper.GetMethod <IUserService>(x => x.GetUser(null));

            GeneratedServiceType.DetermineRequestType(method).ShouldBeNull();
        }
Пример #6
0
        public void get_input_type_positive()
        {
            var method = ReflectionHelper.GetMethod <IUserService>(x => x.Create(null));

            GeneratedServiceType.DetermineRequestType(method).ShouldBe(typeof(User));
        }