Example #1
0
        public void GetHashCodeDoesNotThrow(
            [Random(0, int.MaxValue, 1)] int lowerMajor,
            [Random(0, int.MaxValue, 1)] int lowerMinor,
            [Random(0, int.MaxValue, 1)] int lowerPatch,
            [Random(0, int.MaxValue, 1)] int lowerBuilder,
            [Values(false, true)] bool lowerInclusive,
            [Random(0, int.MaxValue, 1)] int upperMajor,
            [Random(0, int.MaxValue, 1)] int upperMinor,
            [Random(0, int.MaxValue, 1)] int upperPatch,
            [Random(0, int.MaxValue, 1)] int upperBuilder,
            [Values(false, true)] bool upperInclusive
            )
        {
            // Arrange
            var lower = new GameVersionBound(
                new GameVersion(lowerMajor, lowerMinor, lowerPatch, lowerBuilder),
                lowerInclusive
                );

            var upper = new GameVersionBound(
                new GameVersion(upperMajor, upperMinor, upperPatch, upperBuilder),
                upperInclusive
                );

            // Act
            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            TestDelegate act = () => new GameVersionRange(lower, upper).GetHashCode();

            // Assert
            Assert.That(act, Throws.Nothing);
        }
Example #2
0
        public void ParameterfulCtorWorksCorrectly()
        {
            // Act
            var result = new GameVersionBound(new GameVersion(1, 2, 3, 4), true);

            // Assert
            Assert.AreEqual(new GameVersion(1, 2, 3, 4), result.Value);
            Assert.IsTrue(result.Inclusive);
        }
Example #3
0
        public void ParameterlessCtorWorksCorrectly()
        {
            // Act
            var result = new GameVersionBound();

            // Assert
            Assert.AreEqual(GameVersion.Any, result.Value);
            Assert.IsTrue(result.Inclusive);
        }
Example #4
0
        public void ReferenceEqualityWorksCorrectly()
        {
            // Arrange
            var sut = new GameVersionBound();

            // Act
            var genericEquals    = sut.Equals(sut);
            var nonGenericEquals = sut.Equals((object)sut);

            // Assert
            Assert.IsTrue(genericEquals);
            Assert.IsTrue(nonGenericEquals);
        }
Example #5
0
        public void CtorWorksCorrectly()
        {
            // Arrange
            var lower = new GameVersionBound(new GameVersion(1, 2, 3, 4), false);
            var upper = new GameVersionBound(new GameVersion(5, 6, 7, 8), true);

            // Act
            var result = new GameVersionRange(lower, upper);

            // Assert
            Assert.That(result.Lower, Is.EqualTo(lower));
            Assert.That(result.Upper, Is.EqualTo(upper));
        }
Example #6
0
        public void RangeFromVersionsEqualsRangeFromBounds()
        {
            // Arrange
            var lowerBound   = new GameVersionBound(new GameVersion(1, 2, 0, 0), true);
            var upperBound   = new GameVersionBound(new GameVersion(2, 4, 7, 0), false);
            var lowerVersion = new GameVersion(1, 2);
            var upperVersion = new GameVersion(2, 4, 6);

            // Act
            var resultFromBounds   = new GameVersionRange(lowerBound, upperBound);
            var resultFromVersions = new GameVersionRange(lowerVersion, upperVersion);

            // Assert
            Assert.That(resultFromBounds.Lower, Is.EqualTo(resultFromVersions.Lower));
            Assert.That(resultFromBounds.Upper, Is.EqualTo(resultFromVersions.Upper));
        }
Example #7
0
        public void EqualityWorksCorrectly(GameVersionBound vb1, GameVersionBound vb2, bool areEqual)
        {
            // Act
            var genericEquals            = vb1.Equals(vb2);
            var nonGenericEquals         = vb1.Equals((object)vb2);
            var equalsOperator           = vb1 == vb2;
            var notEqualsOperator        = vb1 != vb2;
            var reverseEqualsOperator    = vb2 == vb1;
            var reverseNotEqualsOperator = vb2 != vb1;

            // Assert
            Assert.AreEqual(areEqual, genericEquals);
            Assert.AreEqual(areEqual, nonGenericEquals);
            Assert.AreEqual(areEqual, equalsOperator);
            Assert.AreNotEqual(areEqual, notEqualsOperator);
            Assert.AreEqual(areEqual, reverseEqualsOperator);
            Assert.AreNotEqual(areEqual, reverseNotEqualsOperator);
        }
Example #8
0
        public void NullEqualityWorksCorrectly()
        {
            // Act
            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            var genericEquals              = new GameVersionBound().Equals(null);
            var nonGenericEquals           = new GameVersionBound().Equals((object)null);
            var equalsOperatorNullLeft     = null == new GameVersionBound();
            var equalsOperatorNullRight    = new GameVersionBound() == null;
            var notEqualsOperatorNullLeft  = null != new GameVersionBound();
            var notEqualsOperatorNullRight = new GameVersionBound() != null;

            // ReSharper restore ConditionIsAlwaysTrueOrFalse

            // ASsert
            Assert.IsFalse(genericEquals);
            Assert.IsFalse(nonGenericEquals);
            Assert.IsFalse(equalsOperatorNullLeft);
            Assert.IsFalse(equalsOperatorNullRight);
            Assert.IsTrue(notEqualsOperatorNullLeft);
            Assert.IsTrue(notEqualsOperatorNullRight);
        }