Exemplo n.º 1
0
        public void CloneWillThrowAnExceptionIfRepoToCloneIsNotPopulated()
        {
            var cloneView = Mocks.StrictMock <CloneView>();

            cloneView.SetPropertyAsBehavior(v => v.RepositoryToClone);
            cloneView.SetPropertyAsBehavior(v => v.DestinationFolder);

            var clone = Mocks.StrictMock <Clone>();

            clone.SetPropertyAsBehavior(v => v.RepositoryToClone);
            clone.SetPropertyAsBehavior(v => v.Destination);

            clone.Expect(v => v.Run()).Repeat.Never();

            Mocks.ReplayAll();

            const string destinationFolder = @"C:\NewClone\Location";

            cloneView.RepositoryToClone = null;
            cloneView.DestinationFolder = destinationFolder;

            var presenter = new ClonePresenter(cloneView)
            {
                Clone = clone
            };

            presenter.PerformClone();
        }
Exemplo n.º 2
0
        public void HideDestionationFolderWillNotBeCalledTwiceWhenNoChange()
        {
            var view = Mocks.StrictMock <CloneView>();

            view.Expect(v => v.HideDestinationFolder()).Repeat.Once();
            view.Expect(v => v.DisplayDestinationFolder()).Repeat.Once();

            view.RepositoryToClone = "does_not_matter";
            LastCall.PropertyBehavior();

            Mocks.ReplayAll();

            view.RepositoryToClone = "some data to get test set up";

            var presenter = new ClonePresenter(view);

            presenter.RepositoryToCloneChanged();

            Assert.That(presenter.DestinationFolderDisplayed, Is.True);

            view.RepositoryToClone = null;

            presenter.RepositoryToCloneChanged();

            Assert.That(presenter.DestinationFolderDisplayed, Is.False);

            view.RepositoryToClone = null;

            presenter.RepositoryToCloneChanged();

            Assert.That(presenter.DestinationFolderDisplayed, Is.False);
        }
Exemplo n.º 3
0
        public void SecondTimeRepositoryToCloneChangedAndValidTextNoChangeWithDestionationFolderOccuers()
        {
            var view = Mocks.StrictMock <CloneView>();

            view.Expect(v => v.DisplayDestinationFolder()).Repeat.Once();

            view.RepositoryToClone = "ve";
            LastCall.PropertyBehavior();

            Mocks.ReplayAll();

            view.RepositoryToClone = "somedata";

            var presenter = new ClonePresenter(view);

            presenter.RepositoryToCloneChanged();

            Assert.That(presenter.DestinationFolderDisplayed, Is.True);

            view.RepositoryToClone = "new data";

            presenter.RepositoryToCloneChanged();

            Assert.That(presenter.DestinationFolderDisplayed, Is.True);
        }
Exemplo n.º 4
0
        public void WhenCloneButtonIsVisibleItNotDisplayedAgain()
        {
            var view = Mocks.StrictMock <CloneView>();

            view.Expect(v => v.ShowCloneButton()).Repeat.Once();

            view.SetPropertyAsBehavior(v => v.RepositoryToClone);
            view.SetPropertyAsBehavior(v => v.DestinationFolder);

            Mocks.ReplayAll();

            view.RepositoryToClone = "some value";
            view.DestinationFolder = "more value";

            var presenter = new ClonePresenter(view);

            presenter.DestionFolderTextChanged();

            Assert.That(presenter.IsCloneButtonShown, Is.True);

            view.RepositoryToClone = "changes value";
            view.DestinationFolder = "other changes value";

            presenter.DestionFolderTextChanged();

            Assert.That(presenter.IsCloneButtonShown, Is.True);
        }
Exemplo n.º 5
0
        public void WhenRepositoryIsLocalNameIsNotAutomaticlyPutInDestinationFolder()
        {
            CloneView cloneView = SetUpClonePresenterTestWithRepositry(TestRepository, DestinationLocation);

            var presenter = new ClonePresenter(cloneView);

            presenter.SetDestinationFolder(DestinationLocation);

            Assert.That(cloneView.DestinationFolder, Is.EqualTo(DestinationLocation));
        }
