Exemple #1
0
    public void TestSortingFileAndDirectory(bool isAscending, SortingMode sortingColumn)
    {
        _autoMocker.Use(true);

        var directoryViewModel = _autoMocker.CreateInstance <DirectoryViewModel>();
        var fileViewModel      = _autoMocker.CreateInstance <FileViewModel>();

        var comparer = new FileSystemNodesComparer(isAscending, sortingColumn);

        var result = comparer.Compare(directoryViewModel, fileViewModel);

        Assert.True(result < 0);

        result = comparer.Compare(fileViewModel, directoryViewModel);
        Assert.True(result > 0);
    }
Exemple #2
0
        public void TestSortingParentDirectory(bool isAscending, SortingMode sortingColumn)
        {
            var parentDirectoryViewModel = _autoMocker.CreateInstance <DirectoryViewModel>();

            parentDirectoryViewModel.IsParentDirectory = true;
            var directoryViewModel = _autoMocker.CreateInstance <DirectoryViewModel>();

            var comparer = new FileSystemNodesComparer(isAscending, sortingColumn);

            var result = comparer.Compare(parentDirectoryViewModel, directoryViewModel);

            Assert.True(result < 0);

            result = comparer.Compare(directoryViewModel, parentDirectoryViewModel);
            Assert.True(result > 0);
        }
Exemple #3
0
    public void TestThrows(bool isAscending, SortingMode sortingColumn)
    {
        _autoMocker.Use(true);

        var directoryViewModel = _autoMocker.CreateInstance <DirectoryViewModel>();
        var nodeViewModel      = _autoMocker.CreateInstance <NodeViewModel>();

        var comparer = new FileSystemNodesComparer(isAscending, sortingColumn);

        void Compare() => comparer.Compare(nodeViewModel, directoryViewModel);

        Assert.Throws <InvalidOperationException>(Compare);

        void CompareReversed() => comparer.Compare(directoryViewModel, nodeViewModel);

        Assert.Throws <InvalidOperationException>(CompareReversed);
    }