public Foo(FooType type, FooDetail detail) : this() { Ensure.NotNull(detail, nameof(detail)); Type = type; Detail = detail; }
public void TestEnum() { const FooType e = FooType.Jarjar; Serializer serpent = new Serializer(); var ser = strip_header(serpent.Serialize(e)); Assert.Equal("'Jarjar'", S(ser)); }
public void TestEnum() { FooType e = FooType.Jarjar; Serializer serpent = new Serializer(); byte[] ser = strip_header(serpent.Serialize(e)); Assert.AreEqual("'Jarjar'", S(ser)); }
public void ObjectTypeWithDynamicField_TypeDeclaOrderShouldNotMatter() { // act FooType fooType = CreateType(new FooType()); // assert Assert.True(fooType.Fields.TryGetField("test", out ObjectField field)); Assert.IsType <ListType>(field.Type); Assert.IsType <StringType>(((ListType)field.Type).ElementType); }
public void AddRootType_ObjTypeDuplicateQueryType_ArgumentException() { // arrange var fooType = new FooType(); // act Action action = () => SchemaBuilder.New() .AddRootType(fooType, OperationType.Query) .AddRootType(fooType, OperationType.Query); // assert Assert.Throws <ArgumentException>(action); }
public void EnumTypeExtension_AddValue() { // arrange // act ISchema schema = SchemaBuilder.New() .AddQueryType<DummyQuery>() .AddType<FooType>() .AddType<FooTypeExtension>() .Create(); // assert FooType type = schema.GetType<FooType>("Foo"); Assert.True(type.TryGetValue("_QUOX", out _)); }
public void AddRootType_ObjTypeQueryType_SchemaIsCreated() { // arrange var fooType = new FooType(); // act ISchema schema = SchemaBuilder.New() .AddRootType(fooType, OperationType.Query) .Create(); // assert ObjectType queryType = schema.GetType <ObjectType>("Foo"); Assert.NotNull(queryType); Assert.Equal(queryType, schema.QueryType); Assert.Equal(fooType, schema.QueryType); }
public void UnionTypeExtension_AddType() { // arrange // act ISchema schema = SchemaBuilder.New() .AddQueryType <QueryType>() .AddType <FooType>() .AddType <FooTypeExtension>() .Create(); // assert FooType type = schema.GetType <FooType>("Foo"); Assert.Collection(type.Types.Values, t => Assert.IsType <AType>(t), t => Assert.IsType <BType>(t)); }
public void EnumTypeExtension_SetDirectiveOnType() { // arrange // act ISchema schema = SchemaBuilder.New() .AddQueryType <DummyQuery>() .AddType <FooType>() .AddType(new EnumTypeExtension(d => d .Name("Foo") .Directive("dummy"))) .AddDirectiveType <DummyDirective>() .Create(); // assert FooType type = schema.GetType <FooType>("Foo"); Assert.Equal(1, type.Directives["dummy"].Count()); }
public void AddRootType_ObjTypeSubscriptionType_SchemaIsCreated() { // arrange var fooType = new FooType(); var barType = new BarType(); // act ISchema schema = SchemaBuilder.New() .AddRootType(fooType, OperationType.Query) .AddRootType(barType, OperationType.Subscription) .Create(); // assert ObjectType subscriptionType = schema.GetType <ObjectType>("Bar"); Assert.NotNull(subscriptionType); Assert.Equal(subscriptionType, schema.SubscriptionType); Assert.Equal(barType, schema.SubscriptionType); }
public void UnionTypeExtension_CopyDependencies_ToType() { // arrange // act ISchema schema = SchemaBuilder.New() .AddQueryType <QueryType>() .AddType <FooType>() .AddType(new UnionTypeExtension(d => d .Name("Foo") .Type <BType>())) .Create(); // assert FooType type = schema.GetType <FooType>("Foo"); Assert.Collection(type.Types.Values, t => Assert.IsType <AType>(t), t => Assert.IsType <BType>(t)); }
public Foo(FooType type) { this.type = type; }
// Option 1: forced via constructor public Foo(FooType type) { this.Type = type; }
// A here is same class as in Bar definition public D Init(TestInterface a, FooType footype) { return(null); }