예제 #1
0
        public void GetHashCode_WithEqualObject_EqualHashes(string code)
        {
            var x = new DOPostalCode(code);
            var y = new DOPostalCode(code);

            Assert.IsTrue(x.GetHashCode() == y.GetHashCode());
        }
예제 #2
0
        public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
        {
            var b = new DOPostalCode(postalCodeBefore);
            var a = new DOPostalCode(postalCodeAfter);

            Assert.AreEqual(Math.Sign(-1), Math.Sign(b.CompareTo(a)));
            Assert.AreEqual(Math.Sign(1), Math.Sign(a.CompareTo(b)));
        }
예제 #3
0
        public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, string postalCodeSuccessor)
        {
            var code          = new DOPostalCode(postalCode);
            var codeSuccessor = new DOPostalCode(postalCodeSuccessor);

            Assert.AreEqual(codeSuccessor, code.Successor);
            Assert.AreEqual(codeSuccessor.ToString(), code.Successor.ToString());
            Assert.AreEqual(codeSuccessor.ToHumanReadableString(), code.Successor.ToHumanReadableString());
        }
예제 #4
0
        public void AreAdjacent_WithAdjacentPostalCodes_ReturnsTrue(string code)
        {
            var x     = new DOPostalCode(code);
            var xPred = x.Predecessor;
            var xSucc = x.Successor;

            Assert.IsTrue(PostalCode.AreAdjacent(x, xPred));
            Assert.IsTrue(PostalCode.AreAdjacent(xPred, x));
            Assert.IsTrue(PostalCode.AreAdjacent(x, xSucc));
            Assert.IsTrue(PostalCode.AreAdjacent(xSucc, x));
            Assert.IsFalse(PostalCode.AreAdjacent(xPred, xSucc));
        }