mirror of https://github.com/dahall/Vanara.git
Exposed TempFile to all tests in Kernel32
parent
d7eaafbb3b
commit
6b5cea3719
|
@ -453,28 +453,28 @@ namespace Vanara.PInvoke.Tests
|
|||
Assert.That(b, Is.True);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class TempFile : IDisposable
|
||||
internal class TempFile : IDisposable
|
||||
{
|
||||
public const string tmpstr = @"Temporary";
|
||||
|
||||
public TempFile(Kernel32.FileAccess dwDesiredAccess, FileShare dwShareMode, FileMode dwCreationDisposition = FileMode.OpenOrCreate, FileFlagsAndAttributes dwFlagsAndAttributes = FileFlagsAndAttributes.FILE_ATTRIBUTE_NORMAL) : this()
|
||||
{
|
||||
public const string tmpstr = @"Temporary";
|
||||
hFile = CreateFile(FullName, dwDesiredAccess, dwShareMode, null, dwCreationDisposition, dwFlagsAndAttributes, IntPtr.Zero);
|
||||
}
|
||||
|
||||
public TempFile(Kernel32.FileAccess dwDesiredAccess, FileShare dwShareMode, FileMode dwCreationDisposition = FileMode.OpenOrCreate, FileFlagsAndAttributes dwFlagsAndAttributes = FileFlagsAndAttributes.FILE_ATTRIBUTE_NORMAL) : this()
|
||||
{
|
||||
hFile = CreateFile(FullName, dwDesiredAccess, dwShareMode, null, dwCreationDisposition, dwFlagsAndAttributes, IntPtr.Zero);
|
||||
}
|
||||
public TempFile(string contents = tmpstr)
|
||||
{
|
||||
FullName = Path.GetTempFileName(); File.WriteAllText(FullName, contents);
|
||||
}
|
||||
|
||||
public TempFile(string contents = tmpstr)
|
||||
{
|
||||
FullName = Path.GetTempFileName(); File.WriteAllText(FullName, contents);
|
||||
}
|
||||
public string FullName { get; }
|
||||
public SafeHFILE hFile { get; }
|
||||
|
||||
public string FullName { get; }
|
||||
public SafeHFILE hFile { get; }
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
hFile?.Dispose(); File.Delete(FullName);
|
||||
}
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
hFile?.Dispose(); File.Delete(FullName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
|
@ -32,6 +32,7 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
@ -46,6 +47,8 @@
|
|||
<Compile Include="AppModelTests.cs" />
|
||||
<Compile Include="InterlockedApiTests.cs" />
|
||||
<Compile Include="InteropServices\SafeLocalHandleTests.cs" />
|
||||
<Compile Include="NamedPipeApiTests.cs" />
|
||||
<Compile Include="MemoryApiTests.cs" />
|
||||
<Compile Include="LibLoaderApiTests.cs" />
|
||||
<Compile Include="JobApiTests.cs" />
|
||||
<Compile Include="IoApiSetTests.cs" />
|
||||
|
|
Loading…
Reference in New Issue