-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Start to add Unit tests to perform speed / stability confirmation
NOTE: Current code base is not stable !
- Loading branch information
smurfiv_cp
authored and
smurfiv_cp
committed
Nov 7, 2012
1 parent
61619f9
commit 90e8e29
Showing
20 changed files
with
712 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<configSections> | ||
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/> | ||
</configSections> | ||
<!-- Stick the namespaces in .. this is supposed to allow the intellisense to work ;-) --> | ||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<variable name="LogDir" value="${specialfolder:folder=CommonApplicationData}/LiquesceSvc/Logs"/> | ||
<targets> | ||
<target name="console" xsi:type="Console" | ||
layout="${longdate}[${threadid}] ${level:uppercase=true} ${logger}: ${message} ${exception:format=ToString}" | ||
> | ||
</target> | ||
</targets> | ||
|
||
<rules> | ||
<logger name="*" minlevel="Trace" writeTo="console"/> | ||
</rules> | ||
</nlog> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using NLog; | ||
|
||
namespace DokanTesting | ||
{ | ||
static public class CommonFuncs | ||
{ | ||
static private readonly Logger Log = LogManager.GetCurrentClassLogger(); | ||
|
||
public static bool CheckExistenceOfMount(string mountPoint) | ||
{ | ||
if (mountPoint.Length == 1) | ||
{ | ||
string path = string.Format("{0}:{1}", mountPoint, Path.DirectorySeparatorChar); | ||
if (!Directory.Exists(path)) | ||
{ | ||
return false; | ||
} | ||
// 2nd phase as the above is supposed to be cheap but can return false +ves | ||
{ | ||
string[] drives = Environment.GetLogicalDrives(); | ||
return (Array.Exists(drives, dr => dr.Remove(1) == mountPoint)); | ||
} | ||
} | ||
else | ||
{ | ||
DirectoryInfo di = new DirectoryInfo(mountPoint); | ||
return ((di.Attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{73EC480E-46DD-4D3B-9E9E-3BF2EC1213BD}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>DokanTesting</RootNamespace> | ||
<AssemblyName>DokanTesting</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<SccProjectName>SAK</SccProjectName> | ||
<SccLocalPath>SAK</SccLocalPath> | ||
<SccAuxPath>SAK</SccAuxPath> | ||
<SccProvider>SAK</SccProvider> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="NLog"> | ||
<HintPath>..\ThirdParty\NLog.dll</HintPath> | ||
</Reference> | ||
<Reference Include="nunit.core"> | ||
<HintPath>..\ThirdParty\NUnit\nunit.core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="nunit.framework"> | ||
<HintPath>..\ThirdParty\NUnit\nunit.framework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\LiquesceFaçade\Utils.cs"> | ||
<Link>Utils.cs</Link> | ||
</Compile> | ||
<Compile Include="CommonFuncs.cs" /> | ||
<Compile Include="MountTests.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="TestDokanOperations.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\ThirdParty\DokanNet\DokanNet.csproj"> | ||
<Project>{A09B408A-26A0-4FF8-83D5-6E1B1DA5F63C}</Project> | ||
<Name>DokanNet</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<PostBuildEvent>copy "$(ProjectDir)..\Thirdparty\Dokan_x64\x64\$(ConfigurationName)\Dokan.dll" "$(TargetDir)"</PostBuildEvent> | ||
</PropertyGroup> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"" | ||
{ | ||
"FILE_VERSION" = "9237" | ||
"ENLISTMENT_CHOICE" = "NEVER" | ||
"PROJECT_FILE_RELATIVE_PATH" = "" | ||
"NUMBER_OF_EXCLUDED_FILES" = "0" | ||
"ORIGINAL_PROJECT_FILE_PATH" = "" | ||
"NUMBER_OF_NESTED_PROJECTS" = "0" | ||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using DokanNet; | ||
using NLog; | ||
using NUnit.Framework; | ||
|
||
namespace DokanTesting | ||
{ | ||
[TestFixture] | ||
[Description("These tests excercise the mount### API's.")] | ||
[Category("Mount")] | ||
public class MountTests | ||
{ | ||
static private readonly Logger Log = LogManager.GetCurrentClassLogger(); | ||
private List<string> mountedPoints = new List<string>(); | ||
|
||
[TestFixtureSetUp] | ||
public void Init() | ||
{ | ||
Log.Warn("Test @ [{0}]", "Warn"); | ||
Log.Debug("Test @ [{0}]", "Debug"); | ||
Log.Trace("Test @ [{0}]", "Trace"); | ||
Log.Info("DokanVersion:[{0}], DokanDriverVersion[{1}]", Dokan.DokanVersion(), Dokan.DokanDriverVersion()); | ||
Dokan.DokanSetDebugMode(true); | ||
|
||
} | ||
|
||
[TestFixtureTearDown] | ||
public void Dispose() | ||
{ | ||
foreach (string point in mountedPoints) | ||
{ | ||
if (point.Length == 1) | ||
Dokan.DokanUnmount(point[0]); | ||
else | ||
Dokan.DokanRemoveMountPoint(point); | ||
} | ||
} | ||
|
||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
} | ||
|
||
[TearDown] | ||
public void TearDown() | ||
{ | ||
} | ||
|
||
|
||
|
||
[Test] | ||
[Description("Check that it is possible to perform a simple mount.")] | ||
public void A010SimpleLetterMount() | ||
{ | ||
mountedPoints.Add("M"); | ||
DokanOptions options = new DokanOptions | ||
{ | ||
MountPoint = "M", | ||
ThreadCount = 1, | ||
DebugMode = true | ||
}; | ||
TestLayer testLayer = new TestLayer(); | ||
ThreadPool.QueueUserWorkItem(testLayer.Start, options); | ||
|
||
|
||
Assert.That(() => CommonFuncs.CheckExistenceOfMount(options.MountPoint), Is.True.After(50000, 100), "CheckExistenceOfMount"); | ||
|
||
//Assert.That(() => testLayer.RetVal, Is.EqualTo(Dokan.DOKAN_SUCCESS).After(500, 50), | ||
// "Expected result after 500ms"); | ||
|
||
|
||
} | ||
|
||
[Test] | ||
[Description("Check that it is possible to perform a simple mount.")] | ||
public void A020SimpleDirMount() | ||
{ | ||
mountedPoints.Add("C:\\blam\\test"); | ||
DokanOptions options = new DokanOptions | ||
{ | ||
MountPoint = "C:\\blam\\test", | ||
ThreadCount = 1, | ||
DebugMode = true | ||
}; | ||
TestLayer testLayer = new TestLayer(); | ||
ThreadPool.QueueUserWorkItem(testLayer.Start, options); | ||
Thread.Sleep(20*1000); | ||
|
||
//Assert.That(() => CommonFuncs.CheckExistenceOfMount(options.MountPoint), Is.True.After(50000, 100), "CheckExistenceOfMount"); | ||
|
||
} | ||
|
||
} | ||
|
||
public class TestLayer | ||
{ | ||
public TestLayer() | ||
{ | ||
RetVal = Dokan.DOKAN_MOUNT_ERROR; | ||
} | ||
|
||
public void Start(object state) | ||
{ | ||
DokanOptions options = state as DokanOptions; | ||
IDokanOperations proxy = new TestDokanOperations(); | ||
RetVal = Dokan.DokanMain(options, proxy); | ||
} | ||
|
||
public int RetVal { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("DokanTesting")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("DokanTesting")] | ||
[assembly: AssemblyCopyright("Copyright © 2012")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("08a70825-c0ae-467d-9dfd-d8e32c3b183c")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Oops, something went wrong.