Skip to content

Latest commit

 

History

History
110 lines (78 loc) · 3.4 KB

File metadata and controls

110 lines (78 loc) · 3.4 KB

NetEvolve.ProjectBuilders.TUnit

NuGet Version NuGet Downloads License

Test utilities for TUnit-based .NET projects, providing helpers for temporary directory management and test environment setup.

Features

  • Temporary directory management for integration tests
  • Utilities for test environment setup and teardown
  • Seamless integration with TUnit test framework

Installation

NuGet Package Manager

Install-Package NetEvolve.ProjectBuilders.TUnit

.NET CLI

dotnet add package NetEvolve.ProjectBuilders.TUnit

PackageReference

<PackageReference Include="NetEvolve.ProjectBuilders.TUnit" />

Quick Start

using NetEvolve.ProjectBuilders.TUnit;
using TUnit;

[ClassDataSource<TemporaryDirectory>]
public class MyTests(TemporaryDirectory directory)
{
    [Test]
    public void TestCreateFile()
    {
        // Create a file in the temporary directory
        using var stream = directory.CreateFile("test.txt");
        // Write to the file (example)
        stream.Write(new byte[] { 1, 2, 3 }, 0, 3);

        string filePath = directory.GetFilePath("test.txt");
        Assert.That(File.Exists(filePath));
    }
}

Usage

Basic Example

[ClassDataSource<TemporaryDirectory>]
public class ExampleTests(TemporaryDirectory directory)
{
    [Test]
    public void TestDirectoryAndFiles()
    {
        // Use directory.FullPath for test files
        var subDir = directory.CreateDirectory("sub");
        using var file = directory.CreateFile("sample.txt");
        file.WriteByte(42);
        string filePath = directory.GetFilePath("sample.txt");
        Assert.That(File.Exists(filePath));
    }
}

Requirements

  • .NET 8.0 or higher
  • TUnit

Related Packages

Documentation

For complete documentation, please visit the official documentation.

Contributing

Contributions are welcome! Please read the Contributing Guidelines before submitting a pull request.

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.


Note

Made with ❤️ by the NetEvolve Team Visit us at https://www.daily-devops.net for more information about our services and solutions.