Exemplo n.º 1
0
        public void Synchronizer_creates_conflict_if_a_file_with_pending_syncactions_is_modified()
        {                 
            // SCENARIO
            // left: A -> B *Sync* -> C  *Sync*
            // right A      *Sync*       *Sync*
            // 3: A

            // ARRANGE
            var writeTimeA = DateTime.Now;
            var writeTimeB = writeTimeA.AddHours(1);
            var writeTimeC = writeTimeA.AddHours(2);

            var historyBuilder1 = new HistoryBuilder(m_Group, "history1");
            historyBuilder1.AddFile("file1", writeTimeA);
            historyBuilder1.CreateSnapshot();
            historyBuilder1.RemoveFile("file1");
            historyBuilder1.AddFile("file1", writeTimeB);
            historyBuilder1.CreateSnapshot();

            var historyBuilder2 = new HistoryBuilder(m_Group, "history2");
            historyBuilder2.AddFile("file1", writeTimeA);
            historyBuilder2.CreateSnapshot();

            var historyBuilder3 = new HistoryBuilder(m_Group, "history3");
            historyBuilder3.AddFile("file1", writeTimeA);
            historyBuilder3.CreateSnapshot();

            m_Instance.Synchronize(m_Group);

            historyBuilder1.RemoveFile("file1");
            historyBuilder1.AddFile("file1", writeTimeC);
            historyBuilder1.CreateSnapshot();

            // ACT
            m_Instance.Synchronize(m_Group);            

            // ASSERT: The pending sync action cannot be applied => create a conflict for the file

            var conflicts = m_Group.GetSyncConflictService().Items.ToArray();
            Assert.Single(conflicts);

            // snapshot ids must be null (there were no previous sync at the time the non-applicable sync action was created)
            Assert.Null(conflicts.Single().SnapshotId);

            Assert.Empty(m_Group.GetSyncActionService().PendingItems);

        }
Exemplo n.º 2
0
        public void Synchronize_without_previous_sync_no_conflicts()
        {
            // ARRANGE
            var left = new HistoryBuilder(m_Group, "left");
            left.AddFile("file1");
            left.CreateSnapshot();

            left.RemoveFile("file1");
            left.CreateSnapshot();

            var right = new HistoryBuilder(m_Group, "right");

            right.AddFile("file2");
            right.CreateSnapshot();

            right.RemoveFile("file2");
            right.CreateSnapshot();

            //ACT
            m_Instance.Synchronize(m_Group);

            //ASSERT
            Assert.Empty(m_Group.GetSyncConflictService().Items);
            var syncActions = m_Group.GetSyncActionService().AllItems.ToArray();
            Assert.Empty(syncActions);
            Assert.Single(m_Group.GetSyncPointService().Items);
        }