コード例 #1
0
    private void SetupMainTab(NodeModelBase directoryModel)
    {
        LoadDirectorySize(directoryModel.FullPath);

        var filesCount       = _fileService.GetFiles(directoryModel.FullPath).Count;
        var directoriesCount = _directoryService.GetChildDirectories(directoryModel.FullPath).Count;

        MainNodeInfoTabViewModel.Activate(directoryModel, true, filesCount, directoriesCount);
    }
コード例 #2
0
    public void TestProperties(string filePath, string extension, bool isDirectory, bool isImage)
    {
        _autoMocker
        .Setup <IFileSizeFormatter, string>(m => m.GetFormattedSize(Size))
        .Returns(FormattedSize);
        _autoMocker
        .Setup <IFileSizeFormatter, string>(m => m.GetSizeAsNumber(Size))
        .Returns(SizeAsNumber);
        _autoMocker
        .Setup <IPathService, string>(m => m.GetParentDirectory(filePath))
        .Returns(ParentDirectory);
        _autoMocker
        .Setup <IPathService, string>(m => m.GetFileName(filePath))
        .Returns(FileName);
        _autoMocker
        .Setup <IPathService, string>(m => m.GetExtension(filePath))
        .Returns(extension);
        _autoMocker
        .Setup <IBitmapFactory, IBitmap>(m => m.Create(filePath))
        .Returns(new Mock <IBitmap>().Object);

        var viewModel = _autoMocker.CreateInstance <MainNodeInfoTabViewModel>();
        var nodeModel = new NodeModelBase
        {
            FullPath             = filePath,
            CreatedDateTime      = DateTime.Now,
            LastAccessDateTime   = DateTime.Now.AddHours(1),
            LastModifiedDateTime = DateTime.Now.AddHours(2),
        };

        viewModel.Activate(nodeModel, isDirectory, InnerFilesCount, InnerDirectoriesCount);
        viewModel.SetSize(Size);

        Assert.Equal(nodeModel.CreatedDateTime, viewModel.CreatedDateTime);
        Assert.Equal(nodeModel.LastAccessDateTime, viewModel.LastAccessDateTime);
        Assert.Equal(nodeModel.LastModifiedDateTime, viewModel.LastWriteDateTime);
        Assert.Equal(FormattedSize, viewModel.FormattedSize);
        Assert.Equal(SizeAsNumber, viewModel.FormattedSizeAsNumber);
        Assert.Equal(FileName, viewModel.Name);
        Assert.Equal(ParentDirectory, viewModel.Path);
        Assert.Equal(isDirectory, viewModel.IsDirectory);
        Assert.Equal(InnerFilesCount, viewModel.InnerFilesCount);
        Assert.Equal(InnerDirectoriesCount, viewModel.InnerDirectoriesCount);

        if (isImage)
        {
            Assert.NotNull(viewModel.ImageBitmap);
        }
        else
        {
            Assert.Null(viewModel.ImageBitmap);
        }
    }
コード例 #3
0
 public TransitionEndModel(NodeModelBase udsaetNodeModel)
 {
     Node = udsaetNodeModel;
 }
コード例 #4
0
        private void SetupMainTab(NodeModelBase directoryModel)
        {
            LoadDirectorySize(directoryModel.FullPath);

            MainNodeInfoTabViewModel.Activate(directoryModel, true);
        }
コード例 #5
0
 public override bool IsSatisfiedBy(NodeModelBase nodeModel) =>
 _regexService.CheckIfMatches(nodeModel.Name, _regex,
                              _isCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);
コード例 #6
0
 public abstract bool IsSatisfiedBy(NodeModelBase nodeModel);
コード例 #7
0
 public override bool IsSatisfiedBy(NodeModelBase nodeModel) =>
 nodeModel.Name.Contains(_text,
                         _isCaseSensitive ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase);
コード例 #8
0
        public void TestProperties(string filePath, string extension, bool isDirectory, bool isImage)
        {
            var configuration = new ImagePreviewConfiguration
            {
                SupportedFormats = new List <string>
                {
                    "png", "jpg"
                }
            };
            var fileSizeFormatterMock = new Mock <IFileSizeFormatter>();

            fileSizeFormatterMock
            .Setup(m => m.GetFormattedSize(Size))
            .Returns(FormattedSize);
            fileSizeFormatterMock
            .Setup(m => m.GetSizeAsNumber(Size))
            .Returns(SizeAsNumber);
            var pathServiceMock = new Mock <IPathService>();

            pathServiceMock
            .Setup(m => m.GetParentDirectory(filePath))
            .Returns(ParentDirectory);
            pathServiceMock
            .Setup(m => m.GetFileName(filePath))
            .Returns(FileName);
            pathServiceMock
            .Setup(m => m.GetExtension(filePath))
            .Returns(extension);
            var bitmapFactoryMock = new Mock <IBitmapFactory>();

            bitmapFactoryMock
            .Setup(m => m.Create(filePath))
            .Returns(new Mock <IBitmap>().Object);

            var viewModel = new MainNodeInfoTabViewModel(fileSizeFormatterMock.Object,
                                                         pathServiceMock.Object, bitmapFactoryMock.Object, configuration);
            var nodeModel = new NodeModelBase
            {
                FullPath             = filePath,
                CreatedDateTime      = DateTime.Now,
                LastAccessDateTime   = DateTime.Now.AddHours(1),
                LastModifiedDateTime = DateTime.Now.AddHours(2),
            };

            viewModel.Activate(nodeModel, isDirectory);
            viewModel.SetSize(Size);

            Assert.Equal(nodeModel.CreatedDateTime, viewModel.CreatedDateTime);
            Assert.Equal(nodeModel.LastAccessDateTime, viewModel.LastAccessDateTime);
            Assert.Equal(nodeModel.LastModifiedDateTime, viewModel.LastWriteDateTime);
            Assert.Equal(FormattedSize, viewModel.FormattedSize);
            Assert.Equal(SizeAsNumber, viewModel.FormattedSizeAsNumber);
            Assert.Equal(FileName, viewModel.Name);
            Assert.Equal(ParentDirectory, viewModel.Path);
            Assert.Equal(isDirectory, viewModel.IsDirectory);

            if (isImage)
            {
                Assert.NotNull(viewModel.ImageBitmap);
            }
            else
            {
                Assert.Null(viewModel.ImageBitmap);
            }
        }
コード例 #9
0
 public void DeleteNode(NodeModelBase node)
 {
     Nodes.Remove(node);
     // TODO remove links here too, at some point
 }
コード例 #10
0
 public TransitionStartModel(NodeModelBase node)
 {
     Node = node;
 }
コード例 #11
0
 public override bool IsSatisfiedBy(NodeModelBase nodeModel) => true;