Agilent.Testables.AppDomain 1.0.8

Prefix Reserved
dotnet add package Agilent.Testables.AppDomain --version 1.0.8
                    
NuGet\Install-Package Agilent.Testables.AppDomain -Version 1.0.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Agilent.Testables.AppDomain" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Agilent.Testables.AppDomain" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Agilent.Testables.AppDomain" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Agilent.Testables.AppDomain --version 1.0.8
                    
#r "nuget: Agilent.Testables.AppDomain, 1.0.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Agilent.Testables.AppDomain&version=1.0.8
                    
Install Agilent.Testables.AppDomain as a Cake Addin
#tool nuget:?package=Agilent.Testables.AppDomain&version=1.0.8
                    
Install Agilent.Testables.AppDomain as a Cake Tool

Agilent.Testables.AppDomain

This package contains an abstraction of the static System.AppDomain class found in .NET Framework 4.8 and above. It allows for an IAppDominFactory interface to be used instead of the static class and for mocks to be created.

Usage

  1. Pass IAppDomainFactory as a dependency via the constructor into the class utilize IAppDomain:
public class TestableClass
{
    private readonly IAppDomainFactory _appDomainFactory;

    public TestableClass(IAppDomainFactory appDomainFactory)
    {
        _appDomainFactory = appDomainFactory;
    }

    public string GetBaseDirectory()
    {
        IAppDomain appDomain = _appDomainFactory.CurrentDomain;
        return _appDomain.BaseDirectory;
    }
}
  1. In your IOC Container register IAppDomainFactory and Agilent.Testables.AppDomainFactory:
_services.AddTransient<IAppDomainFactory, AppDomainFactory>();
  1. In your tests, setup and use IAppDomainFactory and IAppDomain as required:
    [TestMethod]
    public void Should_GetBaseDirectory()
    {
        // Arrange
        var baseDirectory = @"C:\AppBaseDirectory";
        var mockAppDomain = new Mock<IAppDomain>();
        mockAppDomain.Setup(x => x.BaseDirectory).Returns(baseDirectory);
        var mockAppDomainFactory = new Mock<IAppDomainFactory>();
        mockAppDomainFactory.Setup(x => x.CurrentDomain).Returns(mockAppDomain.Object);
        var sut = new TestableClass(mockAppDomainFactory.Object);

        // Act
        var result = sut.GetBaseDirectory();

        // Assert
        result.Should().Be(baseDirectory);
    }
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.
  • .NETFramework 4.8.1

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.8 142 1/7/2025
1.0.6-dev 86 1/2/2025

Initial release