Agilent.Testables.AppDomain
1.0.8
Prefix Reserved
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Framework 4.8
This package targets .NET Framework 4.8. The package is compatible with this framework or higher.
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" />
<PackageReference Include="Agilent.Testables.AppDomain" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Agilent.Testables.AppDomain&version=1.0.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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
- Pass
IAppDomainFactory
as a dependency via the constructor into the class utilizeIAppDomain
:
public class TestableClass
{
private readonly IAppDomainFactory _appDomainFactory;
public TestableClass(IAppDomainFactory appDomainFactory)
{
_appDomainFactory = appDomainFactory;
}
public string GetBaseDirectory()
{
IAppDomain appDomain = _appDomainFactory.CurrentDomain;
return _appDomain.BaseDirectory;
}
}
- In your IOC Container register
IAppDomainFactory
andAgilent.Testables.AppDomainFactory
:
_services.AddTransient<IAppDomainFactory, AppDomainFactory>();
- 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 | Versions 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.
Initial release