public void UpdateStatusesAndCommands(string date1, string date2, string strExpextedStatus1, string strExpextedStatus2)
        {
            var expextedStatus1 = Enum.Parse <ItemStatusEnum>(strExpextedStatus1);
            var expextedStatus2 = Enum.Parse <ItemStatusEnum>(strExpextedStatus2);

            var item1 = new SynchronizedItem(null, false, date1 == null ? null :
                                             new TestItem(DateTime.Parse(date1)));
            var item2 = new SynchronizedItem(null, false, date2 == null ? null :
                                             new TestItem(DateTime.Parse(date2)));

            var matcher = new SynchronizedItemMatcher();

            matcher.UpdateStatusesAndCommands(item1, item2);

            Assert.Equal(expextedStatus1, item1.Status.StatusEnum);
            Assert.Equal(expextedStatus2, item2.Status.StatusEnum);
            Assert.NotNull(item1.SyncCommand.CommandAction);
            Assert.NotNull(item2.SyncCommand.CommandAction);
        }
        public void UpdateStatusesAndCommandsForEquals()
        {
            var lastUpdate = DateTime.Now;

            var item1 = new SynchronizedItem(null, false, new TestItem(lastUpdate));
            var item2 = new SynchronizedItem(null, false, new TestItem(lastUpdate));

            // Чтобы потом проверить, что команд не стало.
            item1.SyncCommand.SetCommandAction(() => { return(Task.FromResult(true)); });
            item2.SyncCommand.SetCommandAction(() => { return(Task.FromResult(true)); });

            var matcher = new SynchronizedItemMatcher();

            matcher.UpdateStatusesAndCommands(item1, item2);

            Assert.Equal(ItemStatusEnum.Equally, item1.Status.StatusEnum);
            Assert.Equal(ItemStatusEnum.Equally, item2.Status.StatusEnum);
            Assert.Null(item1.SyncCommand.CommandAction);
            Assert.Null(item2.SyncCommand.CommandAction);
        }
예제 #3
0
        public void Init(bool isDirectory)
        {
            var leftSynchronizedItem  = new SynchronizedItem("LeftItem", isDirectory, null);
            var rightSynchronizedItem = new SynchronizedItem("RightItem", isDirectory, null);
            var leftItemViewModel     = new ItemViewModel(leftSynchronizedItem);
            var rightItemViewModel    = new ItemViewModel(rightSynchronizedItem);

            var rowViewModel = new RowViewModel(leftItemViewModel, rightItemViewModel, null);

            Assert.Equal(leftItemViewModel, rowViewModel.LeftItem);
            Assert.Equal(rightItemViewModel, rowViewModel.RightItem);

            Assert.Equal(isDirectory, rowViewModel.IsDirectory);

            Assert.Empty(rowViewModel.ChildRows); // Пока дочерние строки не добавлялись.

            Assert.False(rowViewModel.InProcess);

            // Пока команды синхронизации не заданы, кнопки команд должны быть не видиммы.
            Assert.False(rowViewModel.CommandButtonIsVisible);
        }
        public void UpdateStatusesAndCommandsForLoadError(string loadError1, string loadError2)
        {
            var itemViewModel1 = new SynchronizedItem(null, false, new TestItem(DateTime.Now)
            {
                LastLoadError = loadError1
            });
            var itemViewModel2 = new SynchronizedItem(null, false, new TestItem(DateTime.Now)
            {
                LastLoadError = loadError2
            });

            // Чтобы потом проверить, что команд не стало.
            itemViewModel1.SyncCommand.SetCommandAction(() => { return(Task.FromResult(true)); });
            itemViewModel2.SyncCommand.SetCommandAction(() => { return(Task.FromResult(true)); });

            var matcher = new SynchronizedItemMatcher();

            matcher.UpdateStatusesAndCommands(itemViewModel1, itemViewModel2);

            Assert.Equal(ItemStatusEnum.LoadError, itemViewModel1.Status.StatusEnum);
            Assert.Equal(ItemStatusEnum.LoadError, itemViewModel2.Status.StatusEnum);
            Assert.Null(itemViewModel1.SyncCommand.CommandAction);
            Assert.Null(itemViewModel2.SyncCommand.CommandAction);
        }
 public TestSynchronizedItems(string itemName)
 {
     LeftItem  = new SynchronizedItem(itemName, true, null);
     RightItem = new SynchronizedItem(itemName, true, null);
 }
예제 #6
0
 public TestSynchronizedItems(IItem item)
 {
     _item     = item;
     LeftItem  = new SynchronizedItem(item.FullPath, item is IDirectory, item);
     RightItem = new SynchronizedItem(item.FullPath, item is IDirectory, item);
 }