Exemplo n.º 1
0
        public void Update_nonexisting_entry()
        {
            var syncTable = new List<SyncTableEntry> {new SyncTableEntry {Id = "myid", RelativeFilename = "myfn"}};
            var sut = new RemoteSyncTable(REPO_PATH, syncTable);

            var rf = new RepoFile { Id = "my new id", RelativeFileName = "my non existing fn" };
            RepoFile result = null;
            sut.UpdateEntry(rf, null, _ => result = _);

            Equalidator.AreEqual(result, rf);
        }
Exemplo n.º 2
0
        public void Persist_sync_table_after_add_and_update()
        {
            var sut = new RemoteSyncTable(REPO_PATH, new List<SyncTableEntry>());

            sut.AddEntry(new RepoFile{Id="myid", User="******", TimeStamp=new DateTime(2000,5,12, 10, 11, 12), RelativeFileName="myfn"});
            Assert.AreEqual("myfn\tmyid\tmyuser\t2000-05-12T10:11:12\r\n", File.ReadAllText(REPO_PATH + @"\.sync"));

            sut.UpdateEntry(new RepoFile { Id = "myid2", User = "******", TimeStamp = new DateTime(1999, 12, 31), RelativeFileName = "myfn" }, _ => { }, null);
            Assert.AreEqual("myfn\tmyid2\tmyuser2\t1999-12-31T00:00:00\r\n", File.ReadAllText(REPO_PATH + @"\.sync"));

            sut.AddEntry(new RepoFile { Id = "yourid", User = "******", TimeStamp = new DateTime(2001, 3, 26), RelativeFileName = "yourfn" });
            Assert.AreEqual("myfn\tmyid2\tmyuser2\t1999-12-31T00:00:00\r\nyourfn\tyourid\tmyuser3\t2001-03-26T00:00:00\r\n", File.ReadAllText(REPO_PATH + @"\.sync"));
        }
Exemplo n.º 3
0
        public void Update_existing_entry()
        {
            var syncTable = new List<SyncTableEntry> {new SyncTableEntry {Id = "myid", User="******", TimeStamp=new DateTime(1999, 12, 31), RelativeFilename="myfn"}};
            var sut = new RemoteSyncTable(REPO_PATH, syncTable);

            RepoFile result = null;
            sut.UpdateEntry(new RepoFile { Id = "my new id", User = "******", TimeStamp = new DateTime(2000, 5, 12), RelativeFileName = "myfn" },
                            _ => result = _, null);

            Equalidator.AreEqual(result, new RepoFile{Id="myid", User="******", TimeStamp=new DateTime(1999,12,31), RelativeFileName="myfn"});
            Equalidator.AreEqual(new List<SyncTableEntry> { new SyncTableEntry { Id = "my new id", User="******", TimeStamp=new DateTime(2000,5,12), RelativeFilename = "myfn" } }, syncTable);
        }
Exemplo n.º 4
0
        public void Load_sync_table_upon_creation()
        {
            var sut = new RemoteSyncTable(REPO_PATH, new List<SyncTableEntry>());
            var rf = new RepoFile { Id = "myid", User = "******", TimeStamp = new DateTime(2000, 5, 12), RelativeFileName = "myfn" };
            sut.AddEntry(rf);

            sut = new RemoteSyncTable(REPO_PATH);

            RepoFile result = null;
            sut.CollectRepoFiles(_ => result = _);
            Equalidator.AreEqual(rf, result);

            sut.UpdateEntry(new RepoFile { Id = "myid2", User = "******", TimeStamp = new DateTime(1999, 12, 31), RelativeFileName = "myfn" }, _ => { }, null);
            Assert.AreEqual("myfn\tmyid2\tmyuser2\t1999-12-31T00:00:00\r\n", File.ReadAllText(REPO_PATH + @"\.sync"));
        }