コード例 #1
0
        public void Path_HandleNoTarget(string value, bool useEmptyData)
        {
            var expected   = _AllHitData;
            var hitManager = _hitManager;

            if (useEmptyData)
            {
                expected   = new List <HitData>();
                hitManager = _hitManagerEmpty;
            }

            var options = new GetGitChangeDirectoryCommandOptions {
                NameOrAlias = value
            };
            var testCmd = new ActionNameOrAlias(_repoPaths, options, hitManager);

            _info.Options = new GetGitChangeDirectoryCommandOptions {
                NameOrAlias = options.NameOrAlias
            };

            var origList = options.List;
            var result   = testCmd.Process(_info);

            Assert.False(result);

            hitManager.Received(0).GetHitList();
        }
コード例 #2
0
        public void Path_HandlePreviousTarget_no_data()
        {
            var options = new GetGitChangeDirectoryCommandOptions {
                NameOrAlias = "-"
            };
            var testCmd = new ActionNameOrAlias(_repoPaths, options, _hitManagerEmpty);

            var result = testCmd.Process(_info);

            Assert.True(result);

            _hitManagerEmpty.Received(1).GetHitList();

            Assert.Null(_info.TargetDirectory);
        }
コード例 #3
0
        public void Path_HandleRootTarget_no_data(string value)
        {
            var options = new GetGitChangeDirectoryCommandOptions {
                NameOrAlias = value
            };
            var testCmd = new ActionNameOrAlias(_repoPaths, options, _hitManagerEmpty);

            var result = testCmd.Process(_info);

            Assert.True(result);

            _hitManagerEmpty.Received(1).GetHitList();

            Assert.NotNull(_info.TargetDirectory);
            Assert.AreEqual(_repoPaths.RootFolder, _info.TargetDirectory);
        }
コード例 #4
0
        public void Path_HandleSingleTarget()
        {
            var expected           = _AllHitData.First();
            var expectedFolderName = GcdTestHelper.GetFolderNameFromPath(expected.Directory);
            var options            = new GetGitChangeDirectoryCommandOptions {
                NameOrAlias = expectedFolderName
            };
            var testCmd = new ActionNameOrAlias(_repoPaths, options, _hitManager);

            var result = testCmd.Process(_info);

            Assert.True(result);

            _hitManager.Received(1).GetHitList();
            Assert.AreEqual(expected.Directory, _info.TargetDirectory);
        }
コード例 #5
0
        public void Path_HandleMultiTarget_no_data()
        {
            var options = new GetGitChangeDirectoryCommandOptions {
                NameOrAlias = "SomeRandomName"
            };
            var testCmd = new ActionNameOrAlias(_repoPaths, options, _hitManagerEmpty);

            var result = testCmd.Process(_info);

            Assert.True(result);

            _hitManagerEmpty.Received(1).GetHitList();
            CollectionAssert.IsEmpty(_info.ListData);
            Assert.Null(_info.TargetDirectory);
            Assert.True(_info.Options.List);
            Assert.True(_info.PromptForListSelector);
        }
コード例 #6
0
        public void Path_HandleMultiTarget()
        {
            var options = new GetGitChangeDirectoryCommandOptions {
                NameOrAlias = "SomeRandomName"
            };
            var testCmd = new ActionNameOrAlias(_repoPaths, options, _hitManager);

            var result = testCmd.Process(_info);

            Assert.True(result);

            _hitManager.Received(1).GetHitList();
            Assert.True(GcdTestHelper.AreSame(_AllHitData, _info.ListData));
            Assert.Null(_info.TargetDirectory);
            Assert.True(_info.Options.List);
            Assert.True(_info.PromptForListSelector);
        }
コード例 #7
0
        public void Path_HandlePreviousTarget()
        {
            var options = new GetGitChangeDirectoryCommandOptions {
                NameOrAlias = "-"
            };
            var testCmd = new ActionNameOrAlias(_repoPaths, options, _hitManager);

            var expected = _AllHitData.OrderByDescending(x => x.DateLastHit)
                           .FirstOrDefault(x => x.Directory.IsSameFolder(_repoPaths.RootFolder) == false);

            var result = testCmd.Process(_info);

            Assert.True(result);

            _hitManager.Received(1).GetHitList();

            Assert.NotNull(_info.TargetDirectory);
            Assert.AreEqual(expected.Directory, _info.TargetDirectory);
        }