public void ProcessTemplateCompleter_Exercise()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._templates);
            ProcessTemplateCache.Cache.Shell = ps;
            ProcessTemplateCache.Invalidate();

            var target = new ProcessTemplateCompleter(ps);
            var fakeBoundParameters = new Dictionary <string, string>();

            // Act
            var actual = target.CompleteArgument(string.Empty, string.Empty, string.Empty, null, fakeBoundParameters);

            // Assert
            Assert.AreEqual(5, actual.Count());
            var e = actual.GetEnumerator();

            e.MoveNext();
            Assert.AreEqual("Agile", e.Current.CompletionText, "Agile");
            e.MoveNext();
            Assert.AreEqual("CMMI", e.Current.CompletionText, "CMMI");
            e.MoveNext();
            Assert.AreEqual("Scrum", e.Current.CompletionText, "Scrum");
            e.MoveNext();
            Assert.AreEqual("'Scrum With Space'", e.Current.CompletionText, "Scrum With Space");
            e.MoveNext();
            Assert.AreEqual("Basic", e.Current.CompletionText, "Basic");
        }
        public void ProcessTemplateValidateAttribute_Invalid_Value_Throws()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._templates);
            ProcessTemplateCache.Cache.Shell = ps;
            ProcessTemplateCache.Invalidate();

            // Act
            // Assert
            Assert.ThrowsException <ValidationMetadataException>(() => this.Validate("Test", null));
        }
        public void WorkItemTypeValidateAttribute_Invalid_Value_Throws()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._defaultProject, this._workItemTypes);
            WorkItemTypeCache.Cache.Shell = ps;
            WorkItemTypeCache.Invalidate();

            // Act
            // Assert
            Assert.ThrowsException <ValidationMetadataException>(() => this.Validate("Test", null));
        }
        public void ProcessTemplateCache_Update_Returns_Null()
        {
            // Arrange
            var expected = 0;
            var ps       = BaseTests.PrepPowerShell();

            ProcessTemplateCache.Cache.Shell = ps;

            // Act
            ProcessTemplateCache.Update(null);

            // Assert
            Assert.AreEqual(expected, ProcessTemplateCache.Cache.Values.Count);
        }
        public void ProjectValidateAttribute_Null_Value_Does_Not_Throw()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._values);
            ProjectCache.Cache.Shell = ps;
            ProjectCache.Invalidate();

            // Act
            this.Validate(null, null);

            // Assert
        }
Beispiel #6
0
        public void QueryCache_Update_With_Empty_List()
        {
            // Arrange
            var expected = 0;
            var ps       = BaseTests.PrepPowerShell();

            QueryCache.Cache.Shell = ps;

            // Act
            QueryCache.Update(new List <string>());

            // Assert
            Assert.AreEqual(expected, QueryCache.Cache.Values.Count);
        }
        public void ProcessTemplateValidateAttribute_Empty_Cache_Does_Not_Throw()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._empty);
            ProcessTemplateCache.Cache.Shell = ps;
            ProcessTemplateCache.Invalidate();

            // Act
            this.Validate("Agile", null);

            // Assert
        }
        public void WorkItemTypeValidateAttribute_Empty_Cache_Does_Not_Throw()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._defaultProject, this._emptyStrings);
            WorkItemTypeCache.Cache.Shell = ps;
            WorkItemTypeCache.Invalidate();

            // Act
            this.Validate("Agile", null);

            // Assert
        }
        public void ProcessTemplateCache_Update_With_Null_List()
        {
            // Arrange
            var expected = 5;
            var ps       = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._items);
            ProcessTemplateCache.Cache.Shell = ps;

            // Act
            ProcessTemplateCache.Update(null);

            // Assert
            Assert.AreEqual(expected, ProcessTemplateCache.Cache.Values.Count);
        }
        public void WorkItemTypeCache_Update_Returns_Null()
        {
            // Arrange
            var expected = 0;
            var ps       = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._defaultProject, _emptyStrings);
            WorkItemTypeCache.Cache.Shell = ps;

            // Act
            WorkItemTypeCache.Update(null);

            // Assert
            Assert.AreEqual(expected, WorkItemTypeCache.Cache.Values.Count);
        }
        public void WorkItemTypeCache_GetCurrent()
        {
            // Arrange
            var expected = 5;
            var ps       = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._workItemTypes);
            WorkItemTypeCache.Cache.Shell = ps;

            // Act
            var actual = WorkItemTypeCache.GetCurrent();

            // Assert
            Assert.AreEqual(expected, actual.Count());
        }
        public void WorkItemTypeCache_Update_With_Null_List()
        {
            // Arrange
            var expected = 5;
            var ps       = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._workItemTypes);
            WorkItemTypeCache.Cache.Shell = ps;

            // Act
            WorkItemTypeCache.Update(null);

            // Assert
            Assert.AreEqual(expected, WorkItemTypeCache.Cache.Values.Count);
        }
