Skip to content

Commit

Permalink
Merge pull request #58 from istanishev/feature/fix_CompareTo
Browse files Browse the repository at this point in the history
Fix PostalCodeRange.CompareTo method to order ranges correctly first …
  • Loading branch information
istanishev committed Aug 3, 2015
2 parents eb4a065 + 0e96b70 commit 617025d
Show file tree
Hide file tree
Showing 159 changed files with 1,683 additions and 854 deletions.
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/AFPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new AFPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new AFPostalCode(postalCodeBefore);
var a = new AFPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/ALPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new ALPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new ALPostalCode(postalCodeBefore);
var a = new ALPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/AMPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new AMPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new AMPostalCode(postalCodeBefore);
var a = new AMPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/ARPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new ARPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new ARPostalCode(postalCodeBefore);
var a = new ARPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/ASPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("00000")]
Expand All @@ -52,6 +51,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new ASPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new ASPostalCode(postalCodeBefore);
var a = new ASPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("12234")]
[TestCase("52678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/ATPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new ATPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new ATPostalCode(postalCodeBefore);
var a = new ATPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/AUPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new AUPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new AUPostalCode(postalCodeBefore);
var a = new AUPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/BAPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("00000")]
Expand All @@ -52,6 +51,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new BAPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new BAPostalCode(postalCodeBefore);
var a = new BAPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("12234")]
[TestCase("52678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/BBPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("BB00000")]
Expand All @@ -51,6 +50,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new BBPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new BBPostalCode(postalCodeBefore);
var a = new BBPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("BB12345")]
[TestCase("12345")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/BDPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new BDPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new BDPostalCode(postalCodeBefore);
var a = new BDPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/BEPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new BEPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new BEPostalCode(postalCodeBefore);
var a = new BEPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/BGPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new BGPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new BGPostalCode(postalCodeBefore);
var a = new BGPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/BOPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new BOPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new BOPostalCode(postalCodeBefore);
var a = new BOPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/BTPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("00000")]
Expand All @@ -52,6 +51,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new BTPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new BTPostalCode(postalCodeBefore);
var a = new BTPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("12234")]
[TestCase("52678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/BYPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("000000")]
Expand All @@ -52,6 +51,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new BYPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new BYPostalCode(postalCodeBefore);
var a = new BYPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("122334")]
[TestCase("525678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/CAPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("A0A0A0")]
Expand All @@ -49,6 +48,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new CAPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new CAPostalCode(postalCodeBefore);
var a = new CAPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("A4B5X5")]
[TestCase("A4B5A5")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/CCPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new CCPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new CCPostalCode(postalCodeBefore);
var a = new CCPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
8 changes: 7 additions & 1 deletion src/PostalCodes.UnitTests/Generated/CHPostalCodeTests.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, str
Assert.AreEqual(codeSuccessor, code.Successor);
Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());

}

[TestCase("0000")]
Expand All @@ -50,6 +49,13 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
Assert.Throws<ArgumentException>(() => new CHPostalCode(postalCode));
}

public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
{
var b = new CHPostalCode(postalCodeBefore);
var a = new CHPostalCode(postalCodeAfter);
Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
Assert.AreEqual(Math.Sign( 1), Math.Sign(a.CompareTo(b)));
}
[TestCase("1234")]
[TestCase("5678")]
public void Equals_WithNull_DoesntThrowAndReturnsFalse(string code)
Expand Down
Loading

0 comments on commit 617025d

Please sign in to comment.