Skip to content

Commit

Permalink
Added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raczeja committed Jun 11, 2018
1 parent 867eae2 commit d865198
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
</Choose>
<ItemGroup>
<Compile Include="ProjectTestBase.cs" />
<Compile Include="Tests\NameHelperTests.cs" />
<Compile Include="Tests\DateHelperTests.cs" />
<Compile Include="Tests\JavaScriptAlertsTestsNUnit.cs" />
<Compile Include="Tests\FilesHelperTests.cs" />
<Compile Include="Tests\WaitHelperTests.cs" />
Expand Down
36 changes: 36 additions & 0 deletions Objectivity.Test.Automation.UnitTests/Tests/DateHelperTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Globalization;
using NUnit.Framework;
using Objectivity.Test.Automation.Common.Helpers;

namespace Objectivity.Test.Automation.UnitTests.Tests
{
[TestFixture()]
[TestFixture, Parallelizable(ParallelScope.Self)]
public class DateHelperTests
{
[Test()]
public void TomorrowDateTest()
{
Assert.AreEqual(DateTime.Now.AddDays(1).ToString("ddMMyyyy", CultureInfo.CurrentCulture), DateHelper.TomorrowDate);
}

[Test()]
public void CurrentDateTest()
{
Assert.AreEqual(DateTime.Now.ToString("dd-MM-yyyy", CultureInfo.CurrentCulture), DateHelper.CurrentDate);
}

[Test()]
public void CurrentTimeStampTest()
{
Assert.AreEqual(DateTime.Now.ToString("ddMMyyyyHHmmss", CultureInfo.CurrentCulture), DateHelper.CurrentTimeStamp);
}

[Test()]
public void GetFutureDateTest()
{
Assert.AreEqual(DateTime.Now.AddDays(3).ToString("ddMMyyyy", CultureInfo.CurrentCulture), DateHelper.GetFutureDate(3));
}
}
}
21 changes: 21 additions & 0 deletions Objectivity.Test.Automation.UnitTests/Tests/NameHelperTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using NUnit.Framework;
using Objectivity.Test.Automation.Common.Helpers;

namespace Objectivity.Test.Automation.UnitTests.Tests
{
[TestFixture()]
[TestFixture, Parallelizable(ParallelScope.Self)]
public class NameHelperTests
{
[Test()]
public void ShortenFileNameTest()
{
var name = "verylongfilename 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0.txt";
var text = NameHelper.ShortenFileName(TestContext.CurrentContext.TestDirectory, name, "_", 255);
Assert.IsTrue((TestContext.CurrentContext.TestDirectory + name).Length > 255);
text = NameHelper.ShortenFileName(TestContext.CurrentContext.TestDirectory, name, " ", 255);
Assert.AreEqual(255, (TestContext.CurrentContext.TestDirectory + text).Length);
}

}
}

0 comments on commit d865198

Please sign in to comment.