Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDCard tests #92

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions System.IO.FileSystem.UnitTests/FileUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public class FileUnitTests
[Setup]
public void Setup()
{
Assert.SkipTest("These test will only run on real hardware. Comment out this line if you are testing on real hardware.");
//Assert.SkipTest("These test will only run on real hardware. Comment out this line if you are testing on real hardware.");
}

private const string Root = @"I:\";
private const string Root = @"D:\";
private static readonly string Destination = $"{Root}{nameof(FileUnitTests)}-Destination.test";
private static readonly string Source = $"{Root}{nameof(FileUnitTests)}-Source.test";

Expand Down Expand Up @@ -225,7 +225,7 @@ public void Delete_deletes_file()
[TestMethod]
public void Exists_returns_false_if_file_does_not_exist()
{
Assert.IsFalse(File.Exists($@"I:\file_does_not_exist-{nameof(FileUnitTests)}.pretty_sure"));
Assert.IsFalse(File.Exists($@"D:\file_does_not_exist-{nameof(FileUnitTests)}.pretty_sure"));
}

[TestMethod]
Expand Down
68 changes: 34 additions & 34 deletions System.IO.FileSystem.UnitTests/PathUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal class PathUnitTests
[TestMethod]
public void ChangeExtension_adds_extension()
{
const string path = @"I:\file";
const string expect = @"I:\file.new";
const string path = @"D:\file";
const string expect = @"D:\file.new";

Assert.AreEqual(expect, Path.ChangeExtension(path, "new"));
Assert.AreEqual(expect, Path.ChangeExtension(path, ".new"));
Expand All @@ -18,8 +18,8 @@ public void ChangeExtension_adds_extension()
[TestMethod]
public void ChangeExtension_changes_extension()
{
const string path = @"I:\file.old";
const string expect = @"I:\file.new";
const string path = @"D:\file.old";
const string expect = @"D:\file.new";

Assert.AreEqual(expect, Path.ChangeExtension(path, "new"));
Assert.AreEqual(expect, Path.ChangeExtension(path, ".new"));
Expand All @@ -28,8 +28,8 @@ public void ChangeExtension_changes_extension()
[TestMethod]
public void ChangeExtension_removes_extension()
{
const string path = @"I:\file.old";
const string expect = @"I:\file";
const string path = @"D:\file.old";
const string expect = @"D:\file";

Assert.AreEqual(expect, Path.ChangeExtension(path, null));
}
Expand Down Expand Up @@ -60,17 +60,17 @@ public void Combine_returns_path1_if_path2_is_empty_string()
[TestMethod]
public void Combine_combines_paths()
{
var expect = @"I:\Path1\Path2\File.ext";
var expect = @"D:\Path1\Path2\File.ext";

Assert.AreEqual(expect, Path.Combine(@"I:\Path1", @"Path2\File.ext"));
Assert.AreEqual(expect, Path.Combine(@"I:\Path1\", @"Path2\File.ext"));
Assert.AreEqual(expect, Path.Combine(@"D:\Path1", @"Path2\File.ext"));
Assert.AreEqual(expect, Path.Combine(@"D:\Path1\", @"Path2\File.ext"));
}

[TestMethod]
public void Combine_returns_path2_if_it_is_an_absolute_path()
{
var path1 = @"I:\Directory";
var path2 = @"I:\Absolute\Path";
var path1 = @"D:\Directory";
var path2 = @"D:\Absolute\Path";

var actual = Path.Combine(path1, path2);

Expand All @@ -97,14 +97,14 @@ public void Combine_throws_if_path1_is_null()
[TestMethod]
public void Combine_throws_if_path2_is_null()
{
Assert.ThrowsException(typeof(ArgumentNullException), () => { Path.Combine(@"I:\Directory", null); });
Assert.ThrowsException(typeof(ArgumentNullException), () => { Path.Combine(@"D:\Directory", null); });
}

[TestMethod]
public void GetDirectoryName_returns_directory()
{
var tests = new[] { @"I:\directory", @"I:\directory\", @"I:\directory\file.ext" };
var answers = new[] { @"I:\", @"I:\directory", @"I:\directory" };
var tests = new[] { @"D:\directory", @"D:\directory\", @"D:\directory\file.ext" };
var answers = new[] { @"D:\", @"D:\directory", @"D:\directory" };

for (var i = 0; i < tests.Length; i++)
{
Expand Down Expand Up @@ -175,9 +175,9 @@ public void GetExtension_returns_extension()
var expect = ".ext";

Assert.AreEqual(expect, Path.GetExtension(file));
Assert.AreEqual(expect, Path.GetExtension($"I:{file}"));
Assert.AreEqual(expect, Path.GetExtension(@$"I:\{file}"));
Assert.AreEqual(expect, Path.GetExtension(@$"I:\directory\{file}"));
Assert.AreEqual(expect, Path.GetExtension($"D:{file}"));
Assert.AreEqual(expect, Path.GetExtension(@$"D:\{file}"));
Assert.AreEqual(expect, Path.GetExtension(@$"D:\directory\{file}"));
Assert.AreEqual(expect, Path.GetExtension(@$"\{file}"));
}

Expand All @@ -200,17 +200,17 @@ public void GetExtension_returns_null()
[TestMethod]
public void GetFilename_returns_empty_string()
{
Assert.AreEqual(string.Empty, Path.GetFileName("I:"));
Assert.AreEqual(string.Empty, Path.GetFileName(@"I:\"));
Assert.AreEqual(string.Empty, Path.GetFileName("D:"));
Assert.AreEqual(string.Empty, Path.GetFileName(@"D:\"));
}

[TestMethod]
public void GetFilename_returns_filename_without_extension()
{
Assert.AreEqual("file", Path.GetFileName(@"I:\directory\file"));
Assert.AreEqual("file.ext", Path.GetFileName(@"I:\directory\file.ext"));
Assert.AreEqual("file", Path.GetFileName(@"I:\file"));
Assert.AreEqual("file.ext", Path.GetFileName(@"I:\file.ext"));
Assert.AreEqual("file", Path.GetFileName(@"D:\directory\file"));
Assert.AreEqual("file.ext", Path.GetFileName(@"D:\directory\file.ext"));
Assert.AreEqual("file", Path.GetFileName(@"D:\file"));
Assert.AreEqual("file.ext", Path.GetFileName(@"D:\file.ext"));
}

[TestMethod]
Expand All @@ -229,17 +229,17 @@ public void GetFilename_returns_null()
[TestMethod]
public void GetFilenameWithoutExtension_returns_empty_string()
{
Assert.AreEqual(string.Empty, Path.GetFileNameWithoutExtension("I:"));
Assert.AreEqual(string.Empty, Path.GetFileNameWithoutExtension(@"I:\"));
Assert.AreEqual(string.Empty, Path.GetFileNameWithoutExtension("D:"));
Assert.AreEqual(string.Empty, Path.GetFileNameWithoutExtension(@"D:\"));
}

[TestMethod]
public void GetFilenameWithoutExtension_returns_filename_without_extension()
{
Assert.AreEqual("file", Path.GetFileNameWithoutExtension(@"I:\directory\file"));
Assert.AreEqual("file", Path.GetFileNameWithoutExtension(@"I:\directory\file.ext"));
Assert.AreEqual("file", Path.GetFileNameWithoutExtension(@"I:\file"));
Assert.AreEqual("file", Path.GetFileNameWithoutExtension(@"I:\file.ext"));
Assert.AreEqual("file", Path.GetFileNameWithoutExtension(@"D:\directory\file"));
Assert.AreEqual("file", Path.GetFileNameWithoutExtension(@"D:\directory\file.ext"));
Assert.AreEqual("file", Path.GetFileNameWithoutExtension(@"D:\file"));
Assert.AreEqual("file", Path.GetFileNameWithoutExtension(@"D:\file.ext"));
}

[TestMethod]
Expand Down Expand Up @@ -276,10 +276,10 @@ public void GetPathRoot_returns_root()
{
var tests = new[]
{
"I:", @"I:\directory\file", @"I:\directory\file.ext", @"I:\file", @"I:\file.ext"
"D:", @"D:\directory\file", @"D:\directory\file.ext", @"D:\file", @"D:\file.ext"
};

var answers = new[] { "I:", @"I:\", @"I:\", @"I:\", @"I:\" };
var answers = new[] { "D:", @"D:\", @"D:\", @"D:\", @"D:\" };

for (var i = 0; i < tests.Length; i++)
{
Expand Down Expand Up @@ -316,7 +316,7 @@ public void HasExtension_returns_false()
{
var tests = new[]
{
"file", @"\file.", @"\", "/", "I:", @"I:\", @"I:\directory\"
"file", @"\file.", @"\", "/", "D:", @"D:\", @"D:\directory\"
};

for (var i = 0; i < tests.Length; i++)
Expand Down Expand Up @@ -346,7 +346,7 @@ public void HasExtension_returns_true()
{
var tests = new[]
{
"file.ext", @"\file.ext", "/file.ext", "I:file.ext", @"I:\file.ext", @"I:\directory\file.ext"
"file.ext", @"\file.ext", "/file.ext", "D:file.ext", @"D:\file.ext", @"D:\directory\file.ext"
};

for (var i = 0; i < tests.Length; i++)
Expand Down Expand Up @@ -376,7 +376,7 @@ public void IsPathRooted_returns_true()
{
var tests = new[]
{
@"\", "/", "I:", @"I:\", @"I:\file.ext", @"I:\directory\file.ext"
@"\", "/", "D:", @"D:\", @"D:\file.ext", @"D:\directory\file.ext"
};

for (var i = 0; i < tests.Length; i++)
Expand Down
35 changes: 21 additions & 14 deletions System.IO.FileSystem.UnitTests/nano.runsettings
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<ResultsDirectory>.\TestResults</ResultsDirectory><!-- Path relative to solution directory -->
<TestSessionTimeout>120000</TestSessionTimeout><!-- Milliseconds -->
<TargetFrameworkVersion>net48</TargetFrameworkVersion>
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
<nanoFrameworkAdapter>
<Logging>None</Logging> <!--Set to the desired level of logging for Unit Test execution. Possible values are: None, Detailed, Verbose, Error. -->
<IsRealHardware>True</IsRealHardware><!--Set to true to run tests on real hardware. -->
<RealHardwarePort>COM3</RealHardwarePort><!--Specify the COM port to use to connect to a nanoDevice. If none is specified, a device detection is performed and the 1st available one will be used. -->
<CLRVersion></CLRVersion><!--Specify the nanoCLR version to use. If not specified, the latest available will be used. -->
<PathToLocalCLRInstance></PathToLocalCLRInstance><!--Specify the path to a local nanoCLR instance. If not specified, the default one installed with nanoclr CLR witll be used. -->
</nanoFrameworkAdapter>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<!-- Path relative to solution directory -->
<ResultsDirectory>.\TestResults</ResultsDirectory>
<!-- Timeout Milliseconds -->
<TestSessionTimeout>120000</TestSessionTimeout>
<TargetFrameworkVersion>net48</TargetFrameworkVersion>
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
<nanoFrameworkAdapter>
<!--Set to the desired level of logging for Unit Test execution. Possible values are: None, Detailed, Verbose, Error. -->
<Logging>None</Logging>
<!--Set to true to run tests on real hardware. -->
<IsRealHardware>True</IsRealHardware>
<!--Specify the COM port to use to connect to a nanoDevice. If none is specified, a device detection is performed and the 1st available one will be used. -->
<RealHardwarePort></RealHardwarePort>
<!--Specify the nanoCLR version to use. If not specified, the latest available will be used. -->
<CLRVersion></CLRVersion>
<!--Specify the path to a local nanoCLR instance. If not specified, the default one installed with nanoclr CLR witll be used. -->
<PathToLocalCLRInstance></PathToLocalCLRInstance>
</nanoFrameworkAdapter>
</RunSettings>
4 changes: 2 additions & 2 deletions System.IO.FileSystem/FileStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,12 @@ public override void WriteByte(byte value)
[Diagnostics.DebuggerStepThrough]
[Diagnostics.DebuggerHidden]
[MethodImpl(MethodImplOptions.InternalCall)]
private extern int ReadNative(string path, string fileName, long actualPosition, byte[] buffer, int length);
private extern int ReadNative(string path, string fileName, long actualPosition, byte[] buffer, long length);

[Diagnostics.DebuggerStepThrough]
[Diagnostics.DebuggerHidden]
[MethodImpl(MethodImplOptions.InternalCall)]
private extern void WriteNative(string path, string fileName, long actualPosition, byte[] buffer, int length);
private extern void WriteNative(string path, string fileName, long actualPosition, byte[] buffer, long length);

[Diagnostics.DebuggerStepThrough]
[Diagnostics.DebuggerHidden]
Expand Down
Loading