Esempio n. 1
0
        public void SyncCommand_DeleteThenReAdd()
        {
            Decr1.UpdateTo("file1.txt < aa");
            SyncDecr1andEncr1();
            SyncDecr2andEncr1();

            Decr1.UpdateTo("");
            SyncDecr1andEncr1();
            SyncDecr2andEncr1();
            DirectoryAreEqual(Decr2, "", "deleted file propigated");

            Decr1.UpdateTo("file1.txt < abc");
            SyncDecr1andEncr1();
            SyncDecr2andEncr1();

            Decr2.AssertEqual("file1.txt < abc");
        }
Esempio n. 2
0
        public void SyncCommand_DeleteFolderOn1andAddFileOn2()
        {
            Decr1.UpdateTo(@"aa\001.txt < 001");
            Decr2.UpdateTo(@"");
            SyncDecr1andEncr1();
            SyncDecr2andEncr1();

            Decr1.UpdateTo(@""); //removes file and directory
            Decr2.UpdateTo(      //add file to directory
                @"aa\001.txt < 001",
                @"aa\002.txt < 002");
            SyncDecr1andEncr1();

            SyncDecr2andEncr1();
            Decr2.AssertEqual(new string[] { @"aa/", @"aa\002.txt < 002" });

            SyncDecr1andEncr1();
            Decr1.AssertEqual(new string[] { @"aa/", @"aa\002.txt < 002" });
        }
Esempio n. 3
0
        public void SyncCommand_ChangeCaseOnly()
        {
            for (int i = 0; i < 10; i++)
            {
                Decr1.UpdateTo("A < xyz");
                SyncDecr1andEncr1(p => Assert.IsTrue(p.SyncMode == PreSyncMode.DecryptedSide));
                SyncDecr2andEncr1(p => Assert.IsTrue(p.SyncMode == PreSyncMode.EncryptedSide));
                Decr1.AssertEqual(new string[] { "A < xyz" });
                Decr2.AssertEqual(new string[] { "A < xyz" });

                Decr1.UpdateTo("a");
                SyncDecr1andEncr1(p => Assert.IsTrue(p.SyncMode == PreSyncMode.DecryptedSide));
                SyncDecr2andEncr1(p => Assert.IsTrue(p.SyncMode == PreSyncMode.EncryptedSide));
                Decr1.AssertEqual(new string[] { "a" });
                Decr2.AssertEqual(new string[] { "a" });
            }

            //Assert.IsTrue(false, "Sometimes works sometimes fails depending if th delete comes before the add");
        }
Esempio n. 4
0
        public void SyncCommand_OneWaySync_NoConflict_FuzzTesting(byte[] d1, byte[] d2)
        {
            Decr1.Clear(true);
            Decr2.Clear(true);

            string[] d1str = (d1 ?? (new byte[] { })).Select(d => choices[d % choices.Length]).ToArray();
            string[] d2str = (d2 ?? (new byte[] { })).Select(d => choices[d % choices.Length]).ToArray();

            Decr1.UpdateTo(d1str);
            SyncDecr1andEncr1(p => Assert.IsTrue(p.SyncMode == PreSyncMode.DecryptedSide));
            SyncDecr2andEncr1(p => Assert.IsTrue(p.SyncMode == PreSyncMode.EncryptedSide));
            Decr1.AssertEqual(d1str);
            Decr2.AssertEqual(d1str);

            Decr1.UpdateTo(d2str);
            SyncDecr1andEncr1(p => Assert.IsTrue(p.SyncMode == PreSyncMode.DecryptedSide));
            SyncDecr2andEncr1(p => Assert.IsTrue(p.SyncMode == PreSyncMode.EncryptedSide));
            Decr1.AssertEqual(d2str);
            Decr2.AssertEqual(d2str);
        }
Esempio n. 5
0
        public void SyncCommand_SimpleSync()
        {
            Decr1.UpdateTo("file1.txt < aa");
            var sync1 = SyncDecr1andEncr1();

            Assert.AreEqual(1, sync1.Changes.Count);

            var sync2 = SyncDecr2andEncr1();

            Assert.AreEqual(1, sync1.Changes.Count);


            Decr2.AssertEqual(new string[] { "file1.txt < aa" });

            Decr1.UpdateTo("file1.txt < aa",
                           "file2.txt < bb");

            SyncDecr1andEncr1();
            SyncDecr2andEncr1();
            Decr2.AssertEqual(new string[] { "file1.txt < aa",
                                             "file2.txt < bb" });;
        }