public void CheckPathsAreValid_ShouldThrow()
        {
            //Invalid path
            var p = new PathsValidator(new ServiceControlInstanceMetadata {
                InstallPath = @"?>c:\test\1\bin"
            })
            {
                Instances = instances
            };
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckPathsAreValid());

            Assert.That(ex.Message, Is.EqualTo("The install path is set to an invalid path"));

            //Partial path
            p = new PathsValidator(new ServiceControlInstanceMetadata {
                InstallPath = @"\test\1\bin"
            })
            {
                Instances = instances
            };

            ex = Assert.Throws <EngineValidationException>(() => p.CheckPathsAreValid());
            Assert.That(ex.Message, Is.EqualTo("The install path is set to an invalid path"));

            //No Drive
            p = new PathsValidator(new ServiceControlInstanceMetadata {
                InstallPath = $@"{GetAnUnsedDriveLetter()}:\test\1\bin"
            })
            {
                Instances = instances
            };
            ex = Assert.Throws <EngineValidationException>(() => p.CheckPathsAreValid());
            Assert.That(ex.Message, Is.EqualTo("The install path does not go to a supported drive"));
        }
示例#2
0
        public void CheckPathsAreValid_ShouldSucceed()
        {
            var newInstance = new ServiceControlNewInstance
            {
                InstallPath = @"c:\test\1\bin",
                LogPath     = @"c:\test\1\bin",
                DBPath      = @"c:\test\1\bin"
            };

            var p = new PathsValidator(newInstance);

            Assert.DoesNotThrow(() => p.CheckPathsAreValid());
        }
示例#3
0
        public void CheckNoNestedSiblingPaths_ShouldSucceed()
        {
            var newInstance = new ServiceControlNewInstance
            {
                InstallPath = @"c:\test\1\servicecontrol",
                LogPath     = @"c:\test\1\servicecontrollog",
                DBPath      = @"c:\test\1\servicecontroldb"
            };

            var p = new PathsValidator(newInstance);

            Assert.DoesNotThrow(() => p.CheckNoNestedPaths());
        }
        public void ValidateChanges()
        {
            try
            {
                PathsValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                QueueNameValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            var oldSettings    = FindByName(Name);
            var passwordSet    = !string.IsNullOrWhiteSpace(ServiceAccountPwd);
            var accountChanged = !string.Equals(oldSettings.ServiceAccount, ServiceAccount, StringComparison.OrdinalIgnoreCase);

            if (passwordSet || accountChanged)
            {
                try
                {
                    ServiceAccountValidation.Validate(this);
                }
                catch (IdentityNotMappedException)
                {
                    ReportCard.Errors.Add("The service account specified does not exist");
                    return;
                }
                catch (EngineValidationException ex)
                {
                    ReportCard.Errors.Add(ex.Message);
                    return;
                }
            }
            try
            {
                ConnectionStringValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }
        }
示例#5
0
        public void CheckNoNestedPaths_ShouldThrow()
        {
            var newInstance = new ServiceControlNewInstance
            {
                InstallPath = @"c:\test\1",
                LogPath     = @"c:\test\1\log",
                DBPath      = @"c:\test\1\db"
            };

            var p  = new PathsValidator(newInstance);
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckNoNestedPaths());

            Assert.That(ex.Message, Does.Contain("Nested paths are not supported"));
        }
示例#6
0
        public void CheckPathsAreUnique_ShouldThrow()
        {
            var newInstance = new ServiceControlNewInstance
            {
                InstallPath = @"c:\test\1\bin",
                LogPath     = @"c:\test\1\bin",
                DBPath      = @"c:\test\1\bin"
            };

            var p = new PathsValidator(newInstance);

            var ex = Assert.Throws <EngineValidationException>(() => p.CheckPathsAreUnique());

            Assert.That(ex.Message, Is.EqualTo("The installation path, log path and database path must be unique"));
        }
        public void CheckPathsNotUsedInOtherInstances_ShouldSuceed()
        {
            var newInstance = new ServiceControlInstanceMetadata
            {
                InstallPath = @"c:\test\2\bin",
                LogPath     = @"c:\test\2\logs",
                DBPath      = @"c:\test\2\db"
            };

            var p = new PathsValidator(newInstance)
            {
                Instances = instances
            };

            Assert.DoesNotThrow(() => p.CheckPathsNotUsedInOtherInstances());
        }
        public void CheckPathsAreUnique_ShouldSucceed()
        {
            var newInstance = new ServiceControlInstanceMetadata
            {
                InstallPath = @"c:\test\1\bin",
                LogPath     = @"c:\test\1\log",
                DBPath      = @"c:\test\1\db"
            };

            var p = new PathsValidator(newInstance)
            {
                Instances = instances
            };

            Assert.DoesNotThrow(() => p.CheckPathsAreUnique());
        }
        public void CheckPathsNotUsedInOtherInstances_ShouldThrow()
        {
            var newInstance = new ServiceControlInstanceMetadata
            {
                InstallPath = @"c:\test\1\bin",  //This one is bad
                LogPath     = @"c:\test\2\logs",
                DBPath      = @"c:\test\2\db"
            };

            var p = new PathsValidator(newInstance)
            {
                Instances = instances
            };
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckPathsNotUsedInOtherInstances());

            Assert.That(ex.Message, Is.EqualTo("The install path specified is already assigned to another instance"));
        }
        public void Validate(Func <PathInfo, bool> promptToProceed)
        {
            if (TransportPackage.Equals("MSMQ", StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    MSMQConfigValidator.Validate();
                }
                catch (EngineValidationException ex)
                {
                    ReportCard.Errors.Add(ex.Message);
                }
            }

            try
            {
                PortValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                ReportCard.CancelRequested = PathsValidator.Validate(this, promptToProceed);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                QueueNameValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                CheckForConflictingUrlAclReservations();
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                ServiceAccountValidation.Validate(this);
                ConnectionStringValidator.Validate(this);
            }
            catch (IdentityNotMappedException)
            {
                ReportCard.Errors.Add("The service account specified does not exist");
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }
        }