public void ViewModel_ValidateVisiblFlags()
        {
            SelectBranchPlanViewModel vm = new SelectBranchPlanViewModel();
            MockTeamExplorer mockTE = new MockTeamExplorer();
            MockPlanCatalog mockPlanCataog = new MockPlanCatalog();
            vm.Load(mockTE, mockPlanCataog, null);

            bool showFormStart = vm.ShowForm;
            bool showProgressStart = vm.ShowProgress;
            bool showDoneStart = vm.IsJobDone;
            Assert.AreEqual(showFormStart, true);
            Assert.AreEqual(showProgressStart, false);
            Assert.AreEqual(showDoneStart, false);

            vm.JobStatus = JobStatus.inProgress;

            bool showFormInProgress = vm.ShowForm;
            bool showProgressInProgress = vm.ShowProgress;
            bool showDoneInPogress = vm.IsJobDone;
            Assert.AreEqual(showFormInProgress, false);
            Assert.AreEqual(showProgressInProgress, true);
            Assert.AreEqual(showDoneInPogress, false);

            vm.JobStatus = JobStatus.done;

            bool showFormDone = vm.ShowForm;
            bool showProgressDone = vm.ShowProgress;
            bool showDoneDone = vm.IsJobDone;
            Assert.AreEqual(showFormDone, false);
            Assert.AreEqual(showProgressDone, true);
            Assert.AreEqual(showDoneDone, true);
        }
        public void ViewModel_ValidateExecuteErrorLoading()
        {
            SelectBranchPlanViewModel vm = new SelectBranchPlanViewModel();
            MockTeamExplorer mockTE = new MockTeamExplorer();
            MockEngine engine = new MockEngine();
            MockPlanCatalog mockPlanCataog = new MockPlanCatalog();
            vm.Load(mockTE, mockPlanCataog, null);

            Task t = vm.ExecuteJob();
            t.Wait();

            Assert.AreEqual(vm.JobProgress, 100.0);
            Assert.AreEqual(vm.JobCurrentOperation, "Error: \nObject reference not set to an instance of an object.\n   at Microsoft.ALMRangers.BranchTool.VSExtension.ViewModels.SelectBranchPlanViewModel.<>c__DisplayClass5.<ExecuteJob>b__1(Task param0) in c:\\Src_Rangers\\BranchTool\\code\\TfsBranchToolVSExtension\\ViewModels\\SelectBranchPlanViewModel.cs:line 268");
        }
        public void ViewModel_ValidateProgress()
        {
            SelectBranchPlanViewModel vm = new SelectBranchPlanViewModel();
            MockTeamExplorer mockTE = new MockTeamExplorer();
            MockPlanCatalog mockPlanCataog = new MockPlanCatalog();
            vm.Load(mockTE, mockPlanCataog, null);

            string started = "Started";
            vm.UpdateStatus(0, started);

            Assert.AreEqual(vm.JobProgress, 0);
            Assert.AreEqual(vm.JobCurrentOperation, started);
            Assert.AreEqual(vm.JobOperationLog, started + "\n");

            string op1 = "Operation1";
            vm.UpdateStatus(10, op1);

            Assert.AreEqual(vm.JobProgress, 10);
            Assert.AreEqual(vm.JobCurrentOperation, op1);
            Assert.AreEqual(vm.JobOperationLog, started + "\n" + op1 + "\n");

            string op2 = "Operation2";
            vm.UpdateStatus(100, op2);
            Assert.AreEqual(vm.JobProgress, 100);
            Assert.AreEqual(vm.IsJobDone, true);
            Assert.AreEqual(vm.JobCurrentOperation, op2);
            Assert.AreEqual(vm.JobOperationLog, started + "\n" + op1 + "\n" + op2 + "\n");
        }
        public void ViewModel_ValidateExecute()
        {
            SelectBranchPlanViewModel vm = new SelectBranchPlanViewModel();
            MockTeamExplorer mockTE = new MockTeamExplorer();
            MockEngine engine = new MockEngine();
            MockPlanCatalog mockPlanCataog = new MockPlanCatalog();
            vm.Load(mockTE, mockPlanCataog, engine);

            vm.ExecuteJob();
        }
        public void ViewModel_NotLoadedTest_BranchPlans()
        {
            SelectBranchPlanViewModel vm = new SelectBranchPlanViewModel();
            MockTeamExplorer mockTE = new MockTeamExplorer();
            MockPlanCatalog mockPlanCataog = new MockPlanCatalog();
            IEnumerable<ActionPlan> lst;

            lst = vm.BranchPlans;

            Assert.AreEqual(lst, null);
        }
        public void ViewModel_NotLoadedTest_Argument()
        {
            SelectBranchPlanViewModel vm = new SelectBranchPlanViewModel();
            MockTeamExplorer mockTE = new MockTeamExplorer();
            MockPlanCatalog mockPlanCataog = new MockPlanCatalog();
            List<BranchPlanArgument> lst;

            lst = vm.Arguments;

            Assert.AreEqual(lst.Count, 3);
        }
        public void ViewModel_LoadTeamExplorerTestBasic()
        {
            SelectBranchPlanViewModel vm = new SelectBranchPlanViewModel();
            MockTeamExplorer mockTE = new MockTeamExplorer();
            MockPlanCatalog mockPlanCataog = new MockPlanCatalog();
            Dictionary<string, object> d;
            vm.Load(mockTE, mockPlanCataog, null);
            vm.SelectedBranchPlan = mockPlanCataog.GetPlan("Basic");
            d = vm.Arguments.ToDictionary(x => x.Name, x => x.Value as object);

            object actualCollection, actualTPName, actualRoot;

            d.TryGetValue("ProjectCollectionUrl", out actualCollection);
            d.TryGetValue("TeamProject", out actualTPName);
            d.TryGetValue("RootFolder", out actualRoot);

            Assert.AreEqual(actualCollection.ToString(), mockTE.TPCollectionUri.ToString());
            Assert.AreEqual(actualTPName.ToString(), mockTE.TPName);
            Assert.AreEqual(actualRoot.ToString(), mockTE.CurrentSourceControlFolder);
        }
        public void ViewModel_BranchPlanTest()
        {
            SelectBranchPlanViewModel vm = new SelectBranchPlanViewModel();
            MockTeamExplorer te = new MockTeamExplorer();
            MockPlanCatalog pc = new MockPlanCatalog();
            vm.Load(te, pc, null);

            IEnumerable<ActionPlan> lst2 = vm.BranchPlans;
            List<ActionPlan> lst = new List<ActionPlan>();
            lst.AddRange(lst2);

            Assert.AreEqual(lst.Count, 2);

            Assert.AreEqual(lst[0].Name, "Basic");
            Assert.AreEqual(lst[1].Name, "Feature");
        }