[TearDown] added

This commit is contained in:
Artemy
2025-11-04 11:51:37 +07:00
parent c720ae3667
commit c462d065f4
9 changed files with 60 additions and 0 deletions
@@ -380,4 +380,10 @@ public class SessionControllerTests
It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once()); It.IsAny<Func<It.IsAnyType, Exception, string>>()), Times.Once());
} }
#endregion #endregion
[TearDown]
public void TearDown()
{
_controller?.Dispose();
}
} }
+7
View File
@@ -4,6 +4,7 @@ using Govor.API.Hubs;
using Govor.Application.Interfaces.UserOnlineStatus; using Govor.Application.Interfaces.UserOnlineStatus;
using Govor.Core.Models.Users; using Govor.Core.Models.Users;
using Govor.Core.Repositories.Users; using Govor.Core.Repositories.Users;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Moq; using Moq;
@@ -186,4 +187,10 @@ public class PresenceHubTests
It.IsAny<CancellationToken>()), It.IsAny<CancellationToken>()),
Times.Never); Times.Never);
} }
[TearDown]
public void TearDown()
{
_hub?.Dispose();
}
} }
@@ -257,4 +257,10 @@ public class ChatLoadControllerTests
// Assert // Assert
Assert.That(result, Is.InstanceOf<BadRequestObjectResult>()); Assert.That(result, Is.InstanceOf<BadRequestObjectResult>());
} }
[TearDown]
public void TearDown()
{
_controller?.Dispose();
}
} }
@@ -199,4 +199,10 @@ public class FriendsRequestQueryControllerTests
var objectResult = result as ObjectResult; var objectResult = result as ObjectResult;
Assert.That(objectResult.StatusCode, Is.EqualTo(500)); Assert.That(objectResult.StatusCode, Is.EqualTo(500));
} }
[TearDown]
public void TearDown()
{
_controller?.Dispose();
}
} }
@@ -112,6 +112,13 @@ public class OnlinePingingControllerTests
_loggerMock.VerifyLog(LogLevel.Error, exception.Message, Times.Once()); _loggerMock.VerifyLog(LogLevel.Error, exception.Message, Times.Once());
_pingHandlerServiceMock.Verify(x => x.Ping(It.IsAny<Guid>()), Times.Never()); _pingHandlerServiceMock.Verify(x => x.Ping(It.IsAny<Guid>()), Times.Never());
} }
[TearDown]
public void TearDown()
{
_controller?.Dispose();
}
} }
// Helper extension for verifying logger calls // Helper extension for verifying logger calls
@@ -114,4 +114,11 @@ public class RefreshControllerTests
// Assert // Assert
Assert.That(result, Is.InstanceOf<BadRequestObjectResult>()); Assert.That(result, Is.InstanceOf<BadRequestObjectResult>());
} }
[TearDown]
public void TearDown()
{
_controller?.Dispose();
}
} }
@@ -3,6 +3,7 @@ using Govor.API.Common.SignalR.Helpers;
using Govor.API.Hubs; using Govor.API.Hubs;
using Govor.Application.Interfaces; using Govor.Application.Interfaces;
using Govor.Application.Interfaces.Messages; using Govor.Application.Interfaces.Messages;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Moq; using Moq;
@@ -44,4 +45,11 @@ public class ChatsHubTests
{ {
} }
[TearDown]
public void TearDown()
{
_chatsHub?.Dispose();
}
} }
@@ -335,4 +335,10 @@ public class FriendsHubTests
Assert.That(result.Status, Is.EqualTo(HubResultStatus.ServerError)); Assert.That(result.Status, Is.EqualTo(HubResultStatus.ServerError));
Assert.That(result.ErrorMessage, Is.EqualTo("Unexpected error! Please try later!")); Assert.That(result.ErrorMessage, Is.EqualTo("Unexpected error! Please try later!"));
} }
[TearDown]
public void TearDown()
{
_hub?.Dispose();
}
} }
@@ -55,4 +55,11 @@ public class PingHandlerServiceTests
// Assert // Assert
Assert.That(updatedUser.WasOnline, Is.EqualTo(originalTime)); Assert.That(updatedUser.WasOnline, Is.EqualTo(originalTime));
} }
[TearDown]
public void TearDown()
{
_dbContext?.Dispose();
_memoryCache?.Dispose();
}
} }