Beispiel #13
0
        public void InvokeCompleter_Get_Areas_With_SubDomain_And_Area()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._areas);

            var target = new InvokeCompleter(ps);
            var fakeBoundParameters = new Dictionary <string, string>();

            // Act
            var actual = target.CompleteArgument("Invoke-VSTeamRequest", "area", "", null, fakeBoundParameters);

            // Assert
            Assert.AreEqual(2, actual.Count());
        }
        public void ProcessTemplateCache_GetCurrent()
        {
            // Arrange
            var expected = 5;
            var ps       = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._items);
            ProcessTemplateCache.Cache.Shell = ps;
            ProcessTemplateCache.Invalidate();

            // Act
            var actual = ProcessTemplateCache.GetCurrent();

            // Assert
            Assert.AreEqual(expected, actual.Count());
        }
Beispiel #15
0
        public void BuildCompleter_NoDefaultProject()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._nullDefaultProject);

            var target = new BuildCompleter(ps);
            var fakeBoundParameters = new Dictionary <string, string>();

            // Act
            var actual = target.CompleteArgument("Add-VSTeamRelease", "BuildNumber", "", null, fakeBoundParameters);

            // Assert
            Assert.AreEqual(0, actual.Count());
        }
Beispiel #16
0
        public void QueryCache_Update_With_Null_List()
        {
            // Arrange
            var expected = 2;
            var ps       = BaseTests.PrepPowerShell();

            ps.Invoke().Returns(this._queries);
            ps.Invoke <string>(this._queries).Returns(this._queryNames);
            ps.Invoke <string>().Returns(this._defaultProject, this._queryNames);
            QueryCache.Cache.Shell = ps;

            // Act
            QueryCache.Update(null);

            // Assert
            Assert.AreEqual(expected, QueryCache.Cache.Values.Count);
        }
Beispiel #17
0
        public void BuildCompleter_Build602()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._builds);

            var target = new BuildCompleter(ps);
            var fakeBoundParameters = new Dictionary <string, string>
            {
                { "ProjectName", "UnitTestProject" }
            };

            // Act
            var actual = target.CompleteArgument(null, null, "6", null, fakeBoundParameters);

            // Assert
            Assert.AreEqual(1, actual.Count());
        }
Beispiel #18
0
        public void ReleaseDefinitionCompleter_GetValues()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._releases);

            var target = new ReleaseDefinitionCompleter(ps);
            var fakeBoundParameters = new Dictionary <string, string>
            {
                { "ProjectName", "UnitTestProject" }
            };

            // Act
            var actual = target.CompleteArgument("Add-VSTeamBuild", "BuildDefinition", "", null, fakeBoundParameters);

            // Assert
            Assert.AreEqual(2, actual.Count());
        }
Beispiel #19
0
        public void QueryCache_GetCurrent()
        {
            // Arrange
            var expected = 2;
            var ps       = BaseTests.PrepPowerShell();

            ps.Invoke().Returns(this._queries);
            ps.Invoke <string>(this._queries).Returns(this._queryNames);

            ps.Invoke <string>().Returns(this._defaultProject, this._queryNames);
            QueryCache.Invalidate();
            QueryCache.Cache.Shell = ps;

            // Act
            var actual = QueryCache.GetCurrent();

            // Assert
            Assert.AreEqual(expected, actual.Count());
        }
Beispiel #20
0
        public void QueryCache_Get_Query_ID()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke().Returns(this._queries);
            ps.Invoke <string>().Returns(this._defaultProject, this._queryNames);
            QueryCache.Cache.Shell = ps;

            var expected = "20000000-2000-2000-2000-200000000000";

            // Force an update
            QueryCache.Update(null);

            // Act
            var actual = QueryCache.GetId("My Queries");

            // Assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #21
0
        public void BuildCompleter_NoBuilds()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            // Make the return of Get-VSTeamBuild to return zero builds
            ps.Invoke <string>().Returns(this._empty);

            var target = new BuildCompleter(ps);
            var fakeBoundParameters = new Dictionary <string, string>
            {
                { "ProjectName", "UnitTestProject" }
            };

            // Act
            var actual = target.CompleteArgument(null, null, "", null, fakeBoundParameters);

            // Assert
            Assert.AreEqual(0, actual.Count());
        }
Beispiel #22
0
        public void TimeZoneCompleter_Exercise()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            var target = new TimeZoneCompleter(ps);
            var fakeBoundParameters = new Dictionary <string, string>();

            // Act
            var actual = target.CompleteArgument(string.Empty, string.Empty, "be", null, fakeBoundParameters);

            // Assert
            Assert.AreEqual(_timeZones.Count, actual.Count());
            var e = actual.GetEnumerator();

            foreach (var timeZone in _timeZones)
            {
                e.MoveNext();
                Assert.AreEqual(timeZone.Key, e.Current.CompletionText, timeZone.Key);
                Assert.AreEqual(timeZone.Value, e.Current.ListItemText, timeZone.Value);
            }
        }
Beispiel #23
0
        public void ProjectCompleter_Exercise()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._values);
            ProjectCache.Cache.Shell = ps;
            ProjectCache.Invalidate();

            var target = new ProjectCompleter(ps);
            var fakeBoundParameters = new Dictionary <string, string>();

            // Act
            var actual = target.CompleteArgument(string.Empty, string.Empty, string.Empty, null, fakeBoundParameters);

            // Assert
            Assert.AreEqual(2, actual.Count());
            var e = actual.GetEnumerator();

            e.MoveNext();
            Assert.AreEqual("Project1", e.Current.CompletionText, "Project1");
            e.MoveNext();
            Assert.AreEqual("'Project 2'", e.Current.CompletionText, "Project 2");
        }