Skip to content

Commit

Permalink
Mocking logging conflicts with parallelized tests, removing unnecessa…
Browse files Browse the repository at this point in the history
…ry checks
  • Loading branch information
MichaelGHSeg committed Feb 23, 2024
1 parent 452645f commit 049fd33
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions Tests/StateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ public void TestSystemDefaultState()
[Fact]
public void TestSystemDefaultStateEmpty()
{
var logger = new Mock<ISegmentLogger>();
Analytics.Logger = logger.Object;

_storage
.Setup(o => o.Read(It.IsAny<StorageConstants>()))
.Returns("");
Expand All @@ -70,26 +67,20 @@ public void TestSystemDefaultStateEmpty()
Assert.Equal(_configuration, actual._configuration);
Assert.Equal(_settings.Integrations.ToString(), actual._settings.Integrations.ToString());
Assert.False(actual._running);
logger.Verify(o => o.Log(LogLevel.Information, null, It.Is<string>(s => s.Contains("No settings loaded"))), Times.AtLeastOnce());
}

[Fact]
public void TestSystemDefaultStateException()
{
var logger = new Mock<ISegmentLogger>();
Analytics.Logger = logger.Object;
var exception = new Exception();

_storage
.Setup(o => o.Read(It.IsAny<StorageConstants>()))
.Throws(exception);
.Throws<Exception>();

var actual = Segment.Analytics.System.DefaultState(_configuration, _storage.Object);

Assert.Equal(_configuration, actual._configuration);
Assert.Equal(_settings.Integrations.ToString(), actual._settings.Integrations.ToString());
Assert.False(actual._running);
logger.Verify(o => o.Log(LogLevel.Error, exception, It.Is<string>(s => s.Contains("Failed to load"))), Times.Exactly(1));
}

[Fact]
Expand Down

0 comments on commit 049fd33

Please sign in to comment.