Skip to content

Commit

Permalink
Updated everything wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Amsellem committed Sep 1, 2017
1 parent 08edf5d commit 5b2a39e
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 83 deletions.
39 changes: 21 additions & 18 deletions EverythingNet.Tests/AcceptanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace EverythingNet.Tests
[TestFixture]
public class AcceptanceTests
{
private const string FileToSearchA = "EverythingState.cs";
private const string FileToSearchB = "DateSearchTests.cs";

private Everything everyThing;

[SetUp]
Expand All @@ -31,20 +34,20 @@ public void Query()
{
var queryable = new Everything()
.Search()
.Name("AcceptanceTests.cs")
.Name(FileToSearchA)
.Or
.Name("SearchResult.cs");
.Name(FileToSearchB);

Assert.That(queryable.Where(x => x.FileName == "AcceptanceTests.cs"), Is.Not.Empty);
Assert.That(queryable.Where(x => x.FileName == "SearchResult.cs"), Is.Not.Empty);
Assert.That(queryable.Where(x => x.FileName == FileToSearchA), Is.Not.Empty);
Assert.That(queryable.Where(x => x.FileName == FileToSearchB), Is.Not.Empty);
}

[Test]
public void SearchGetSize()
{
var queryable = new Everything()
.Search()
.Name("AcceptanceTests.cs");
.Name(FileToSearchA);

foreach (var result in queryable)
{
Expand All @@ -57,11 +60,11 @@ public void SearchGetFileName()
{
var queryable = new Everything()
.Search()
.Name("AcceptanceTests.cs");
.Name(FileToSearchA);

foreach (var result in queryable)
{
Assert.That(result.FileName, Is.EqualTo("AcceptanceTests.cs"));
Assert.That(result.FileName, Is.EqualTo(FileToSearchA));
}
}

Expand All @@ -70,7 +73,7 @@ public void SearchGetPath()
{
var queryable = new Everything()
.Search()
.Name("AcceptanceTests.cs");
.Name(FileToSearchA);

foreach (var result in queryable)
{
Expand All @@ -83,11 +86,11 @@ public void SearchGetFullPath()
{
var queryable = new Everything()
.Search()
.Name("AcceptanceTests.cs");
.Name(FileToSearchA);

foreach (var result in queryable)
{
Assert.That(result.FullPath, Does.Contain("EverythingNet\\EverythingNet.Tests\\AcceptanceTests.cs").IgnoreCase);
Assert.That(result.FullPath, Does.Contain($"EverythingNet\\core\\{FileToSearchA}").IgnoreCase);
}
}

Expand All @@ -96,7 +99,7 @@ public void SearchGetDate()
{
var queryable = new Everything()
.Search()
.Name("AcceptanceTests.cs");
.Name(FileToSearchA);

foreach (var result in queryable)
{
Expand All @@ -112,7 +115,7 @@ public void SearchGetAttributes()
{
var queryable = new Everything()
.Search()
.Name("AcceptanceTests.cs");
.Name(FileToSearchA);

foreach (var result in queryable)
{
Expand All @@ -124,10 +127,10 @@ public void SearchGetAttributes()
public void StressTest()
{
// Arrange
var queryable = this.everyThing.Search().Name("AcceptanceTests.cs");
var queryable = this.everyThing.Search().Name(FileToSearchA);

// Assert
Assert.That(everyThing.LastErrorCode, Is.EqualTo(ErrorCode.Ok));
Assert.That(this.everyThing.LastErrorCode, Is.EqualTo(ErrorCode.Ok));
Assert.That(queryable, Is.Not.Null);
Assert.That(queryable, Is.Not.Empty);
}
Expand All @@ -136,8 +139,8 @@ public void StressTest()
[Test, Ignore("Not yet ready")]
public void ThreadSafety()
{
ManualResetEventSlim resetEvent1 = this.StartSearchInBackground("Everything.cs");
ManualResetEventSlim resetEvent2 = this.StartSearchInBackground("AcceptanceTests.cs");
ManualResetEventSlim resetEvent1 = this.StartSearchInBackground(FileToSearchA);
ManualResetEventSlim resetEvent2 = this.StartSearchInBackground(FileToSearchB);

Assert.That(resetEvent1.Wait(15000), Is.True);
Assert.That(resetEvent2.Wait(15000), Is.True);
Expand All @@ -151,12 +154,12 @@ private ManualResetEventSlim StartSearchInBackground(string searchString)
{
IEverything everything = new Everything();
everything.MatchWholeWord = true;

// Act
var results = everything.Search().Name(searchString);

// Assert
Assert.That(everyThing.LastErrorCode, Is.EqualTo(ErrorCode.Ok));
Assert.That(this.everyThing.LastErrorCode, Is.EqualTo(ErrorCode.Ok));
Assert.That(results, Is.Not.Empty);
foreach (var result in results)
{
Expand Down
6 changes: 3 additions & 3 deletions EverythingNet/Core/Everything.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ IEnumerable<ISearchResult> IEverythingInternal.SendSearch(string searchPattern)
EverythingWrapper.Everything_SetMatchCase(this.MatchCase);
EverythingWrapper.Everything_SetRequestFlags((uint)requestFlags);
searchPattern = this.ApplySearchResultKind(searchPattern);
EverythingWrapper.Everything_SetSearchA(searchPattern);
EverythingWrapper.Everything_QueryA(true);
EverythingWrapper.Everything_SetSearch(searchPattern);
EverythingWrapper.Everything_Query(true);

/* uint flags = EverythingWrapper.Everything_GetResultListRequestFlags();
Debug.Assert((RequestFlags)flags == requestFlags);*/
Expand Down Expand Up @@ -92,7 +92,7 @@ private IEnumerable<ISearchResult> GetResults()
{
var numResults = EverythingWrapper.Everything_GetNumResults();

return Enumerable.Range(0, numResults).Select(x => new SearchResult(x));
return Enumerable.Range(0, (int)numResults).Select(x => new SearchResult(x));
}

private ErrorCode GetError()
Expand Down
8 changes: 4 additions & 4 deletions EverythingNet/Core/EverythingState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public static bool IsReady()

public static Version GetVersion()
{
int major = EverythingWrapper.Everything_GetMajorVersion();
int minor = EverythingWrapper.Everything_GetMinorVersion();
int build = EverythingWrapper.Everything_GetBuildNumber();
int revision = EverythingWrapper.Everything_GetRevision();
UInt32 major = EverythingWrapper.Everything_GetMajorVersion();
UInt32 minor = EverythingWrapper.Everything_GetMinorVersion();
UInt32 build = EverythingWrapper.Everything_GetBuildNumber();
UInt32 revision = EverythingWrapper.Everything_GetRevision();

return new Version(Convert.ToInt32(major), Convert.ToInt32(minor), Convert.ToInt32(build), Convert.ToInt32(revision));
}
Expand Down
106 changes: 49 additions & 57 deletions EverythingNet/Core/EverythingWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,19 @@ internal static IDisposable Lock()
public static extern bool Everything_IsDBLoaded();

[DllImport(EverythingDLL)]
public static extern int Everything_GetMajorVersion();
public static extern UInt32 Everything_GetMajorVersion();

[DllImport(EverythingDLL)]
public static extern int Everything_GetMinorVersion();
public static extern UInt32 Everything_GetMinorVersion();

[DllImport(EverythingDLL)]
public static extern int Everything_GetRevision();
public static extern UInt32 Everything_GetRevision();

[DllImport(EverythingDLL)]
public static extern int Everything_GetBuildNumber();

[DllImport(EverythingDLL, CharSet = CharSet.Unicode)]
public static extern int Everything_SetSearchW(string lpSearchString);
public static extern UInt32 Everything_GetBuildNumber();

[DllImport(EverythingDLL)]
public static extern int Everything_SetSearchA(string lpSearchString);
public static extern int Everything_SetSearch(string lpSearchString);

[DllImport(EverythingDLL)]
public static extern void Everything_SetMatchPath(bool bEnable);
Expand All @@ -79,16 +76,16 @@ internal static IDisposable Lock()
public static extern void Everything_SetRegex(bool bEnable);

[DllImport(EverythingDLL)]
public static extern void Everything_SetMax(int dwMax);
public static extern void Everything_SetMax(UInt32 dwMax);

[DllImport(EverythingDLL)]
public static extern void Everything_SetOffset(int dwOffset);
public static extern void Everything_SetOffset(UInt32 dwOffset);

[DllImport(EverythingDLL)]
public static extern void Everything_SetReplyWindow(IntPtr handler);

[DllImport(EverythingDLL)]
public static extern void Everything_SetReplyID(uint nId);
public static extern void Everything_SetReplyID(UInt32 nId);

[DllImport(EverythingDLL)]
public static extern void Everything_Reset();
Expand All @@ -106,130 +103,125 @@ internal static IDisposable Lock()
public static extern bool Everything_GetRegex();

[DllImport(EverythingDLL)]
public static extern uint Everything_GetMax();

[DllImport(EverythingDLL)]
public static extern uint Everything_GetOffset();
public static extern UInt32 Everything_GetMax();

[DllImport(EverythingDLL)]
public static extern IntPtr Everything_GetSearchW();
public static extern UInt32 Everything_GetOffset();

[DllImport(EverythingDLL)]
public static extern IntPtr Everything_GetSearchA();
public static extern IntPtr Everything_GetSearch();

[DllImport(EverythingDLL)]
public static extern int Everything_GetLastError();

[DllImport(EverythingDLL)]
public static extern bool Everything_QueryW(bool bWait);

[DllImport(EverythingDLL)]
public static extern bool Everything_QueryA(bool bWait);
public static extern bool Everything_Query(bool bWait);

[DllImport(EverythingDLL)]
public static extern void Everything_SortResultsByPath();

[DllImport(EverythingDLL)]
public static extern int Everything_GetNumFileResults();
public static extern UInt32 Everything_GetNumFileResults();

[DllImport(EverythingDLL)]
public static extern int Everything_GetNumFolderResults();
public static extern UInt32 Everything_GetNumFolderResults();

[DllImport(EverythingDLL)]
public static extern int Everything_GetNumResults();
public static extern UInt32 Everything_GetNumResults();

[DllImport(EverythingDLL)]
public static extern int Everything_GetTotFileResults();
public static extern UInt32 Everything_GetTotFileResults();

[DllImport(EverythingDLL)]
public static extern int Everything_GetTotFolderResults();
public static extern UInt32 Everything_GetTotFolderResults();

[DllImport(EverythingDLL)]
public static extern int Everything_GetTotResults();
public static extern UInt32 Everything_GetTotResults();

[DllImport(EverythingDLL)]
public static extern bool Everything_IsVolumeResult(uint nIndex);
public static extern bool Everything_IsVolumeResult(UInt32 nIndex);

[DllImport(EverythingDLL)]
public static extern bool Everything_IsFolderResult(uint nIndex);
public static extern bool Everything_IsFolderResult(UInt32 nIndex);

[DllImport(EverythingDLL)]
public static extern bool Everything_IsFileResult(uint nIndex);

[DllImport(EverythingDLL)]
public static extern void Everything_GetResultFullPathNameA(uint nIndex, StringBuilder lpString, int nMaxCount);
public static extern bool Everything_IsFileResult(UInt32 nIndex);

[DllImport(EverythingDLL, CharSet = CharSet.Unicode)]
public static extern void Everything_GetResultFullPathNameW(uint nIndex, StringBuilder lpString, int nMaxCount);
public static extern void Everything_GetResultFullPathName(UInt32 nIndex, StringBuilder lpString, UInt32 nMaxCount);

// Everything 1.4
[DllImport(EverythingDLL)]
public static extern void Everything_SetSort(uint dwSortType);
public static extern void Everything_SetSort(UInt32 dwSortType);


[DllImport(EverythingDLL)]
public static extern UInt32 Everything_GetSort();

[DllImport(EverythingDLL)]
public static extern uint Everything_GetResultListSort();
public static extern UInt32 Everything_GetResultListSort();

[DllImport(EverythingDLL)]
public static extern void Everything_SetRequestFlags(uint dwRequestFlags);
public static extern void Everything_SetRequestFlags(UInt32 dwRequestFlags);

[DllImport(EverythingDLL)]
public static extern uint Everything_GetRequestFlags();
public static extern UInt32 Everything_GetRequestFlags();

[DllImport(EverythingDLL)]
public static extern uint Everything_GetResultListRequestFlags();
public static extern UInt32 Everything_GetResultListRequestFlags();

[DllImport(EverythingDLL, CharSet = CharSet.Unicode)]
public static extern string Everything_GetResultExtension(uint nIndex);
public static extern string Everything_GetResultExtension(UInt32 nIndex);

[DllImport(EverythingDLL)]
public static extern bool Everything_GetResultSize(uint nIndex, out long lpFileSize);
public static extern bool Everything_GetResultSize(UInt32 nIndex, out long lpFileSize);

[DllImport(EverythingDLL)]
public static extern bool Everything_GetResultDateCreated(uint nIndex, out long lpFileTime);
public static extern bool Everything_GetResultDateCreated(UInt32 nIndex, out long lpFileTime);

[DllImport(EverythingDLL)]
public static extern bool Everything_GetResultDateModified(uint nIndex, out long lpFileTime);
public static extern bool Everything_GetResultDateModified(UInt32 nIndex, out long lpFileTime);

[DllImport(EverythingDLL)]
public static extern bool Everything_GetResultDateAccessed(uint nIndex, out long lpFileTime);
public static extern bool Everything_GetResultDateAccessed(UInt32 nIndex, out long lpFileTime);

[DllImport(EverythingDLL)]
public static extern uint Everything_GetResultAttributes(uint nIndex);
public static extern UInt32 Everything_GetResultAttributes(UInt32 nIndex);

[DllImport(EverythingDLL, CharSet = CharSet.Unicode)]
public static extern string Everything_GetResultFileListFileName(uint nIndex);
public static extern string Everything_GetResultFileListFileName(UInt32 nIndex);

[DllImport(EverythingDLL, CharSet = CharSet.Unicode)]
public static extern string Everything_GetResultPath(uint nIndex);
public static extern string Everything_GetResultPath(UInt32 nIndex);

[DllImport(EverythingDLL, CharSet = CharSet.Unicode)]
public static extern string Everything_GetResultFileName(uint nIndex);
public static extern string Everything_GetResultFileName(UInt32 nIndex);

[DllImport(EverythingDLL)]
public static extern uint Everything_GetResultRunCount(uint nIndex);
public static extern UInt32 Everything_GetResultRunCount(UInt32 nIndex);

[DllImport(EverythingDLL)]
public static extern bool Everything_GetResultDateRun(uint nIndex, out long lpFileTime);
public static extern bool Everything_GetResultDateRun(UInt32 nIndex, out long lpFileTime);

[DllImport(EverythingDLL)]
public static extern bool Everything_GetResultDateRecentlyChanged(uint nIndex, out long lpFileTime);
public static extern bool Everything_GetResultDateRecentlyChanged(UInt32 nIndex, out long lpFileTime);

[DllImport(EverythingDLL, CharSet = CharSet.Unicode)]
public static extern string Everything_GetResultHighlightedFileName(uint nIndex);
public static extern string Everything_GetResultHighlightedFileName(UInt32 nIndex);

[DllImport(EverythingDLL, CharSet = CharSet.Unicode)]
public static extern string Everything_GetResultHighlightedPath(uint nIndex);
public static extern string Everything_GetResultHighlightedPath(UInt32 nIndex);

[DllImport(EverythingDLL, CharSet = CharSet.Unicode)]
public static extern string Everything_GetResultHighlightedFullPathAndFileName(uint nIndex);
public static extern string Everything_GetResultHighlightedFullPathAndFileName(UInt32 nIndex);

[DllImport(EverythingDLL)]
public static extern uint Everything_GetRunCountFromFileName(string lpFileName);
public static extern UInt32 Everything_GetRunCountFromFileName(string lpFileName);

[DllImport(EverythingDLL)]
public static extern bool Everything_SetRunCountFromFileName(string lpFileName, uint dwRunCount);
public static extern bool Everything_SetRunCountFromFileName(string lpFileName, UInt32 dwRunCount);

[DllImport(EverythingDLL)]
public static extern uint Everything_IncRunCountFromFileName(string lpFileName);
public static extern UInt32 Everything_IncRunCountFromFileName(string lpFileName);
}
}
2 changes: 1 addition & 1 deletion EverythingNet/Core/SearchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public string FullPath
{
var builder = new StringBuilder(260);

EverythingWrapper.Everything_GetResultFullPathNameW(this.index, builder, 260);
EverythingWrapper.Everything_GetResultFullPathName(this.index, builder, 260);

return builder.ToString();
}
Expand Down

0 comments on commit 5b2a39e

Please sign in to comment.