Skip to content

Commit

Permalink
Add new unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Komissarov committed May 24, 2024
1 parent d5802e9 commit a49ac0c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore ${{ matrix.project }}
Expand All @@ -44,7 +44,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore ${{ matrix.project }}
Expand Down
13 changes: 8 additions & 5 deletions Tms.Adapter.CoreTests/Configurator/ConfiguratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ namespace Tms.Adapter.CoreTests.Configurator;
[TestClass]
public class ConfiguratorTests
{
[TestMethod]
public void ConvertAutoTestDtoToPostModel()
[TestInitialize]
public void InitializeTest()
{
// Arrange
Environment.SetEnvironmentVariable("TMS_URL", "https://example.com");
Environment.SetEnvironmentVariable("TMS_PRIVATE_TOKEN", "token");
Environment.SetEnvironmentVariable("TMS_PROJECT_ID", Guid.NewGuid().ToString());
Environment.SetEnvironmentVariable("TMS_CONFIGURATION_ID", Guid.NewGuid().ToString());
Environment.SetEnvironmentVariable("TMS_TEST_RUN_ID", Guid.NewGuid().ToString());

Environment.SetEnvironmentVariable("TMS_TEST_RUN_ID", Guid.NewGuid().ToString());
}

[TestMethod]
public void GetConfig()
{
// Act
var actual = Core.Configurator.Configurator.GetConfig();

Expand Down
54 changes: 54 additions & 0 deletions Tms.Adapter.CoreTests/Service/AdapterTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
namespace Tms.Adapter.CoreTests.Service;

[TestClass]
public class AdapterTests
{
[TestInitialize]
public void InitializeTest()
{
Environment.SetEnvironmentVariable("TMS_URL", "https://example.com");
Environment.SetEnvironmentVariable("TMS_PRIVATE_TOKEN", "token");
Environment.SetEnvironmentVariable("TMS_PROJECT_ID", Guid.NewGuid().ToString());
Environment.SetEnvironmentVariable("TMS_CONFIGURATION_ID", Guid.NewGuid().ToString());
Environment.SetEnvironmentVariable("TMS_TEST_RUN_ID", Guid.NewGuid().ToString());
}

[TestMethod]
public void AddMessage()
{
// Arrange
const string message = "test";

// Act & Assert
Core.Service.Adapter.AddMessage(message);
}

[TestMethod]
public void AddAttachments()
{
var filename = Path.GetRandomFileName();

try
{
// Arrange
File.Create(filename).Dispose();

// Act & Assert
Assert.ThrowsException<AggregateException>(() => Core.Service.Adapter.AddAttachments(filename));
}
finally
{
File.Delete(filename);
}
}

[TestMethod]
public void AddLinks()
{
// Arrange
const string url = "https://example.com";

// Act & Assert
Core.Service.Adapter.AddLinks(url);
}
}

0 comments on commit a49ac0c

Please sign in to comment.