Skip to content

Commit

Permalink
Fix nunit usage after bump to 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Jun 11, 2024
1 parent 64f2f36 commit 7a8f956
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
using Moq;
using NUnit.Framework;
using Snowflake.Data.Client;
using Snowflake.Data.Core;
using Snowflake.Data.Core.Session;
using Snowflake.Data.Log;
using Snowflake.Data.Tests.Mock;
using Snowflake.Data.Tests.Util;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.IntegrationTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using Snowflake.Data.Core.Session;
using Snowflake.Data.Tests.Mock;
using Snowflake.Data.Tests.Util;
using NUnit.Framework.Legacy;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.IntegrationTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Snowflake.Data.Core;
using Snowflake.Data.Core.Session;
using Snowflake.Data.Tests.Util;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.IntegrationTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Snowflake.Data.Core.Session;
using Snowflake.Data.Log;
using Snowflake.Data.Tests.Util;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.IntegrationTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using NUnit.Framework;
using Snowflake.Data.Client;
using Snowflake.Data.Core.Session;
using Snowflake.Data.Tests.Mock;
using Snowflake.Data.Tests.Util;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.IntegrationTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Snowflake.Data.Client;
using Snowflake.Data.Core.Session;
using Snowflake.Data.Tests.Util;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Snowflake.Data.Client;
using Snowflake.Data.Core.Tools;
using Snowflake.Data.Tests.Util;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Snowflake.Data.Core;
using Snowflake.Data.Core.Session;
using Snowflake.Data.Core.Tools;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Session
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NUnit.Framework;
using Snowflake.Data.Core.Session;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Session
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NUnit.Framework;
using Snowflake.Data.Core;
using Snowflake.Data.Core.Session;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Session
{
Expand All @@ -12,36 +13,36 @@ public void TestGrantSessionCreation()
{
// arrange
var tokens = new NonCountingSessionCreationTokenCounter();

// act
tokens.NewToken();

// assert
Assert.AreEqual(0, tokens.Count());
}

[Test]
public void TestCompleteSessionCreation()
{
// arrange
var tokens = new NonCountingSessionCreationTokenCounter();
var token = tokens.NewToken();

// act
tokens.RemoveToken(token);

// assert
Assert.AreEqual(0, tokens.Count());
}

[Test]
public void TestCompleteUnknownTokenDoesNotThrowExceptions()
{
// arrange
var tokens = new NonCountingSessionCreationTokenCounter();
tokens.NewToken();
var unknownToken = new SessionCreationToken(SFSessionHttpClientProperties.DefaultConnectionTimeout);

// act
tokens.RemoveToken(unknownToken);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NUnit.Framework;
using Snowflake.Data.Core.Session;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Session
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading;
using NUnit.Framework;
using Snowflake.Data.Core.Session;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Session
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NUnit.Framework;
using Snowflake.Data.Core;
using Snowflake.Data.Core.Session;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Session
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System;
using NUnit.Framework;
using Snowflake.Data.Core.Session;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Session
{
[TestFixture]
public class SessionCreationTokenTest
{
private static readonly TimeSpan s_timeout30Seconds = TimeSpan.FromSeconds(30);

[Test]
public void TestTokenIsNotExpired()
{
Expand All @@ -17,11 +18,11 @@ public void TestTokenIsNotExpired()

// act
var isExpired = token.IsExpired(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());

// assert
Assert.IsFalse(isExpired);
}

[Test]
public void TestTokenIsExpired()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
using NUnit.Framework;
using Snowflake.Data.Core;
using Snowflake.Data.Core.Session;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Session
{
[TestFixture]
public class SessionOrCreationTokensTest
{
private SFSession _session = new SFSession("account=test;user=test;password=test", null);

[Test]
public void TestNoBackgroundSessionsToCreateWhenInitialisedWithSession()
{
// arrange
var sessionOrTokens = new SessionOrCreationTokens(_session);

// act
var backgroundCreationTokens = sessionOrTokens.BackgroundSessionCreationTokens();

Expand All @@ -32,14 +33,14 @@ public void TestReturnFirstCreationToken()
.Select(_ => sessionCreationTokenCounter.NewToken())
.ToList();
var sessionOrTokens = new SessionOrCreationTokens(tokens);

// act
var token = sessionOrTokens.SessionCreationToken();

// assert
Assert.AreSame(tokens[0], token);
}

[Test]
public void TestReturnCreationTokensFromTheSecondOneForBackgroundExecution()
{
Expand All @@ -49,10 +50,10 @@ public void TestReturnCreationTokensFromTheSecondOneForBackgroundExecution()
.Select(_ => sessionCreationTokenCounter.NewToken())
.ToList();
var sessionOrTokens = new SessionOrCreationTokens(tokens);

// act
var backgroundTokens = sessionOrTokens.BackgroundSessionCreationTokens();

// assert
Assert.AreEqual(2, backgroundTokens.Count);
Assert.AreSame(tokens[1], backgroundTokens[0]);
Expand Down
1 change: 1 addition & 0 deletions Snowflake.Data.Tests/UnitTests/Session/SessionPoolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Snowflake.Data.Core.Session;
using Snowflake.Data.Core.Tools;
using Snowflake.Data.Tests.Util;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Session
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NUnit.Framework;
using Snowflake.Data.Core;
using Snowflake.Data.Core.Session;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Session
{
Expand Down
1 change: 1 addition & 0 deletions Snowflake.Data.Tests/UnitTests/Session/WaitingQueueTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using NUnit.Framework;
using Snowflake.Data.Core.Session;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Session
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NUnit.Framework;
using Snowflake.Data.Client;
using Snowflake.Data.Core.Session;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NUnit.Framework;
using Snowflake.Data.Core.Tools;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Tools
{
Expand Down
1 change: 1 addition & 0 deletions Snowflake.Data.Tests/UnitTests/Tools/TimeoutHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using NUnit.Framework;
using Snowflake.Data.Core.Tools;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.UnitTests.Tools
{
Expand Down
11 changes: 6 additions & 5 deletions Snowflake.Data.Tests/Util/AwaiterTest.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
using System;
using NUnit.Framework;
using Assert = NUnit.Framework.Legacy.ClassicAssert;

namespace Snowflake.Data.Tests.Util
{
[TestFixture]
public class AwaiterTest
{
private readonly TimeSpan _maxDurationRegardedAsImmediately = TimeSpan.FromSeconds(1);

[Test]
public void TestReturnsImmediatelyWhenConditionIsMet()
{
// act
var millis = MillisecondsOfWaiting(() => true, TimeSpan.FromHours(1));

// assert
Assert.LessOrEqual(millis, _maxDurationRegardedAsImmediately.TotalMilliseconds);
}
Expand All @@ -23,7 +24,7 @@ public void TestReturnsImmediatelyOnZeroTimeout()
{
// act
var millis = MillisecondsOfWaiting(() => false, TimeSpan.FromMilliseconds(0));

// assert
Assert.LessOrEqual(millis, _maxDurationRegardedAsImmediately.TotalMilliseconds);
}
Expand All @@ -33,10 +34,10 @@ public void TestReturnsOnTimeout()
{
// arrange
var timeout = TimeSpan.FromSeconds(2);

// act
var millis = MillisecondsOfWaiting(() => false, TimeSpan.FromSeconds(2));

// assert
Assert.GreaterOrEqual(millis, _maxDurationRegardedAsImmediately.TotalMilliseconds);
Assert.LessOrEqual(millis, timeout.TotalMilliseconds + _maxDurationRegardedAsImmediately.TotalMilliseconds);
Expand Down

0 comments on commit 7a8f956

Please sign in to comment.