Exemplo n.º 6
0
        public void CloneWillCloneTheRepositoryToTheDestination()
        {
            var cloneView = Mocks.StrictMock <CloneView>();

            cloneView.SetPropertyAsBehavior(v => v.RepositoryToClone);
            cloneView.SetPropertyAsBehavior(v => v.DestinationFolder);

            var clone = Mocks.StrictMock <Clone>();

            clone.SetPropertyAsBehavior(v => v.RepositoryToClone);
            clone.SetPropertyAsBehavior(v => v.Destination);
            clone.SetPropertyAsBehavior(v => v.ProjectLocation);

            var result = new TestAsyncResults
            {
                AsyncState = new FakeOutput
                {
                    Output = "Clone completed successfully"
                }
            };

            clone.Expect(v => v.Run()).Return(result);

            Mocks.ReplayAll();

            const string repoToClone       = @"C:\UnitTestRepo\ToClone";
            const string destinationFolder = @"C:\NewClone\Location";

            cloneView.RepositoryToClone = repoToClone;
            cloneView.DestinationFolder = destinationFolder;

            var presenter = new ClonePresenter(cloneView)
            {
                Clone = clone
            };

            bool   eventTriggered = false;
            string output         = string.Empty;

            Action <Output> cloneComplete = o =>
            {
                eventTriggered = true;
                output         = o.Output;
            };

            presenter.CloneComplete += cloneComplete;

            presenter.PerformClone();

            Assert.That(clone.RepositoryToClone, Is.EqualTo(repoToClone));
            Assert.That(clone.Destination, Is.EqualTo(destinationFolder));
            Assert.That(eventTriggered);
            Assert.That(output, Is.EqualTo("Clone completed successfully"));
            Assert.That(clone.ProjectLocation, Is.Null);
        }
Exemplo n.º 7
0
        public void DestinationFolderWillNotAddExtraSlashAtEndOfTheFolder()
        {
            var expectedDestinationFolder = string.Format("{0}\\{1}", DestinationLocation, "SubFolderTest");

            var cloneView = SetUpClonePresenterTestWithRepositry(@"[email protected]:DavidBasarab/SubFolderTest.git", expectedDestinationFolder);

            var presenter = new ClonePresenter(cloneView);

            presenter.SetDestinationFolder(DestinationLocation);

            Assert.That(cloneView.DestinationFolder, Is.EqualTo(expectedDestinationFolder));
        }
Exemplo n.º 8
0
        private void VerifyGitRepositoryName(string gitUrl)
        {
            string expectedDestinationFolder = string.Format("{0}\\{1}", DestinationLocation, "FatCatGit");

            CloneView cloneView = SetUpClonePresenterTestWithRepositry(gitUrl, expectedDestinationFolder);

            var presenter = new ClonePresenter(cloneView);

            presenter.SetDestinationFolder(DestinationLocation);

            Assert.That(cloneView.DestinationFolder, Is.EqualTo(expectedDestinationFolder));
        }
Exemplo n.º 9
0
        public void SpecificyDestionationFolderWillUseRepositoryNameAsSubFolder()
        {
            string expectedDestinationFolder = string.Format("{0}\\{1}", DestinationLocation, "SomeTestRepository");

            CloneView cloneView = SetUpClonePresenterTestWithRepositry(@"[email protected]:DavidBasarab/SomeTestRepository.git", expectedDestinationFolder);

            var presenter = new ClonePresenter(cloneView);

            presenter.SetDestinationFolder(DestinationLocation);

            Assert.That(cloneView.DestinationFolder, Is.EqualTo(expectedDestinationFolder));
        }
Exemplo n.º 10
0
        public void IfDirectoryEndsInRepoNameDoNotAdd()
        {
            string expectedDestinationFolder = string.Format("{0}\\{1}\\", DestinationLocation, "SomeTestRepository");

            CloneView cloneView = SetUpClonePresenterTestWithRepositry(TestRepository, expectedDestinationFolder);

            var presenter = new ClonePresenter(cloneView);

            presenter.SetDestinationFolder(expectedDestinationFolder);

            Assert.That(cloneView.DestinationFolder, Is.EqualTo(expectedDestinationFolder));
        }
Exemplo n.º 11
0
        public void WhenRepositoryAndDestinaitonArePopulatedCloneButtonIsShown()
        {
            CloneView view = SetUpTestForDisplayCloneButton();

            view.RepositoryToClone = "some value";
            view.DestinationFolder = "some value, can be same of different";

            var presenter = new ClonePresenter(view);

            presenter.DestionFolderTextChanged();

            Assert.That(presenter.IsCloneButtonShown, Is.True);
        }
