EldoS | Feel safer!

Software components for data protection, secure storage and transfer

What is the right way to test CBFS within the context of NUnit tests

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
#11716
Posted: 11/17/2009 12:48:30
by Laryn Fernandes (Basic support level)
Joined: 06/22/2009
Posts: 5

Hi,
I am looking for suggestions/approaches on how to write NUnit tests for CBFS. The goal is to load the file system, copy, read, write files to it and the shut it down after the test(s) are completed.
I seem to be bumping into some thread blocking issues when I run within the context of the NUnit framework from within Visual Studio 2008

I started off using the C# Mapper codebase as a template and here's what I currently have.
Driver version 2.5.51.529

public class MyFileSystem : CallbackFileSystem
{
// Relevant code from the Mapper project sample - Form1.cs
// My class has no GUI but implements initialization, open/close/read/write file operations for my specific project/needs
}

public class MyFileSystemWrapper : IDisposable
{
....
....
// This class is a wrapper that allows me to create a file system from the command line

public bool StartMyFileSystem()
{
try
{
_myFS = new MyFileSystem(..., ..., ...);
_myFS.CreateStorage();
_myFS.MountMedia(0);
_myFS.AddNetworkMountingPoint(..., ..., ...);
}
catch (Exception e)
{
_logger.ErrorException("StartMyFileSystem failed", e);
return false;
}
return true;
}

public void ShutdownMyFileSystem()
{
try
{
_myFS.DeleteMountingPointEx(..., false);
}
catch(Exception e)
{
_logger.ErrorException("DeleteMountingPointEx FAILED: {0}", e.Message);
}
_myFS.UnmountMedia(true);
_myFS.DeleteStorage(true);
}
}


In a (sample) console application, things work as expected
class Program
{
static void Main(string[] args)
{
var vsWrapper = new MyFileSystemWrapper(.., ..., ..., ...);
var success = vsWrapper.StartMyFileSystem();
Console.WriteLine("Created={0} : file system for {1} ", success, email);
Console.ReadKey();
vsWrapper.ShutdownVSFileSystem();
}
}

Now when I insert the StartMyFileSystem() method along with all relevant initialization in an NUnit test case, my file system loads up (StartMyFileSystem() returns success ) but I notice two issues
1. In Windows explorer, when I double click the share that was created i.e. \\MyComputer\MyShare, Explorer stops responding and does not display any contents
2. In the same test after the StartMyFileSystem() call, any attempt to copy a file from the local disk to the newly created share results in an exception
$exception {"Exception has been thrown by the target of an invocation."} System.Exception {System.Reflection.TargetInvocationException}


So in a nutshell, my question is, What would be the right way to test CBFS within the context of NUnit tests ?
Thanks
#11734
Posted: 11/18/2009 03:02:06
by Eugene Mayevski (EldoS Corp.)

We don't have experience with NUnit, so let's narrow down the problem you are facing.

Question 1: are you trying to test your CBFS implementation OR you are trying to test some code and use CBFS as a virtual data storage? If CBFS is used just as a container, the easiest would be to move it to a separate process which can be controlled from your main application.

Question 2: as I understand, the problem appears only when you add NUnit into your project. Is it so? Or does the problem happen in any GUI process? It is important to find out, what exactly factor or combination of factors causes this behaviour.

Also the latest build is build 55 and it makes sense to try it too.


Sincerely yours
Eugene Mayevski
#11739
Posted: 11/18/2009 08:08:03
by Laryn Fernandes (Basic support level)
Joined: 06/22/2009
Posts: 5

Hello Eugene,
We have exposed contents of a database as a virtual drive using CBFS.
We have a client application similar to the Mapper form that mounts and unmounts the drive (i..e V: ). This piece works as expected.
I also need to expose the virtual drive as a network share ( so instead of V:\, I expose \\ComputerName\ShareName which also works well from a standard C# console application, via my wrapper class, the code for which is included in my original post.

In my NUnit test, I would like to create/mount a network share using CBFS, perform some file operations and then unmount the share when done. The way NUnit works, this could either be done for the instance of the test class or I could mount/unmount the share for every test that is executed.

Thanks
~ Laryn
#11741
Posted: 11/18/2009 09:32:09
by Eugene Mayevski (EldoS Corp.)

Thank you for the explanation. However, this explanation doesn't answer my questions.


Sincerely yours
Eugene Mayevski
#11753
Posted: 11/18/2009 22:13:41
by Laryn Fernandes (Basic support level)
Joined: 06/22/2009
Posts: 5

Question 1: are you trying to test your CBFS implementation - YES
OR you are trying to test some code and use CBFS as a virtual data storage? – NO

Question 2: as I understand, the problem appears only when you add NUnit into your project. Is it so? – YES
Or does the problem happen in any GUI process? – NO

Regards
~ Laryn
#11755
Posted: 11/19/2009 00:39:54
by Eugene Mayevski (EldoS Corp.)

Understood. In this case can you please create a small test case and send us it's source code (with instructions of where and how to apply NUnit, because we don't have any experience with it)?


Sincerely yours
Eugene Mayevski
Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.

Reply

Statistics

Topic viewed 1864 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!