Ejemplo n.º 1
0
        public void get_response_type_negative()
        {
            var method = ReflectionHelper.GetMethod <IUserService>(x => x.Create(null));

            GeneratedServiceType.DetermineResponseType(method)
            .ShouldBeNull();
        }
Ejemplo n.º 2
0
        public void get_response_type_positive()
        {
            var method = ReflectionHelper.GetMethod <IUserService>(x => x.GetUser(null));

            GeneratedServiceType.DetermineResponseType(method)
            .ShouldBe(typeof(User));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
        public void get_input_type_negative()
        {
            var method = ReflectionHelper.GetMethod <IUserService>(x => x.GetUser(null));

            GeneratedServiceType.DetermineRequestType(method).ShouldBeNull();
        }
Ejemplo n.º 6
0
        public void get_input_type_positive()
        {
            var method = ReflectionHelper.GetMethod <IUserService>(x => x.Create(null));

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