Class HostsFixture
Used to manage the local DNS resolverhosts file on the current computer.
Implements
Inherited Members
Namespace: Neon.Xunit
Assembly: Neon.Xunit.dll
Syntax
public class HostsFixture : TestFixture, ITestFixture
Remarks
note
IMPORTANT: The base Neon TestFixture implementation DOES NOT
support parallel test execution. You need to explicitly disable parallel execution in
all test assemblies that rely on thesex test fixtures by adding a C# file called
AssemblyInfo.cs
with:
[assembly: CollectionBehavior(DisableTestParallelization = true, MaxParallelThreads = 1)]
and then define your test classes like:
public class MyTests : IClassFixture<HostsFixture>, IDisposable
{
[Collection(TestCollection.NonParallel)]
[CollectionDefinition(TestCollection.NonParallel, DisableParallelization = true)]
[Fact]
public void Test()
{
}
}
Constructors
HostsFixture()
Constructs the fixture.
Declaration
public HostsFixture()
Methods
AddHostAddress(string, string, bool)
Adds an IP address to the local DNS resolver's hosts file.
Declaration
public void AddHostAddress(string hostname, string address, bool deferCommit = false)
Parameters
Type | Name | Description |
---|---|---|
string | hostname | The hostname. |
string | address | The IP address. |
bool | deferCommit | Optionally indicates that the change will not be committed to the hosts
until Commit() is called. This defaults to |
Remarks
note
This method will not add the duplicate hostname/address mappings to the fixture.
Commit()
Commits the DNS records to the hosts file.
Declaration
public void Commit()
Dispose(bool)
Releases all associated resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | Pass |
Overrides
EnsureReset()
Called by TestFixture to ensure that the hosts file contains no DNS records remaining after an interrupted test run.
Declaration
public static void EnsureReset()
~HostsFixture()
Finalizer.
Declaration
protected ~HostsFixture()
Reset()
INTERNAL USE ONLY: Resets the fixture state.
Declaration
public override void Reset()