public void SyntaxTypeReference_GetHashCode_NotEquals( string typeName, TypeContext context, bool?isTypeNullable, bool?isElementTypeNullable) { // arrange var x = new SyntaxTypeReference( new NamedTypeNode("abc"), TypeContext.Input, true, false); var y = new SyntaxTypeReference( new NamedTypeNode(typeName), context, isTypeNullable, isElementTypeNullable); // act int xhash = x.GetHashCode(); int yhash = y.GetHashCode(); // assert Assert.NotEqual(xhash, yhash); }
public void Object_Equals_Scope_Different() { // arrange SyntaxTypeReference x = TypeReference.Create( "Foo", TypeContext.None, scope: "a"); SyntaxTypeReference y = TypeReference.Create( "Foo", TypeContext.Output, scope: "a"); SyntaxTypeReference z = TypeReference.Create( "Foo", TypeContext.Input); // act var xy = x.Equals((object)y); var xz = x.Equals((object)z); var yz = y.Equals((object)z); // assert Assert.True(xy); Assert.False(xz); Assert.False(yz); }
public void SyntaxTypeReference_GetHashCode() { // arrange SyntaxTypeReference x = TypeReference.Create( "Foo", TypeContext.None, scope: "foo"); SyntaxTypeReference y = TypeReference.Create( "Foo", TypeContext.None, scope: "foo"); SyntaxTypeReference z = TypeReference.Create( "Foo", TypeContext.Input); // act var xh = x.GetHashCode(); var yh = y.GetHashCode(); var zh = z.GetHashCode(); // assert Assert.Equal(xh, yh); Assert.NotEqual(xh, zh); }
public void Object_Equals_Nullability() { // arrange SyntaxTypeReference x = TypeReference.Create( "Foo", TypeContext.None, nullable: new bool[] { true, false }); SyntaxTypeReference y = TypeReference.Create( "Foo", TypeContext.Output, nullable: new bool[] { false, false }); SyntaxTypeReference z = TypeReference.Create( "Foo", TypeContext.Input, nullable: new bool[] { true, false }); // act var xy = x.Equals((object)y); var xz = x.Equals((object)z); var yz = y.Equals((object)z); // assert Assert.False(xy); Assert.True(xz); Assert.False(yz); }
public void ISyntaxTypeReference_Equals_True( string typeName, TypeContext context, bool?isTypeNullable, bool?isElementTypeNullable) { // arrange var x = new SyntaxTypeReference( new NamedTypeNode(typeName), context, isTypeNullable, isElementTypeNullable); ISyntaxTypeReference y = new SyntaxTypeReference( new NamedTypeNode(typeName), context, isTypeNullable, isElementTypeNullable); // act bool result = x.Equals(y); // assert Assert.True(result); }
public void SyntaxTypeReference_Equals_Context_None_Does_Not_Matter() { // arrange SyntaxTypeReference x = TypeReference.Create( "Foo", TypeContext.None); SyntaxTypeReference y = TypeReference.Create( "Foo", TypeContext.Output); SyntaxTypeReference z = TypeReference.Create( "Foo", TypeContext.Input); // act var xy = x.Equals(y); var xz = x.Equals(z); var yz = y.Equals(z); // assert Assert.True(xy); Assert.True(xz); Assert.False(yz); }
public void SyntaxTypeReference_RewriteType_Type_Is_The_Same() { // arrange SyntaxTypeReference typeReference = TypeReference.Create("Foo"); // act SyntaxTypeReference rewritten = typeReference.Rewrite(); // assert Assert.Equal(typeReference, rewritten); }
public void ITypeReference_Equals_To_SyntaxTypeRef() { // arrange SyntaxTypeReference x = TypeReference.Create( "Foo", TypeContext.None); // act var xx = x.Equals(TypeReference.Create(_typeInspector.GetType(typeof(int)))); // assert Assert.False(xx); }
public void SyntaxTypeReference_ToString() { // arrange SyntaxTypeReference typeReference = TypeReference.Create( "Foo", TypeContext.Input); // act var result = typeReference.ToString(); // assert Assert.Equal("Input: Foo", result); }
public void SyntaxTypeReference_Equals_To_Null() { // arrange SyntaxTypeReference x = TypeReference.Create( "Foo", TypeContext.None); // act var result = x.Equals((SyntaxTypeReference)null); // assert Assert.False(result); }
public void Object_Equals_To_Object() { // arrange SyntaxTypeReference x = TypeReference.Create( "Foo", TypeContext.None); // act var xx = x.Equals(new object()); // assert Assert.False(xx); }
public void SyntaxTypeReference_Equals_To_Same() { // arrange SyntaxTypeReference x = TypeReference.Create( "Foo", TypeContext.None); // act var xx = x.Equals((SyntaxTypeReference)x); // assert Assert.True(xx); }
public void SyntaxTypeReference_With_Type_Null() { // arrange SyntaxTypeReference typeReference1 = TypeReference.Create( "Foo", TypeContext.Input, scope: "foo"); // act Action action = () => typeReference1.With(null); // assert Assert.Throws <ArgumentNullException>(action); }
public void TypeReference_Create_With_Name() { // arrange // act SyntaxTypeReference typeReference = TypeReference.Create( "Foo", TypeContext.Input, scope: "foo"); // assert Assert.Equal("Foo", typeReference.Type.NamedType().Name.Value); Assert.Equal(TypeContext.Input, typeReference.Context); Assert.Equal("foo", typeReference.Scope); }
public void ISyntaxTypeReference_RefEquals_True() { // arrange var x = new SyntaxTypeReference( new NamedTypeNode("abc"), TypeContext.Input, true, false); // act bool result = x.Equals((ISyntaxTypeReference)x); // assert Assert.True(result); }
public void SyntaxTypeReference_RewriteType_NonNullToNullable() { // arrange SyntaxTypeReference typeReference = TypeReference.Create( new NonNullTypeNode(new NamedTypeNode("Foo")), nullable: new bool[] { true }); // act SyntaxTypeReference rewritten = typeReference.Rewrite(); // assert Assert.Equal("Foo", Assert.IsType <NamedTypeNode>( rewritten.Type).Name.Value); }
public void Object_NullEquals_False() { // arrange var x = new SyntaxTypeReference( new NamedTypeNode("abc"), TypeContext.Input, true, false); // act bool result = x.Equals((object)null); // assert Assert.False(result); }
public void ClrTypeReference_ToString() { // arrange var typeReference = new SyntaxTypeReference( new NonNullTypeNode(new NamedTypeNode("abc")), TypeContext.Input, true, false); // act string result = typeReference.ToString(); // assert Assert.Equal("Input: abc!", result); }
public void TypeReference_Create() { // arrange var namedType = new NamedTypeNode("Foo"); // act SyntaxTypeReference typeReference = TypeReference.Create( namedType, TypeContext.Input, scope: "foo"); // assert Assert.Equal(namedType, typeReference.Type); Assert.Equal(TypeContext.Input, typeReference.Context); Assert.Equal("foo", typeReference.Scope); }
public void TypeReference_Create_With_Name() { // arrange // act SyntaxTypeReference typeReference = TypeReference.Create( "Foo", TypeContext.Input, scope: "foo", nullable: new bool[] { false }); // assert Assert.Equal("Foo", typeReference.Type.NamedType().Name.Value); Assert.Equal(TypeContext.Input, typeReference.Context); Assert.Equal("foo", typeReference.Scope); Assert.Collection(typeReference.Nullable, Assert.False); }
public void SyntaxTypeReference_With_Scope() { // arrange SyntaxTypeReference typeReference1 = TypeReference.Create( "Foo", TypeContext.Input, scope: "foo"); // act SyntaxTypeReference typeReference2 = typeReference1.With(scope: "bar"); // assert Assert.Equal(typeReference1.Type, typeReference2.Type); Assert.Equal(typeReference1.Context, typeReference2.Context); Assert.Equal("bar", typeReference2.Scope); }
public void SyntaxTypeReference_With_Context() { // arrange SyntaxTypeReference typeReference1 = TypeReference.Create( "Foo", TypeContext.Input, scope: "foo"); // act SyntaxTypeReference typeReference2 = typeReference1.With(context: TypeContext.None); // assert Assert.Equal(typeReference1.Type, typeReference2.Type); Assert.Equal(TypeContext.None, typeReference2.Context); Assert.Equal(typeReference1.Scope, typeReference2.Scope); }
public void SyntaxTypeReference_With_Type() { // arrange SyntaxTypeReference typeReference1 = TypeReference.Create( "Foo", TypeContext.Input, scope: "foo"); // act SyntaxTypeReference typeReference2 = typeReference1.With(new NamedTypeNode("Bar")); // assert Assert.Equal("Bar", Assert.IsType <NamedTypeNode>(typeReference2.Type).Name.Value); Assert.Equal(typeReference1.Context, typeReference2.Context); Assert.Equal(typeReference1.Scope, typeReference2.Scope); }
public void GetMemberType_With_SyntaxTypeRef() { // arrange PropertyInfo property = typeof(ObjectPropWithSyntaxType) .GetProperty(nameof(ObjectPropWithSyntaxType.ShouldBeFound)) !; var typeInspector = new DefaultTypeInspector(); // act ITypeReference typeReference = typeInspector.GetReturnTypeRef(property !); // assert SyntaxTypeReference extTypeRef = Assert.IsType <SyntaxTypeReference>(typeReference); Assert.Equal("[String]", extTypeRef.Type.ToString()); Assert.Equal(TypeContext.None, typeReference.Context); Assert.Null(typeReference.Scope); }
public void SyntaxTypeReference_With_Nullable() { // arrange SyntaxTypeReference typeReference1 = TypeReference.Create( "Foo", TypeContext.Input, scope: "foo", nullable: new[] { true }); // act SyntaxTypeReference typeReference2 = typeReference1.With(nullable: null); // assert Assert.Equal(typeReference1.Type, typeReference2.Type); Assert.Equal(typeReference1.Context, typeReference2.Context); Assert.Equal(typeReference1.Scope, typeReference2.Scope); Assert.Null(typeReference2.Nullable); }
public void TypeReference_Create() { // arrange var namedType = new NamedTypeNode("Foo"); // act SyntaxTypeReference typeReference = TypeReference.Create( namedType, TypeContext.Input, scope: "foo", nullable: new bool[] { false }); // assert Assert.Equal(namedType, typeReference.Type); Assert.Equal(TypeContext.Input, typeReference.Context); Assert.Equal("foo", typeReference.Scope); Assert.Collection(typeReference.Nullable, Assert.False); }
public void SyntaxTypeReference_CreateInstance( string typeName, TypeContext context, bool?isTypeNullable, bool?isElementTypeNullable) { // arrange // act var typeReference = new SyntaxTypeReference( new NamedTypeNode(typeName), context, isTypeNullable, isElementTypeNullable); // assert Assert.Equal(typeName, typeReference.Type.ToString()); Assert.Equal(context, typeReference.Context); Assert.Equal(isTypeNullable, typeReference.IsTypeNullable); Assert.Equal(isElementTypeNullable, typeReference.IsElementTypeNullable); }
public void ISyntaxTypeReference_Equals_False() { // arrange var x = new SyntaxTypeReference( new NamedTypeNode("abc"), TypeContext.Input, true, false); ISyntaxTypeReference y = new SyntaxTypeReference( new NamedTypeNode("cde"), TypeContext.Input, true, false); // act bool result = x.Equals(y); // assert Assert.False(result); }
public void SyntaxTypeReference_With() { // arrange SyntaxTypeReference typeReference1 = TypeReference.Create( "Foo", TypeContext.Input, scope: "foo", nullable: new[] { true }); // act SyntaxTypeReference typeReference2 = typeReference1.With( new NamedTypeNode("Bar"), TypeContext.Output, scope: "bar", nullable: new[] { false }); // assert Assert.Equal("Bar", Assert.IsType <NamedTypeNode>(typeReference2.Type).Name.Value); Assert.Equal(TypeContext.Output, typeReference2.Context); Assert.Equal("bar", typeReference2.Scope); Assert.Collection(typeReference2.Nullable !, Assert.False); }