コード例 #1
0
        public void CompareFilesByModDate_IfRecorderFileSystemInfoIsDiffrentEachOther_ReturnZero()
        {
            //Arrange

            RecorderFileSystemInfo l = new TerminalRemoteFileSystemInfo(_context, "lorem", "ipsum");
            RecorderFileSystemInfo r = new TerminalRemoteFileSystemInfo(_context, "lorem ipsum", "lorem");

            //Act
            // ReSharper disable ExpressionIsAlwaysNull
            var actual = MethodTestHelper.RunInstanceMethod<FileRecorder, int>("CompareFilesByModDate", _fileRecorder, new object[] { l, r });
            // ReSharper restore ExpressionIsAlwaysNull

            //Assert
            Assert.AreEqual(actual, 0);
        }
コード例 #2
0
 protected virtual TerminalRemoteFileSystemInfo[] Refresh(string absolutePath)
 {
     var refreshInfo = new TerminalRemoteFileSystemInfo[] { null };
     var ctx = Context as TerminalRecorderContext;
     if (ctx == null)
         throw new Exception("Context is not a TerminalRecorderContext");
     ctx.Recorder.Log(LogLevel.DEBUG, "Execute Command to Refresh [" + absolutePath + "]");
     ctx.ExecuteRemoteCommand(ctx.CommandFileSystemInfo.Replace("@NODE", absolutePath), args =>
     {
         var info = Context.InputRecord.ToString().Split(new[] { ';' }, 2);
         var r = 0;
         if (info.Length >= 2 && int.TryParse(info[0], out r))
         {
             if (r == 0)
             {
                 if (string.IsNullOrEmpty(info[1]))
                 {
                     refreshInfo[0] = new TerminalRemoteFileSystemInfo(Context, absolutePath, absolutePath);
                     refreshInfo[0].exists.Value = 0;
                 }
                 else
                 {
                     info = info[1].Split(new[] { ';' }, 8);
                     if (info.Length == 8)
                     {
                         Context.Recorder.Log(LogLevel.DEBUG, "Refresh With [" + Context.InputRecord + "]");
                         refreshInfo[0] = new TerminalRemoteFileSystemInfo(Context, info[7],
                                                                           FileSystemHelper.FileNameOf(info[7],
                                                                                                       info[0]))
                             {
                                 fileNodeId = info[1],
                                 creationTimeUtc = Epoch.AddSeconds(ParseLong(info[2])),
                                 lastAccessTimeUtc = Epoch.AddSeconds(ParseLong(info[3])),
                                 lastWriteTimeUtc = Epoch.AddSeconds(ParseLong(info[4])),
                                 attributes =
                                     info[6].Equals("directory") || info[6].Equals("symbolic link")
                                         ? FileAttributes.Directory
                                         : FileAttributes.Normal
                             };
                         refreshInfo[0].exists.Value = 1;
                     }
                     else
                         throw new Exception("Unexpected Create Directory Info command return:[" +
                                             Context.InputRecord +
                                             "]");
                 }
             }
             else
                 throw new Exception("Create Directory Info Failed Return(" + info[0] + "), Msg(" + info[1] +
                                     ")");
         }
         else
             throw new Exception("Remote Create Directory Info command result not understood:[" +
                                 Context.InputRecord +
                                 "]");
     });
     return refreshInfo;
 }