public void Constructor_OK() { object temp = null; Assert.DoesNotThrow(() => { temp = new DirectoryInfoProxy(_folder); }); var sut = temp as DirectoryInfoProxy; Assert.IsNotNull(sut, "Object constructed, but null."); }
public void Exists_False() { var path = Path.GetRandomFileName(); var expected = new DirectoryInfo(path).Exists; var sut = new DirectoryInfoProxy(path); var actual = sut.Exists; Assert.AreEqual(expected, actual, "Property does not match wrapped property."); }
public void CreateSublocation_Rooted() { var newFolder = TestHelper.NewAbsoluteDirectoryName(); DirectoryInfoProxy actual = null; var sut = new DirectoryInfoProxy(_folder); Assert.Throws<ArgumentException>(() => actual = sut.CreateSublocation(newFolder)); Assert.IsNull(actual); var di = new DirectoryInfo(newFolder); Assert.IsFalse(di.Exists); }
public async Task EnumerateFileSystemInfos() { var root = TestData.GetTestSpecificPath(); await TestData.CreateTestSpecificFileAsync("a_y.py", "not important"); await TestData.CreateTestSpecificFileAsync("b_y.py", "not important"); await TestData.CreateTestSpecificFileAsync("c_z.py", "not important"); var proxy = new DirectoryInfoProxy(root); var files = proxy.EnumerateFileSystemInfos(new[] { "*.py" }, new[] { "*z.py" }).OrderBy(x => x.FullName).ToArray(); files.Should().HaveCount(2); files[0].FullName.Should().Be(Path.Combine(root, "a_y.py")); files[1].FullName.Should().Be(Path.Combine(root, "b_y.py")); }
public void CreateSublocation_Relative() { // Using Resharper, folders will be build in // %LocalAppData%\JetBrains\Installations\ReSharperPlatformVs12 // var basePath = @"%LocalAppData%\JetBrains\Installations\ReSharperPlatformVs12"; var newFolder = TestHelper.NewRelativeDirectoryName(); var sut = new DirectoryInfoProxy(_folder); DirectoryInfoProxy actual = null; Assert.DoesNotThrow(() => actual = sut.CreateSublocation(newFolder)); Assert.IsNotNull(actual); Assert.IsTrue(actual.Exists); DirectoryInfo di = null; Assert.DoesNotThrow(() => di = new DirectoryInfo(actual.FullName)); Assert.IsNotNull(di); Assert.IsTrue(di.Exists); di.Delete(); }
public void Test_Equality_Operators() { var folder1 = Environment.GetFolderPath(Environment.SpecialFolder.Windows); var folder2 = Environment.GetFolderPath(Environment.SpecialFolder.System); var item1 = new DirectoryInfoProxy(folder1); var item3 = item1; var item2 = new DirectoryInfoProxy(folder2); DirectoryInfoProxy item4 = null; Assert.IsTrue(item1 == item3); Assert.IsTrue(item1 != item2); Assert.IsTrue(item1 != item4); }
public void Test_Equality() { var folder = Environment.GetFolderPath(Environment.SpecialFolder.Windows); var differentFolder = Environment.CurrentDirectory; var item1 = new DirectoryInfoProxy(folder); var item2 = new DirectoryInfoProxy(folder); var item3 = new DirectoryInfoProxy(folder); Testing.Cush.TestEquality(item1, item2, item3); // set them different by one item property. //========================================== item1 = new DirectoryInfoProxy(differentFolder); Assert.IsTrue(item2.Equals(item3)); Assert.IsFalse(item1.Equals(item2)); Assert.IsFalse(item1.Equals(item3)); Testing.Cush.TestEquality(item1, item2, item3); item2 = new DirectoryInfoProxy(differentFolder); Assert.IsTrue(item1.Equals(item2)); Assert.IsFalse(item3.Equals(item1)); Assert.IsFalse(item3.Equals(item2)); Testing.Cush.TestEquality(item1, item2, item3); // Set them equal. item3 = new DirectoryInfoProxy(differentFolder); Assert.IsTrue(item1.Equals(item2)); Assert.IsTrue(item1.Equals(item3)); Assert.IsTrue(item2.Equals(item3)); Testing.Cush.TestEquality(item1, item2, item3); }
public void Refresh_And_Attributes() { _dummy = CreateDirectory(); var fileName = _dummy.FullName; var fi = new DirectoryInfoProxy(fileName); var f1Attr = fi.Attributes; // Touching the attributes makes them stick/stale. Assert.IsNotNull(f1Attr); var fi2 = new DirectoryInfoProxy(fileName); fi2.Attributes = fi2.Attributes | FileAttributes.ReadOnly; f1Attr = fi.Attributes; // ...still stale... var f2Attr = fi2.Attributes; Assert.AreNotEqual(f1Attr, f2Attr); Assert.AreNotEqual(fi.Attributes, fi2.Attributes); fi.Refresh(); Assert.AreEqual(fi.Attributes, fi2.Attributes); }
public void Name() { var expected = _directoryInfo.Name; var sut = new DirectoryInfoProxy(_folder); var actual = sut.Name; Assert.AreEqual(expected, actual, "Property does not match wrapped property."); }
public void Delete_Recursive() { var di = TestHelper.CreateStackOf3Directories(); Assert.That(TestHelper.ShouldExist(true, di)); var sut = new DirectoryInfoProxy(di[0].FullName); Assert.DoesNotThrow(() => sut.Delete(true)); TestHelper.Refresh(di); Assert.That(TestHelper.ShouldExist(false, di)); }
public void Constructor_EmptyPath() { object temp = null; Assert.Throws<ArgumentException>(() => { temp = new DirectoryInfoProxy(string.Empty); }); Assert.IsNull(temp, "Exception thrown in constructor, but object constructed."); }
public void GetLocations_With_null_SearchPattern() { var di = TestHelper.CreateStackOf3Directories(); var sut = new DirectoryInfoProxy(di[0].FullName); var actual = sut.GetLocations(searchPattern: null); Assert.IsNotNull(actual); Assert.AreEqual(0, actual.Length); Assert.AreEqual(new ILocationInfo[0], actual); di[0].Delete(true); }
public void GetLocations_WithoutSearchPattern() { var di = TestHelper.CreateStackOf3Directories(); var expected = di[0].GetDirectories(); var sut = new DirectoryInfoProxy(di[0].FullName); var actual = sut.GetLocations(); foreach (var eItem in expected) { var found = false; foreach (var aItem in actual) { if (eItem.FullName == aItem.FullName) { found = true; } } Assert.IsTrue(found); } di[0].Delete(true); }
public void Root() { var expected = _directoryInfo.Root; var sut = new DirectoryInfoProxy(_folder); var actual = sut.Root; TestHelper.CheckDirectoryProperties(expected, actual); }
public void Constructor_NullPath() { object temp = null; Assert.Throws<ArgumentNullException>(() => { temp = new DirectoryInfoProxy(path: null); }); Assert.IsNull(temp, "Exception thrown in constructor, but object constructed."); }
public void IResourceInfo_GetResources() { var location = Environment.CurrentDirectory; var expected = TestHelper.GetFileInfos(location); var sut = new DirectoryInfoProxy(location); var actual = ((ILocationInfo)sut).GetResources(); foreach (var eItem in expected) { var found = false; foreach (var aItem in actual) { if (eItem.FullName == aItem.FullName) { found = true; } } Assert.IsTrue(found); } }
public void ILocationInfo_Root() { var expected = _directoryInfo.Root; var sut = new DirectoryInfoProxy(_folder); var actual = ((ILocationInfo) sut).Root; TestHelper.CheckDirectoryProperties(expected, actual); }
public void ILocationInfo_GetLocations() { var di = TestHelper.CreateStackOf3Directories(); var partialName = di[1].Name; var sut = new DirectoryInfoProxy(di[0].FullName); var actual = ((ILocationInfo)sut).GetLocations(partialName); Assert.IsNotNull(actual); Assert.AreEqual(1, actual.Length); Assert.AreEqual(di[1].FullName, actual[0].FullName); di[0].Delete(true); }
public void IEquatable_Equality() { var folder = Environment.GetFolderPath(Environment.SpecialFolder.Windows); var item1 = new DirectoryInfoProxy(folder); Assert.IsFalse(((IEquatable<ILocationInfo>)item1).Equals(null)); Assert.IsTrue(((IEquatable<ILocationInfo>)item1).Equals(item1)); }
public void Test_Equality_ReferenceEquals() { var folder = Environment.GetFolderPath(Environment.SpecialFolder.Windows); var item1 = new DirectoryInfoProxy(folder); Assert.IsFalse(item1.Equals(null)); Assert.IsTrue(item1.Equals(item1)); }
public void Test_GetHashCode() { var folder = Environment.GetFolderPath(Environment.SpecialFolder.Windows); // If two distinct objects compare as equal, their hashcodes must be equal. var item1 = new DirectoryInfoProxy(folder); var item2 = new DirectoryInfoProxy(folder); Assert.That(item1 == item2); Testing.Cush.TestGetHashCode(item1, item2); }
public void GetResources_With_FullName_SearchPattern() { var expected = TestHelper.GetFileInfos(@"C:\"); Assert.IsNotNull(expected); Assert.That(expected.Length > 0); var sut = new DirectoryInfoProxy(Environment.CurrentDirectory); var actual = sut.GetResources(expected[0].FullName); Assert.IsNotNull(actual); Assert.That(actual.Length > 0); Assert.AreEqual(expected[0].FullName, actual[0].FullName); }
public void Exists_True() { var sut = new DirectoryInfoProxy(_folder); var actual = sut.Exists; Assert.IsTrue(actual, "Property does not match wrapped property."); }
public void GetResources_With_null_SearchPattern() { var sut = new DirectoryInfoProxy(Environment.CurrentDirectory); var actual = sut.GetResources(null); Assert.IsNotNull(actual); Assert.AreEqual(0, actual.Length); Assert.AreEqual(new IResourceInfo[0], actual); }