public void Equals_WithInequal_ShouldReturnFalse() { var results = EqualityTesting.TestInequal( this.subject, s => new BalanceWatch <object, int>( s.Context, uint256.Zero, s.Transaction, s.Address, s.BalanceChange, s.StartTime, s.Id), s => new BalanceWatch <object, int>( s.Context, s.StartBlock, uint256.Zero, s.Address, s.BalanceChange, s.StartTime, s.Id), s => new BalanceWatch <object, int>( s.Context, s.StartBlock, s.Transaction, TestAddress.Regtest2, s.BalanceChange, s.StartTime, s.Id)); results.Should().NotContain(true); }
public void Equality() { var c = CreateCompilation(""); var obj = c.GetSpecialType(SpecialType.System_Object); var int32 = c.GetSpecialType(SpecialType.System_Int32); var notNullable = new NullabilityInfo(CodeAnalysis.NullableAnnotation.NotAnnotated, CodeAnalysis.NullableFlowState.NotNull); var nullable = new NullabilityInfo(CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableFlowState.MaybeNull); EqualityTesting.AssertEqual(default(TypeInfo), default(TypeInfo)); EqualityTesting.AssertEqual(new TypeInfo(obj, int32, nullable, notNullable), new TypeInfo(obj, int32, nullable, notNullable)); #pragma warning disable IDE0055 // Fix formatting: spacing is intentional to allow for visual field comparison EqualityTesting.AssertNotEqual(new TypeInfo(obj, obj, nullable, nullable), new TypeInfo(obj, int32, nullable, nullable)); EqualityTesting.AssertNotEqual(new TypeInfo(int32, obj, nullable, nullable), new TypeInfo(obj, obj, nullable, nullable)); EqualityTesting.AssertNotEqual(new TypeInfo(obj, int32, nullable, nullable), new TypeInfo(obj, int32, notNullable, nullable)); EqualityTesting.AssertNotEqual(new TypeInfo(obj, int32, nullable, nullable), new TypeInfo(obj, int32, nullable, notNullable)); #pragma warning restore IDE0055 // Fix formatting EqualityTesting.AssertEqual(new TypeInfo(int32, int32, default, default),
public void Equals_WithInequal_ShouldBeUnequal() { EqualityTesting.TestInequal( this.subject, s => new BalanceChange <object, int>(s.Context, 11) ); }
public void Equality() { var node1 = SyntaxFactory.Parameter(SyntaxFactory.Identifier("a")); var node2 = SyntaxFactory.Parameter(SyntaxFactory.Identifier("b")); EqualityTesting.AssertEqual( default(SeparatedSyntaxList <CSharpSyntaxNode>), default(SeparatedSyntaxList <CSharpSyntaxNode>) ); EqualityTesting.AssertEqual( new SeparatedSyntaxList <CSharpSyntaxNode>(new SyntaxNodeOrTokenList(node1, 0)), new SeparatedSyntaxList <CSharpSyntaxNode>(new SyntaxNodeOrTokenList(node1, 0)) ); EqualityTesting.AssertEqual( new SeparatedSyntaxList <CSharpSyntaxNode>(new SyntaxNodeOrTokenList(node1, 0)), new SeparatedSyntaxList <CSharpSyntaxNode>(new SyntaxNodeOrTokenList(node1, 1)) ); EqualityTesting.AssertNotEqual( new SeparatedSyntaxList <CSharpSyntaxNode>(new SyntaxNodeOrTokenList(node1, 0)), new SeparatedSyntaxList <CSharpSyntaxNode>(new SyntaxNodeOrTokenList(node2, 0)) ); }
public void Equality() { var c = CreateCompilation(""); var obj = c.GetSpecialType(SpecialType.System_Object).GetPublicSymbol(); var int32 = c.GetSpecialType(SpecialType.System_Int32).GetPublicSymbol(); var notNullable = new NullabilityInfo(CodeAnalysis.NullableAnnotation.NotAnnotated, CodeAnalysis.NullableFlowState.NotNull); var nullable = new NullabilityInfo(CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableFlowState.MaybeNull); EqualityTesting.AssertEqual(default(TypeInfo), default(TypeInfo)); EqualityTesting.AssertEqual(new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32, nullable, notNullable), new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32, nullable, notNullable)); EqualityTesting.AssertNotEqual(new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable), new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable)); EqualityTesting.AssertNotEqual(new TypeInfo(int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable), new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable)); EqualityTesting.AssertNotEqual(new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable), new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.NotAnnotated), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), notNullable, nullable)); EqualityTesting.AssertNotEqual(new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), nullable, nullable), new TypeInfo(obj.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.Annotated), int32, nullable, notNullable)); EqualityTesting.AssertEqual(new TypeInfo(int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), int32.WithNullableAnnotation(CodeAnalysis.NullableAnnotation.None), default, default),
public void Equals_WithEqual_ShouldBeEqual() { EqualityTesting.TestEquals( this.subject, s => new ConfirmedBalanceChange <object, int>(null, s.Amount, s.Confirmation) ); }
public void Equality() { EqualityTesting.AssertEqual(default(TypedConstant), default(TypedConstant)); EqualityTesting.AssertEqual( new TypedConstant(_intType, TypedConstantKind.Primitive, 1), new TypedConstant(_intType, TypedConstantKind.Primitive, 1)); var s1 = "goo"; var s2 = String.Format("{0}{1}{1}", "g", "o"); EqualityTesting.AssertEqual( new TypedConstant(_stringType, TypedConstantKind.Primitive, s1), new TypedConstant(_stringType, TypedConstantKind.Primitive, s2)); EqualityTesting.AssertEqual( new TypedConstant(_stringType, TypedConstantKind.Primitive, null), new TypedConstant(_stringType, TypedConstantKind.Primitive, null)); EqualityTesting.AssertEqual( new TypedConstant(_enumString1, TypedConstantKind.Primitive, null), new TypedConstant(_enumString2, TypedConstantKind.Primitive, null)); EqualityTesting.AssertNotEqual( new TypedConstant(_stringType, TypedConstantKind.Primitive, null), new TypedConstant(_stringType, TypedConstantKind.Error, null)); EqualityTesting.AssertNotEqual( new TypedConstant(_stringType, TypedConstantKind.Primitive, null), new TypedConstant(_enumString1, TypedConstantKind.Primitive, null)); }
public void TestReverse_Equality() { var node1 = SyntaxFactory.ReturnStatement(); EqualityTesting.AssertEqual( default(SyntaxTokenList).Reverse(), default(SyntaxTokenList).Reverse() ); EqualityTesting.AssertEqual( new SyntaxTokenList(node1, node1.ReturnKeyword.Node, 0, 0).Reverse(), new SyntaxTokenList(node1, node1.ReturnKeyword.Node, 0, 0).Reverse() ); // index is considered EqualityTesting.AssertNotEqual( new SyntaxTokenList(node1, node1.ReturnKeyword.Node, 0, 1).Reverse(), new SyntaxTokenList(node1, node1.ReturnKeyword.Node, 0, 0).Reverse() ); // position not considered: EqualityTesting.AssertEqual( new SyntaxTokenList(node1, node1.ReturnKeyword.Node, 1, 0).Reverse(), new SyntaxTokenList(node1, node1.ReturnKeyword.Node, 0, 0).Reverse() ); }
public void EqualsGetHashCodeAndEqualityOperators() { var id = Guid.NewGuid(); var aliceAndBob = new[] { new Name("Alice", "Crypto"), new Name("Bob", "Crypto") }; var coryAndDan = new[] { new Name("Cory", "Crypto"), new Name("Dan", "Crypto") }; var a = new DepartmentImported(id, aliceAndBob); var b = new DepartmentImported(id, aliceAndBob); var c = new DepartmentImported(id, aliceAndBob); var otherNamesSameCount = new DepartmentImported(id, coryAndDan); var otherNamesDifferentCount = new DepartmentImported(id, new[] { aliceAndBob[0] }); var otherNamesNull = new DepartmentImported(id, null); var otherNamesSameCountNullElements = new DepartmentImported(id, new Name[] { null, null }); EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherNamesSameCount, otherNamesDifferentCount, otherNamesNull, otherNamesSameCountNullElements); EqualityTesting.TestEqualityOperators(a, b, c, otherNamesSameCount, otherNamesDifferentCount, otherNamesNull, otherNamesSameCountNullElements); }
public void Reverse_Equality() { var node1 = SyntaxFactory.Token(SyntaxKind.AbstractKeyword); var node2 = SyntaxFactory.Token(SyntaxKind.VirtualKeyword); EqualityTesting.AssertEqual( default(SyntaxTriviaList.Reversed), default(SyntaxTriviaList.Reversed) ); EqualityTesting.AssertEqual( new SyntaxTriviaList(node1, node1.Node, 0, 0).Reverse(), new SyntaxTriviaList(node1, node1.Node, 0, 0).Reverse() ); EqualityTesting.AssertNotEqual( new SyntaxTriviaList(node1, node1.Node, 0, 1).Reverse(), new SyntaxTriviaList(node1, node1.Node, 0, 0).Reverse() ); EqualityTesting.AssertNotEqual( new SyntaxTriviaList(node1, node2.Node, 0, 0).Reverse(), new SyntaxTriviaList(node1, node1.Node, 0, 0).Reverse() ); EqualityTesting.AssertNotEqual( new SyntaxTriviaList(node2, node1.Node, 0, 0).Reverse(), new SyntaxTriviaList(node1, node1.Node, 0, 0).Reverse() ); // position not considered: EqualityTesting.AssertEqual( new SyntaxTriviaList(node1, node1.Node, 1, 0).Reverse(), new SyntaxTriviaList(node1, node1.Node, 0, 0).Reverse() ); }
public void EqualsGetHashCodeAndEqualityOperators() { var a = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname, SourceId); var b = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname, SourceId); var c = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname, SourceId); var otherCommandId = new EmployeeImported(Guid.NewGuid(), EmployeeNumber + 1, FirstName, Lastname, SourceId); var otherEmployeeNumber = new EmployeeImported(Id, EmployeeNumber + 1, FirstName, Lastname, SourceId); var otherFirstName = new EmployeeImported(Id, EmployeeNumber, FirstName + "x", Lastname, SourceId); var otherFirstNameNull = new EmployeeImported(Id, EmployeeNumber, null, Lastname, SourceId); var otherLastName = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname + "x", SourceId); var otherLastNameNull = new EmployeeImported(Id, EmployeeNumber, FirstName, null, SourceId); var otherSourceId = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname, SourceId + 1); var otherSourceIdNull = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname, null); EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherCommandId, otherEmployeeNumber, otherFirstName, otherFirstNameNull, otherLastName, otherLastNameNull, otherSourceId, otherSourceIdNull); EqualityTesting.TestEqualityOperators(a, b, c, otherEmployeeNumber, otherFirstName, otherFirstNameNull, otherLastName, otherLastNameNull, otherSourceId, otherSourceIdNull); }
public void Equals_WithInequal_ShouldReturnFalse() { var results = EqualityTesting.TestInequal( this.subject, s => new BalanceChange <object, int>(s.Context, 11)); results.Should().NotContain(true); }
public void Equals_WithEqual_ShouldBeEqual() { EqualityTesting.TestEquals( this.subject, s => new BalanceChange <object, int>(null, s.Amount), s => new BalanceChange <object, int>(new object(), s.Amount) ); }
public void Equals_WithUnequal_ShouldBeUnequal() { EqualityTesting.TestInequal( this.subject, s => new ConfirmedBalanceChange <object, int>(s.Context, 9, s.Confirmation), s => new ConfirmedBalanceChange <object, int>(s.Context, s.Amount, 2) ); }
public void Reverse_Equality() { var node1 = SyntaxFactory.ReturnStatement(); var node2 = SyntaxFactory.ReturnStatement(); EqualityTesting.AssertEqual(default(ChildSyntaxList.Reversed), default(ChildSyntaxList.Reversed)); EqualityTesting.AssertEqual(new ChildSyntaxList(node1).Reverse(), new ChildSyntaxList(node1).Reverse()); }
public void Equals_WithEqual_ShouldReturnTrue() { var results = EqualityTesting.TestEquals(this.subject, s => new CallbackData() { Received = s.Received }); Assert.DoesNotContain(false, results); }
public void Equals_WithEqual_ShouldReturnTrue() { var results = EqualityTesting.TestEquals( this.subject, s => new BalanceChange <object, int>(null, s.Amount), s => new BalanceChange <object, int>(new object(), s.Amount)); results.Should().NotContain(false); }
public void Equality() { var node1 = SyntaxFactory.ReturnStatement(); var node2 = SyntaxFactory.ReturnStatement(); EqualityTesting.AssertEqual(default(SyntaxList <CSharpSyntaxNode>), default(SyntaxList <CSharpSyntaxNode>)); EqualityTesting.AssertEqual(new SyntaxList <CSharpSyntaxNode>(node1), new SyntaxList <CSharpSyntaxNode>(node1)); EqualityTesting.AssertNotEqual(new SyntaxList <CSharpSyntaxNode>(node1), new SyntaxList <CSharpSyntaxNode>(node2)); }
public void EqualityOperations() { var a = new TypeName("name"); var b = new TypeName("name"); var c = new TypeName("name"); var otherName = new TypeName("other name"); EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherName); EqualityTesting.TestEqualityOperators(a, b, c, otherName); }
public void EqualsAndGetHashCodeAndEquality() { var a = new Keyword("a"); var b = new Keyword("a"); var c = new Keyword("a"); var otherName = new Keyword("b"); EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherName); EqualityTesting.TestEqualityOperators(a, b, c, otherName); }
public void Equals_WithEqual_ShouldReturnTrue() { var results = EqualityTesting.TestEquals( this.subject, s => new CallbackAmount() { Confirmed = s.Confirmed, Pending = s.Pending }); Assert.DoesNotContain(false, results); }
public void EqualsGetHashCodeAndEqualityOperators() { var a = new Generated.EmployeeMetadata(Source, SourceId); var b = new Generated.EmployeeMetadata(Source, SourceId); var c = new Generated.EmployeeMetadata(Source, SourceId); var otherSource = new Generated.EmployeeMetadata(Source + "x", SourceId); var otherSourceId = new Generated.EmployeeMetadata(Source, SourceId + 1); var otherSourceIdNull = new Generated.EmployeeMetadata(Source, null); EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherSource, otherSourceId, otherSourceIdNull); EqualityTesting.TestEqualityOperators(a, b, c, otherSource, otherSourceId, otherSourceIdNull); }
public void EqualsGetHashCodeAndEqualityOperators() { const int number = 1; var a = new Generated.EmployeeNumber(number); var b = new Generated.EmployeeNumber(number); var c = new Generated.EmployeeNumber(number); var otherEmployeeNumber = new Generated.EmployeeNumber(number + 1); EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherEmployeeNumber); EqualityTesting.TestEqualityOperators(a, b, c, otherEmployeeNumber); }
public void EqualityMethods() { var baseTypes = new BaseTypes(new[] { new TypeName("SomeNamespace.IContract") }); var anotherContractBaseTypes = new BaseTypes(new[] { new TypeName("SomeNamespace.IAnotherContract") }); var a = new CommandConventions(baseTypes); var b = new CommandConventions(baseTypes); var c = new CommandConventions(baseTypes); var otherBaseTypes = new CommandConventions(anotherContractBaseTypes); EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherBaseTypes); EqualityTesting.TestEqualityOperators(a, b, c, otherBaseTypes); }
public void Equals_WithInequal_ShouldReturnFalse() { var results = EqualityTesting.TestInequal( this.subject, s => new Rule( s.Property, s.AddressReservation, s.TargetAmount, s.TargetConfirmation, s.OriginalTimeout, s.Callback, Guid.NewGuid())); Assert.DoesNotContain(true, results); }
public void EqualsGetHashCodeAndEqualityOperators() { const string first = "Joe"; const string last = "User"; var a = new Generated.EmployeeName(first, last); var b = new Generated.EmployeeName(first, last); var c = new Generated.EmployeeName(first, last); var otherFirstName = new Generated.EmployeeName(first + "x", last); var otherLastName = new Generated.EmployeeName(first, "von " + last); EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherFirstName, otherLastName); EqualityTesting.TestEqualityOperators(a, b, c, otherFirstName, otherLastName); }
public void EqualityOperations() { var typeNameBaseType = new TypeName("SomeNamespace.IBaseType"); var typeNameOtherBaseType = new TypeName("SomeNamespace.IOtherBaseType"); var a = new BaseTypes(new[] { typeNameBaseType }); var b = new BaseTypes(new[] { typeNameBaseType }); var c = new BaseTypes(new[] { typeNameBaseType }); var otherTypeName = new BaseTypes(new[] { typeNameOtherBaseType }); var otherTypeNameLength = new BaseTypes(new[] { typeNameBaseType, typeNameOtherBaseType }); var otherTypeNameNull = new BaseTypes(null); EqualityTesting.TestEqualityOperators(a, b, c, otherTypeName, otherTypeNameLength, otherTypeNameNull); EqualityTesting.TestEqualityOperators(a, b, c, otherTypeName, otherTypeNameLength, otherTypeNameNull); }
public void Equality() { var c1 = CreateCompilationWithMscorlib(""); var c2 = CreateCompilationWithMscorlib(""); var a1 = c1.Assembly; var a2 = c2.Assembly; EqualityTesting.AssertEqual(default(NamespaceExtent), default(NamespaceExtent)); EqualityTesting.AssertNotEqual(default(NamespaceExtent), new NamespaceExtent(c2)); EqualityTesting.AssertNotEqual(new NamespaceExtent(c1), default(NamespaceExtent)); EqualityTesting.AssertEqual(new NamespaceExtent(c1), new NamespaceExtent(c1)); EqualityTesting.AssertNotEqual(new NamespaceExtent(c1), new NamespaceExtent(c2)); EqualityTesting.AssertEqual(new NamespaceExtent(a1), new NamespaceExtent(a1)); EqualityTesting.AssertNotEqual(new NamespaceExtent(a1), new NamespaceExtent(a2)); }
public void EqualsGetHashCodeAndEqualityOperators_TypeWithStringReferenceTypeArray_ShouldWork() { const int number = 1; var roles = new[] { "tester", "developer" }; var a = new Generated.EmployeeRoles(number, roles); var b = new Generated.EmployeeRoles(number, new[] { "tester", "developer" }); var c = new Generated.EmployeeRoles(number, roles); var otherEmployeeNumber = new Generated.EmployeeRoles(number + 1, roles); var otherRolesLength = new Generated.EmployeeRoles(number, new[] { "tester" }); var otherRolesValues = new Generated.EmployeeRoles(number, new[] { "tester", "analyst" }); EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherEmployeeNumber, otherRolesLength, otherRolesValues); EqualityTesting.TestEqualityOperators(a, b, c, otherEmployeeNumber, otherRolesLength, otherRolesValues); }
public void Equality() { var c = CreateStandardCompilation(""); var obj = c.GetSpecialType(SpecialType.System_Object); var int32 = c.GetSpecialType(SpecialType.System_Int32); EqualityTesting.AssertEqual(default(TypeInfo), default(TypeInfo)); EqualityTesting.AssertEqual(new TypeInfo(obj, int32), new TypeInfo(obj, int32)); EqualityTesting.AssertNotEqual(new TypeInfo(obj, obj), new TypeInfo(obj, int32)); EqualityTesting.AssertNotEqual(new TypeInfo(int32, obj), new TypeInfo(obj, obj)); EqualityTesting.AssertEqual(new TypeInfo(int32, int32), new TypeInfo(int32, int32)); var intEnum1 = c.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerable_T).Construct(int32); var intEnum2 = c.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerable_T).Construct(int32); EqualityTesting.AssertEqual(new TypeInfo(intEnum1, int32), new TypeInfo(intEnum2, int32)); }