public void Constructor_WithOnlyDriveLetter_HasNoRoot() { var path1 = new MockPath(@"C:"); const string expected = ""; Assert.AreEqual(expected, path1.Root); }
public void Constructor_WithEmptyComponentAtEnd_LeavesEmptyComponentOut() { var expected = new MockPath(@"a\b"); var actual = new MockPath("a", "b", ""); Assert.Equal(expected, actual); }
public void Constructor_WithSameInputAndDifferentSeparator_CreatesEqualPaths() { var path1 = new MockPath(@"a\b"); var path2 = new MockPath(@"a/b"); Assert.AreEqual(path1, path2); }
public void Constructor_WithDifferentPaths_PathsAreNotEqual() { var path1 = new MockPath(@"a"); var path2 = new MockPath(@"a\b"); Assert.NotEqual(path1, path2); }
public override void SetUp() { base.SetUp(); vPropDbName = DbName.Vert.Factor.EventorDateTime; vOperation = "lte"; vYear = 2000; vMonth = 1; vDay = 17; vHour = 13; vMinute = 52; vSecond = 3; vValue = DataUtil.EventorTimesToLong(vYear, vMonth, vDay, vHour, vMinute, vSecond); vPropDbNameParam = "_P0"; vValueParam = "_P1"; vScript = ".has(" + vPropDbNameParam + ", Tokens.T.lte, " + vValueParam + ")"; vToType = typeof(FabArtifact); vStep = new TravStepWhereEventorDateTime(); MockItem.Setup(x => x.VerifyParamCount(7, -1)); MockItem.Setup(x => x.GetParamAt <string>(0)).Returns(vOperation); MockItem.Setup(x => x.GetParamAt <long>(1)).Returns(vYear); MockItem.Setup(x => x.GetParamAt <byte>(2)).Returns(vMonth); MockItem.Setup(x => x.GetParamAt <byte>(3)).Returns(vDay); MockItem.Setup(x => x.GetParamAt <byte>(4)).Returns(vHour); MockItem.Setup(x => x.GetParamAt <byte>(5)).Returns(vMinute); MockItem.Setup(x => x.GetParamAt <byte>(6)).Returns(vSecond); MockPath.Setup(x => x.AddParam(vPropDbName)).Returns(vPropDbNameParam); MockPath.Setup(x => x.AddParam(vValue)).Returns(vValueParam); MockPath.Setup(x => x.AddScript(vScript)); }
public void RelativeTo_WithParentLackingDrive_ThrowsException() { var parent = new MockPath(@"\users\"); var path = new MockPath(@"c:\users\nemec\file.txt"); Assert.Throws <ArgumentException>(() => path.RelativeTo(parent)); }
public void RelativeTo_WithParentInDifferentDir_ThrowsException() { var parent = new MockPath(@"\Program Files\"); var path = new MockPath(@"c:\users\nemec\file.txt"); Assert.Throws <ArgumentException>(() => path.RelativeTo(parent)); }
public void RelativeTo_WithParentContainingPartialFilename_ThrowsException() { var parent = new MockPath(@"c:\users\nemec\file"); var path = new MockPath(@"c:\users\nemec\file.txt"); Assert.Throws <ArgumentException>(() => path.RelativeTo(parent)); }
public void GetRoot_WithRelativePathOnDrive_ReturnsEmptyRoot() { var path = new MockPath(@"c:ProgramFiles\"); const string expected = ""; Assert.Equal(expected, path.Root); }
public void Constructor_WithSameInput_CreatesEqualPaths() { var path1 = new MockPath(@"a\b"); var path2 = new MockPath(@"a\b"); Assert.Equal(path1, path2); }
public void GetRoot_WithLocalRoot_ReturnsRoot() { var path = new MockPath(@"c:\ProgramFiles\"); const string expected = @"\"; Assert.Equal(expected, path.Root); }
public void Constructor_WithOnePathRelative_PathsAreNotEqual() { var expected = new MockPath(@"a\b"); var actual = new MockPath(@"\a\b"); Assert.NotEqual(expected, actual); }
public void Constructor_WithAbsoluteAndEmptyComponent_DropsComponentBeforeAbsoluteComponent() { var expected = new MockPath(@"\b\c"); var actual = new MockPath(@"a", @"\b\\", @"c"); Assert.Equal(expected, actual); }
public void Constructor_WithDriveLetterAndRoot_DoesNotDropTrailingSlash() { var path1 = new MockPath(@"C:\"); const string expected = @"\"; Assert.AreEqual(expected, path1.Root); }
public void Constructor_WithOneContainingEmptyComponent_CreatesEqualPaths() { var expected = new MockPath(@"a\\b\"); var actual = new MockPath(@"a\b"); Assert.Equal(expected, actual); }
public void Constructor_WithBothContainingTrailingSlash_CreatesEqualPaths() { var expected = new MockPath(@"a\b"); var actual = new MockPath(@"a\", @"b\"); Assert.Equal(expected, actual); }
public void Constructor_WithJoiningPaths_CreatesEqualPaths() { var expected = new MockPath(@"a\b"); var actual = new MockPath("a", "b"); Assert.Equal(expected, actual); }
public void Constructor_WithEmptyString_ReturnsCurrentDir() { var path = new MockPath(""); var expected = new MockPath("."); Assert.AreEqual(expected, path); }
public void GetRoot_WithUncShare_ReturnsUncRoot() { var path = new MockPath(@"\\some\share"); const string expected = @"\"; Assert.Equal(expected, path.Root); }
public void GetParents_WithAParent_DoesNotReturnSelf() { var path = new MockPath(@"C:\nemec"); var parents = path.Parents(); Assert.Single(parents); }
public void ErrorAliasNotFound() { MockPath.Setup(x => x.HasAlias(vAlias)).Returns(false); var f = new FabStepFault(FabFault.Code.IncorrectParamValue, 0, "", "", 0); SetupFault(f, "not be found"); CheckConsumePathThrows(f); }
public void ErrorDuplicateAlias() { MockPath.Setup(x => x.HasAlias(vAlias)).Returns(true); var f = new FabStepFault(FabFault.Code.IncorrectParamValue, 0, "", "", 0); SetupFault(f, "in use"); CheckConsumePathThrows(f); }
public void ErrorDirectlyAfterAs() { MockPath.Setup(x => x.DoesBackTouchAs(vAlias)).Returns(true); var f = new FabStepFault(FabFault.Code.InvalidStep, 0, "", "", 0); SetupFault(f, "directly after"); CheckConsumePathThrows(f); }
/*--------------------------------------------------------------------------------------------*/ protected override void CheckSuccess(bool pSuccess) { Times t = (pSuccess ? Times.Once() : Times.Never()); MockItem.Verify(x => x.VerifyParamCount(0, -1), Times.Once); MockPath.Verify(x => x.AddScript(It.IsAny <string>()), Times.Never); }
public void SafeJoin_WithSiblinStartsWithTraversal_FailsJoin() { var path = new MockPath(@"a"); MockPath joined; Assert.IsFalse(path.TrySafeJoin(@"..\ab\d", out joined)); }
public void SafeJoin_WithSiblingRelativeParentTraversal_FailsJoin() { var path = new MockPath(@"a"); MockPath joined; Assert.IsFalse(path.TrySafeJoin(@"..\c\d", out joined)); }
public void SafeJoin_WithComplexRelativeParentTraversal_FailsJoin() { var path = new MockPath(@"a"); MockPath joined; Assert.IsFalse(path.TrySafeJoin(@"b\c\d\..\f\..\..\..\g\..\..", out joined)); }
public void Constructor_WithParentDirectoryPart_DoesNotResolvePart() { const string expected = @"c:\users\userA\..\userB"; var path = new MockPath(expected); Assert.AreEqual(expected, path.ToString()); }
public void GetParents_WithAParent_DoesNotReturnSelf() { var path = new MockPath(@"C:\nemec"); var parents = path.Parents(); Assert.AreEqual(1, parents.Count()); }
public void Constructor_WithFileUri_StripsUriPrefix() { var path1 = new MockPath(@"c:\users"); var path2 = new MockPath(@"file://c:/users"); Assert.AreEqual(path1, path2); }
public void Combine_SentFivePaths_Combines() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.Combine(XFS.Path("C:\\test"), "subdir1", "subdir2", "subdir3", "test.bmp"); //Assert Assert.AreEqual(XFS.Path("C:\\test\\subdir1\\subdir2\\subdir3\\test.bmp"), result); }
public void ChangeExtension_ExtensionNoPeriod_PeriodAdded() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.ChangeExtension(TestPath, "doc"); //Assert Assert.AreEqual("C:\\test\\test.doc", result); }
public void GetFileNameWithoutExtension_SendInPath_ReturnsFileNameNoExt() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.GetFileNameWithoutExtension(TestPath); //Assert Assert.AreEqual("test", result); }
public void GetExtension_SendInPath_ReturnsExtension() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.GetExtension(TestPath); //Assert Assert.AreEqual(".bmp", result); }
public void GetFileName_SendInPath_ReturnsFilename() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.GetFileName(TestPath); //Assert Assert.AreEqual("test.bmp", result); }
public void Combine_SentTwoPaths_Combines() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.Combine("C:\\test", "test.bmp"); //Assert Assert.AreEqual("C:\\test\\test.bmp", result); }
public void GetDirectoryName_SentPath_ReturnsDirectory() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.GetDirectoryName(TestPath); //Assert Assert.AreEqual("C:\\test", result); }
public void GetTempPath_Called_ReturnsStringLengthGreaterThanZero() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.GetTempPath(); //Assert Assert.IsTrue(result.Length > 0); }
public void HasExtension_PathSentIn_DeterminesExtension() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.HasExtension(TestPath); //Assert Assert.AreEqual(true, result); }
public void IsPathRooted_PathSentIn_DeterminesPathExists() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.IsPathRooted(TestPath); //Assert Assert.AreEqual(true, result); }
public void GetFullPath_SendInPath_ReturnsFullPath() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.GetFullPath(TestPath); //Assert Assert.AreEqual(TestPath, result); }
public void GetFullPath_AbsolutePaths_ShouldReturnThePathWithTheRoot_Or_Unc(string currentDir, string absolutePath, string expectedResult) { //Arrange var mockFileSystem = new MockFileSystem(); mockFileSystem.Directory.SetCurrentDirectory(currentDir); var mockPath = new MockPath(mockFileSystem); //Act var actualResult = mockPath.GetFullPath(absolutePath); //Assert Assert.AreEqual(expectedResult, actualResult); }
public void GetInvalidPathChars_Called_ReturnsChars() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.GetInvalidPathChars(); //Assert Assert.IsTrue(result.Length > 0); }
public void GetPathRoot_SendInPath_ReturnsRoot() { //Arrange var mockPath = new MockPath(new MockFileSystem()); //Act var result = mockPath.GetPathRoot(TestPath); //Assert Assert.AreEqual("C:\\", result); }
public void GetFullPath_WithMultipleDirectorySeparators_ShouldReturnTheNormalizedForm() { //Arrange var mockFileSystem = new MockFileSystem(); var mockPath = new MockPath(mockFileSystem); //Act var actualFullPath = mockPath.GetFullPath(XFS.Path(@"c:\foo\\//bar\file.dat")); //Assert Assert.AreEqual(XFS.Path(@"c:\foo\bar\file.dat"), actualFullPath); }
public void GetTempFileName_Called_CreatesEmptyFileInTempDirectory() { //Arrange var fileSystem = new MockFileSystem(); var mockPath = new MockPath(fileSystem); //Creating directory explicitly because in normal system Tempory path always exist. fileSystem.Directory.CreateDirectory(mockPath.GetTempPath()); //Act var result = mockPath.GetTempFileName(); Assert.True(fileSystem.FileExists(result)); Assert.AreEqual(0, fileSystem.FileInfo.FromFileName(result).Length); }
public void GetTempFileName_Called_ReturnsStringLengthGreaterThanZero() { //Arrange var fileSystem = new MockFileSystem(); var mockPath = new MockPath(fileSystem); //Creating directory explicitly because in normal system Tempory path always exist. fileSystem.Directory.CreateDirectory(mockPath.GetTempPath()); //Act var result = mockPath.GetTempFileName(); //Assert Assert.IsTrue(result.Length > 0); }
public void GetFullPath_EmptyValue_ShouldThrowArgumentException() { //Arrange var mockFileSystem = new MockFileSystem(); var mockPath = new MockPath(mockFileSystem); //Act TestDelegate action = () => mockPath.GetFullPath(string.Empty); //Assert Assert.Throws<ArgumentException>(action); }
public void GetFullPath_InvalidUNCPaths_ShouldThrowArgumentException() { //Arrange var mockFileSystem = new MockFileSystem(); var mockPath = new MockPath(mockFileSystem); //Act TestDelegate action = () => mockPath.GetFullPath(XFS.Path(@"\\shareZ")); //Assert Assert.Throws<ArgumentException>(action); }
public void GetTempFileName_Called_CreatesEmptyFileInTempDirectory() { //Arrange var fileSystem = new MockFileSystem(); var mockPath = new MockPath(fileSystem); //Act var result = mockPath.GetTempFileName(); Assert.True(fileSystem.FileExists(result)); Assert.AreEqual(0, fileSystem.FileInfo.FromFileName(result).Length); }
public void GetFullPath_RootedPathWithRelativeSegments_ShouldReturnAnRootedAbsolutePath(string rootedPath, string expectedResult) { //Arrange var mockFileSystem = new MockFileSystem(); var mockPath = new MockPath(mockFileSystem); //Act var actualResult = mockPath.GetFullPath(rootedPath); //Assert Assert.AreEqual(expectedResult, actualResult); }