Exemplo n.º 12
0
        public void WhenRepositoryIsNotPopulatedTheCloneButtonIsNotShown()
        {
            CloneView view = SetUpTestForHideCloneButton();

            var presenter = new ClonePresenter(view);

            view.RepositoryToClone = "value";
            view.DestinationFolder = "some value";

            presenter.DestionFolderTextChanged();

            view.RepositoryToClone = null;
            view.DestinationFolder = "some value";

            presenter.DestionFolderTextChanged();

            Assert.That(presenter.IsCloneButtonShown, Is.False);
        }
Exemplo n.º 13
0
        public void WhenTextIsAddedToRepositoryDisplayDestionationIsCalled()
        {
            var view = Mocks.DynamicMock <CloneView>();

            view.Expect(v => v.DisplayDestinationFolder());

            view.RepositoryToClone = "ve";
            LastCall.PropertyBehavior();

            Mocks.ReplayAll();

            view.RepositoryToClone = "somedata";

            var presenter = new ClonePresenter(view);

            presenter.RepositoryToCloneChanged();

            Assert.That(presenter.DestinationFolderDisplayed, Is.True);
        }
Exemplo n.º 14
0
        public void WhenRespitoryToChangeIsNullAndAChangeEventWillNotDisplayDestination()
        {
            var view = Mocks.StrictMock <CloneView>();

            view.Expect(v => v.HideDestinationFolder()).Repeat.Never();

            view.RepositoryToClone = "ve";
            LastCall.PropertyBehavior();

            Mocks.ReplayAll();

            view.RepositoryToClone = null;

            var presenter = new ClonePresenter(view);

            presenter.RepositoryToCloneChanged();

            Assert.That(presenter.DestinationFolderDisplayed, Is.False);
        }
Exemplo n.º 15
0
        public void IfDestinationFolderBlankItIsNotSet()
        {
            var cloneView = Mocks.DynamicMock <CloneView>();

            cloneView.Expect(v => v.RepositoryToClone).IgnoreArguments().Repeat.Never();

            cloneView.DestinationFolder = null;
            LastCall.PropertyBehavior();
            LastCall.IgnoreArguments();
            LastCall.Repeat.Never();

            Mocks.ReplayAll();

            var presenter = new ClonePresenter(cloneView);

            presenter.SetDestinationFolder(null);

            Assert.That(cloneView.DestinationFolder, Is.Null);
        }
Exemplo n.º 16
0
        public void CloneButtonIsOnlyHiddenOnce()
        {
            var view = Mocks.StrictMock <CloneView>();

            view.Expect(v => v.ShowCloneButton()).Repeat.Once();
            view.Expect(v => v.HideCloneButton()).Repeat.Once();

            view.RepositoryToClone = null;
            LastCall.PropertyBehavior();

            view.DestinationFolder = null;
            LastCall.PropertyBehavior();

            Mocks.ReplayAll();

            view.RepositoryToClone = "some value";
            view.DestinationFolder = "more value";

            var presenter = new ClonePresenter(view);

            presenter.DestionFolderTextChanged();

            Assert.That(presenter.IsCloneButtonShown, Is.True);

            view.RepositoryToClone = null;
            view.DestinationFolder = null;

            presenter.DestionFolderTextChanged();

            Assert.That(presenter.IsCloneButtonShown, Is.False);

            view.RepositoryToClone = null;
            view.DestinationFolder = null;

            presenter.DestionFolderTextChanged();

            Assert.That(presenter.IsCloneButtonShown, Is.False);
        }
Exemplo n.º 17
0
        public void WhenTextIsRemovedToRepositoryHideDisplayIsCalled()
        {
            var view = Mocks.DynamicMock <CloneView>();

            view.Expect(v => v.HideDestinationFolder());

            view.RepositoryToClone = "ve";
            LastCall.PropertyBehavior();

            Mocks.ReplayAll();

            view.RepositoryToClone = "some early data";

            var presenter = new ClonePresenter(view);

            presenter.RepositoryToCloneChanged();

            view.RepositoryToClone = null;

            presenter.RepositoryToCloneChanged();

            Assert.That(presenter.DestinationFolderDisplayed, Is.False);
        }