Example #1
0
        public async Task End_To_End_Test()
        {
            SnippetSyncer syncer = new SnippetSyncer();
            string        path   = Path.Combine(Path.GetTempPath(), "SnippetSync");
            string        url    = "https://github.com/philpursglove/CSharpSnippets";

            await syncer.SyncSnippetFolder(path, url);

            Assert.That(Directory.GetFiles(path).Count, Is.EqualTo(4));
        }
Example #2
0
        public async Task File_Is_Downloaded()
        {
            SnippetSyncer syncer = new SnippetSyncer();
            GithubFile    file   = new GithubFile()
            {
                name = "StringProperty.snippet", download_url = "https://raw.githubusercontent.com/philpursglove/CSharpSnippets/master/StringProperty.snippet"
            };
            await syncer.DownloadFile(file, FolderPath);

            Assert.That(File.Exists(Path.Combine(FolderPath, "StringProperty.snippet")));
        }
Example #3
0
        public void ClearFolder_Removes_All_Files_From_A_Folder()
        {
            File.WriteAllText(Path.Combine(FolderPath, Path.GetRandomFileName()), "test");
            File.WriteAllText(Path.Combine(FolderPath, Path.GetRandomFileName()), "test");
            File.WriteAllText(Path.Combine(FolderPath, Path.GetRandomFileName()), "test");

            SnippetSyncer syncer = new SnippetSyncer();

            syncer.ClearFolder(FolderPath);

            Assert.That(Directory.GetFiles(FolderPath).Length, Is.EqualTo(0));
        }
Example #4
0
        public void SaveTimestampFile_Saves_File()
        {
            SnippetSyncer syncer = new SnippetSyncer();

            LocalUpdateFile updateFile = new LocalUpdateFile {
                LastUpdated = DateTime.Now
            };

            syncer.SaveTimestampFile(FolderPath, updateFile);

            Assert.That(File.Exists(FilePath));
        }
Example #5
0
        public void Can_Read_Timestamp_From_File()
        {
            DateTime        testTimestamp = new DateTime(2020, 7, 5, 12, 0, 0);
            LocalUpdateFile updateFile    = new LocalUpdateFile {
                LastUpdated = testTimestamp
            };

            SnippetSyncer syncer = new SnippetSyncer();

            syncer.SaveTimestampFile(FolderPath, updateFile);

            DateTime localFileTimestamp = syncer.GetTimestampFromLocalFile(FolderPath);

            Assert.That(localFileTimestamp, Is.EqualTo(testTimestamp));
        }