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

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

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

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

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

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

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

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

            // Assert
        }
Пример #4
0
        public void ProjectCache_GetCurrent()
        {
            // Arrange
            var expected = 2;
            var ps       = BaseTests.PrepPowerShell();

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

            // Act
            var actual = ProjectCache.GetCurrent(false);

            // Assert
            Assert.AreEqual(expected, actual.Count());
        }
Пример #5
0
        public void ProjectCache_HasCacheExpired()
        {
            // Arrange
            var expected = true;

            // Act
            ProjectCache.Invalidate();

            // Assert
            Assert.AreEqual(expected, ProjectCache.HasCacheExpired, "Cache should be expired");

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

            // Assert
            Assert.AreNotEqual(expected, ProjectCache.HasCacheExpired, "Cache should not be expired");
        }
Пример #6
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");
        }
Пример #7
0
 /// <summary>
 /// This is called by unit testing framework and other constructors
 /// </summary>
 /// <param name="name"></param>
 /// <param name="powerShell"></param>
 public Account(string name, IPowerShell powerShell) :
     base(name, "Project", powerShell)
 {
     // Invalidate any cache of projects
     ProjectCache.Invalidate();
 }