public void get_response_type_negative() { var method = ReflectionHelper.GetMethod <IUserService>(x => x.Create(null)); GeneratedServiceType.DetermineResponseType(method) .ShouldBeNull(); }
public void get_response_type_positive() { var method = ReflectionHelper.GetMethod <IUserService>(x => x.GetUser(null)); GeneratedServiceType.DetermineResponseType(method) .ShouldBe(typeof(User)); }
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); }
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); }
public void get_input_type_negative() { var method = ReflectionHelper.GetMethod <IUserService>(x => x.GetUser(null)); GeneratedServiceType.DetermineRequestType(method).ShouldBeNull(); }
public void get_input_type_positive() { var method = ReflectionHelper.GetMethod <IUserService>(x => x.Create(null)); GeneratedServiceType.DetermineRequestType(method).ShouldBe(typeof(User)); }