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 KspVersionBound( new KspVersion(lowerMajor, lowerMinor, lowerPatch, lowerBuilder), lowerInclusive ); var upper = new KspVersionBound( new KspVersion(upperMajor, upperMinor, upperPatch, upperBuilder), upperInclusive ); // Act // ReSharper disable once ReturnValueOfPureMethodIsNotUsed TestDelegate act = () => new KspVersionRange(lower, upper).GetHashCode(); // Assert Assert.That(act, Throws.Nothing); }
public void ParameterfulCtorWorksCorrectly() { // Act var result = new KspVersionBound(new KspVersion(1, 2, 3, 4), true); // Assert Assert.AreEqual(new KspVersion(1, 2, 3, 4), result.Value); Assert.IsTrue(result.Inclusive); }
public void ParameterlessCtorWorksCorrectly() { // Act var result = new KspVersionBound(); // Assert Assert.AreEqual(KspVersion.Any, result.Value); Assert.IsTrue(result.Inclusive); }
public void CtorWorksCorrectly() { // Arrange var lower = new KspVersionBound(new KspVersion(1, 2, 3, 4), false); var upper = new KspVersionBound(new KspVersion(5, 6, 7, 8), true); // Act var result = new KspVersionRange(lower, upper); // Assert Assert.That(result.Lower, Is.EqualTo(lower)); Assert.That(result.Upper, Is.EqualTo(upper)); }
public void ReferenceEqualityWorksCorrectly() { // Arrange var sut = new KspVersionBound(); // Act var genericEquals = sut.Equals(sut); var nonGenericEquals = sut.Equals((object)sut); // Assert Assert.IsTrue(genericEquals); Assert.IsTrue(nonGenericEquals); }
public void RangeFromVersionsEqualsRangeFromBounds() { // Arrange var lowerBound = new KspVersionBound(new KspVersion(1, 2, 0, 0), true); var upperBound = new KspVersionBound(new KspVersion(2, 4, 7, 0), false); var lowerVersion = new KspVersion(1, 2); var upperVersion = new KspVersion(2, 4, 6); // Act var resultFromBounds = new KspVersionRange(lowerBound, upperBound); var resultFromVersions = new KspVersionRange(lowerVersion, upperVersion); // Assert Assert.That(resultFromBounds.Lower, Is.EqualTo(resultFromVersions.Lower)); Assert.That(resultFromBounds.Upper, Is.EqualTo(resultFromVersions.Upper)); }
public void EqualityWorksCorrectly(KspVersionBound vb1, KspVersionBound 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); }
public void NullEqualityWorksCorrectly() { // Act // ReSharper disable ConditionIsAlwaysTrueOrFalse var genericEquals = new KspVersionBound().Equals(null); var nonGenericEquals = new KspVersionBound().Equals((object)null); var equalsOperatorNullLeft = null == new KspVersionBound(); var equalsOperatorNullRight = new KspVersionBound() == null; var notEqualsOperatorNullLeft = null != new KspVersionBound(); var notEqualsOperatorNullRight = new KspVersionBound() != null; // ReSharper restore ConditionIsAlwaysTrueOrFalse // ASsert Assert.IsFalse(genericEquals); Assert.IsFalse(nonGenericEquals); Assert.IsFalse(equalsOperatorNullLeft); Assert.IsFalse(equalsOperatorNullRight); Assert.IsTrue(notEqualsOperatorNullLeft); Assert.IsTrue(notEqualsOperatorNullRight); }