public void SyncResolverMethodGenerator_GenerateWithSourceArgumentAndTwoArguments() { // arrange FieldResolverArgumentDescriptor argumentDescriptor1 = new FieldResolverArgumentDescriptor("a", "b", FieldResolverArgumentKind.Source, typeof(GeneratorTestDummy)); FieldResolverArgumentDescriptor argumentDescriptor2 = new FieldResolverArgumentDescriptor("b", "c", FieldResolverArgumentKind.Argument, typeof(string)); FieldResolverArgumentDescriptor argumentDescriptor3 = new FieldResolverArgumentDescriptor("c", "d", FieldResolverArgumentKind.Argument, typeof(int)); Type sourceType = typeof(GeneratorTestDummy); MethodInfo method = typeof(GeneratorTestDummyResolver).GetMethods() .Single(t => t.Name == "GetFoo" && t.GetParameters().Length == 3); FieldResolverDescriptor descriptor = FieldResolverDescriptor .CreateCollectionMethod(new FieldReference("Foo", "bar"), method.ReflectedType, sourceType, method, false, new[] { argumentDescriptor1, argumentDescriptor2, argumentDescriptor3 }); // act StringBuilder source = new StringBuilder(); SyncResolverMethodGenerator generator = new SyncResolverMethodGenerator(); string result = generator.Generate("abc", descriptor); // assert Assert.Equal(Snapshot.Current(), Snapshot.New(result)); }
public void SyncResolverMethodGenerator_GenerateWithSourceArgumentAndTwoArguments() { // arrange Type sourceType = typeof(GeneratorTestDummy); var fieldMember = new FieldMember( "Foo", "bar", GetMethod <GeneratorTestDummyResolver>("GetFoo", 3)); var descriptor = new ResolverDescriptor(sourceType, fieldMember); // act var source = new StringBuilder(); var generator = new SyncResolverMethodGenerator(); string result = generator.Generate("abc", descriptor); // assert Assert.Equal(Snapshot.Current(), Snapshot.New(result)); }
public void SyncResolverMethodGenerator_GenerateWithoutArguments() { // arrange Type sourceType = typeof(GeneratorTestDummy); var fieldMember = new FieldMember( "Foo", "bar", GetMethod <GeneratorTestDummyResolver>("GetFoo", 0)); var descriptor = new ResolverDescriptor(sourceType, fieldMember); // act var source = new StringBuilder(); var generator = new SyncResolverMethodGenerator(); string result = generator.Generate("abc", descriptor); // assert result.Snapshot(); }
public void SyncResolverMethodGenerator_GenerateWithoutArguments() { // arrange Type sourceType = typeof(GeneratorTestDummy); MethodInfo method = typeof(GeneratorTestDummyResolver).GetMethods() .Single(t => t.Name == "GetFoo" && t.GetParameters().Length == 0); FieldResolverDescriptor descriptor = FieldResolverDescriptor .CreateCollectionMethod(new FieldReference("Foo", "bar"), method.ReflectedType, sourceType, method, false, Enumerable.Empty <FieldResolverArgumentDescriptor>()); // act StringBuilder source = new StringBuilder(); SyncResolverMethodGenerator generator = new SyncResolverMethodGenerator(); string result = generator.Generate("abc", descriptor); // assert Assert.Equal(Snapshot.Current(), Snapshot.New(result)); }