Пример #1
0
        public void BuildRequiredTest002()
        {
            FileInfo hashFileInfo = new FileInfo(HashFilePath);

            if (hashFileInfo.Exists)
            {
                DateTime prevLastWriteUtc     = hashFileInfo.LastWriteTimeUtc;
                FileInfo test001CInfo         = new FileInfo(Path.Combine(ArtifactsDirectory, ArtifactsDjvuFile));
                DateTime prevTestLastWriteUtc = test001CInfo.LastWriteTimeUtc;
                try
                {
                    test001CInfo.LastWriteTimeUtc = DateTime.UtcNow.AddDays(10);
                    CalculateHashes = false;
                    UtilJson.ArtifactsBuildRequired(ArtifactsDirectory, ArtifactsSearchPattern, SubdirectoryList,
                                                    SubdirectorySearchPatterns, HashFilePath, out CalculateHashes);

                    Assert.True(CalculateHashes);

                    CalculateHashes = false;
                    hashFileInfo.LastWriteTimeUtc = test001CInfo.LastWriteTimeUtc.AddDays(10);
                    UtilJson.ArtifactsBuildRequired(ArtifactsDirectory, ArtifactsSearchPattern, SubdirectoryList,
                                                    SubdirectorySearchPatterns, HashFilePath, out CalculateHashes);

                    Assert.False(CalculateHashes);
                }
                finally
                {
                    hashFileInfo.LastWriteTimeUtc = prevLastWriteUtc;
                    test001CInfo.LastWriteTimeUtc = prevTestLastWriteUtc;
                }
            }
        }
Пример #2
0
        public void BuildRequiredTest001()
        {
            FileInfo hashFileInfo = new FileInfo(HashFilePath);

            if (hashFileInfo.Exists)
            {
                string backupHashFile = HashFilePath + ".bak";
                if (File.Exists(backupHashFile))
                {
                    File.Delete(backupHashFile);
                }
                try
                {
                    hashFileInfo.MoveTo(backupHashFile);
                    CalculateHashes = false;
                    UtilJson.ArtifactsBuildRequired(ArtifactsDirectory, ArtifactsSearchPattern, SubdirectoryList,
                                                    SubdirectorySearchPatterns, HashFilePath, out CalculateHashes);
                    Assert.True(CalculateHashes);
                }
                finally
                {
                    if (File.Exists(backupHashFile))
                    {
                        if (!File.Exists(HashFilePath))
                        {
                            File.Move(backupHashFile, HashFilePath);
                        }
                        else
                        {
                            File.Delete(backupHashFile);
                        }
                    }
                }
            }
        }