Skip to content

Commit

Permalink
Added coverage for Updates/BinaryVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
byorda-glb committed Apr 14, 2020
1 parent c843cba commit 679deca
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/DynamoCoreTests/DynamoCoreTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<Compile Include="UnicodeTest.cs" />
<Compile Include="UnitTestBase.cs" />
<Compile Include="UpdateManagerTests.cs" />
<Compile Include="Updates\BinaryVersionTests.cs" />
<Compile Include="UserDataMigrationTests.cs" />
<Compile Include="VersionUtilitiesTests.cs" />
<Compile Include="WorkspaceHeaderTests.cs" />
Expand Down
151 changes: 151 additions & 0 deletions test/DynamoCoreTests/Updates/BinaryVersionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
using System;
using Dynamo.Updates;
using NUnit.Framework;

namespace Dynamo.Tests.Core
{
[TestFixture]
public class BinaryVersionTests : DynamoModelTestBase
{
[Test]
[Category("UnitTests")]
public void FromStringTest()
{
Assert.IsNull(BinaryVersion.FromString(null));
Assert.IsNull(BinaryVersion.FromString(""));

Assert.IsNull(BinaryVersion.FromString("."));
Assert.IsNull(BinaryVersion.FromString("1.1"));

Assert.IsNull(BinaryVersion.FromString("a.1.1.1"));
Assert.IsNull(BinaryVersion.FromString("1.a.1.1"));
Assert.IsNull(BinaryVersion.FromString("1.1.a.1"));
Assert.IsNull(BinaryVersion.FromString("1.1.1.a"));
}

[Test]
[Category("UnitTests")]
public void GetHashCodeTest()
{
BinaryVersion bin = BinaryVersion.FromString("1.1.1.1");
Console.WriteLine(bin.GetHashCode());

Assert.IsNotNull(bin.GetHashCode());
}

[Test]
[Category("UnitTests")]
public void EqualsTest()
{
BinaryVersion firstBin = BinaryVersion.FromString("1.1.1.1");
BinaryVersion secondBin = firstBin;

Assert.IsTrue(firstBin.Equals(secondBin));
}

[Test]
[Category("UnitTests")]
public void LessThanOperatorTest()
{
BinaryVersion firstBin = BinaryVersion.FromString("1.1.1.1");

BinaryVersion secondBin = firstBin;
Assert.IsFalse(firstBin < secondBin);

secondBin = null;
Assert.IsFalse(firstBin < secondBin);

secondBin = BinaryVersion.FromString("2.2.2.2");
Assert.IsTrue(firstBin < secondBin);
}

[Test]
[Category("UnitTests")]
public void LessOrEqualOperatorTest()
{
BinaryVersion bin = BinaryVersion.FromString("1.1.1.1");

BinaryVersion secondBin = bin;
Assert.IsFalse(bin <= secondBin);

secondBin = null;
Assert.IsFalse(bin <= secondBin);

secondBin = BinaryVersion.FromString("2.2.2.2");
Assert.IsTrue(bin <= secondBin);

secondBin = BinaryVersion.FromString("1.1.1.1");
Assert.IsTrue(bin <= secondBin);
}

[Test]
[Category("UnitTests")]
public void MoreThanOperatorTest()
{
BinaryVersion firstBin = BinaryVersion.FromString("2.2.2.2");

BinaryVersion secondBin = firstBin;
Assert.IsFalse(firstBin > secondBin);

secondBin = null;
Assert.IsFalse(firstBin > secondBin);

secondBin = BinaryVersion.FromString("1.1.1.1");
Assert.IsTrue(firstBin > secondBin);
}

[Test]
[Category("UnitTests")]
public void MoreOrEqualOperatorTest()
{
BinaryVersion firstBin = BinaryVersion.FromString("2.2.2.2");

BinaryVersion secondBin = firstBin;
Assert.IsFalse(firstBin >= secondBin);

secondBin = null;
Assert.IsFalse(firstBin >= secondBin);

secondBin = BinaryVersion.FromString("1.1.1.1");
Assert.IsTrue(firstBin >= secondBin);

secondBin = BinaryVersion.FromString("2.2.2.2");
Assert.IsTrue(firstBin >= secondBin);
}

[Test]
[Category("UnitTests")]
public void EqualOperatorTestTest()
{
BinaryVersion bin = BinaryVersion.FromString("1.1.1.1");

BinaryVersion secondBin = bin;
Assert.IsTrue(bin == secondBin);

secondBin = null;
Assert.IsFalse(bin == secondBin);

secondBin = BinaryVersion.FromString("1.1.1.1");
Assert.IsTrue(bin == secondBin);
}

[Test]
[Category("UnitTests")]
public void NotEqualOperatorTestTest()
{
BinaryVersion bin = BinaryVersion.FromString("1.1.1.1");

BinaryVersion secondBin = bin;
Assert.IsFalse(bin != secondBin);

secondBin = null;
Assert.IsTrue(bin != secondBin);

secondBin = BinaryVersion.FromString("1.1.1.1");
Assert.IsFalse(bin != secondBin);

secondBin = BinaryVersion.FromString("2.2.2.2");
Assert.IsTrue(bin != secondBin);
}
}
}

0 comments on commit 679deca

Please sign in to comment.