protected void CheckConnectionString(string connectionString)
        {
            var dbConnection = new DbConnectionStringBuilder {
                ConnectionString = connectionString
            };

            foreach (var setting in StringSettings)
            {
                if (dbConnection.ContainsKey(setting.SettingName))
                {
                    AssertState.Equal(setting.ExpectedValue, dbConnection[setting.SettingName].ToString());
                }
                else
                {
                    throw new AssertionException(string.Format("Connection String setting [{0}] not found", setting.SettingName));
                }
            }

            if (dbConnection.Keys != null)
            {
                AssertState.Equal(StringSettings.Count, dbConnection.Keys.Count);
            }
            else
            {
                throw new AssertionException("No StringSetting values were found");
            }
        }
Esempio n. 2
0
        public override void Run()
        {
            var clientSection = (ClientSection)GetConfig().GetSection("system.serviceModel/client");

            var endpoints = clientSection.Endpoints;
            var endpoint  = endpoints.OfType <ChannelEndpointElement>().FirstOrDefault(e => e.Name == EndpointName);

            if (endpoint == null)
            {
                throw new AssertionException(string.Format("Could not find Endpoint with name [{0}]", EndpointName));
            }

            AssertState.Equal(ExpectedAddress, endpoint.Address.ToString(), "Address is incorrect");
            AssertState.Equal(ExpectedBehaviourConfiguration, endpoint.BehaviorConfiguration, "BehaviourConfiguration is incorrect");
            AssertState.Equal(ExpectedBinding, endpoint.Binding, "Binding is incorrect");
            AssertState.Equal(ExpectedBindingConfiguration, endpoint.BindingConfiguration, "BindingConfiguration is incorrect");
            AssertState.Equal(ExpectedContract, endpoint.Contract, "Contract is incorrect");
            AssertState.Equal(ExpectedEndpointConfiguration, endpoint.EndpointConfiguration, "EndpointConfiguration is incorrect");

            if (CheckConnectivity.GetValueOrDefault())
            {
                var request = WebRequest.Create(ExpectedAddress);
                request.Timeout = (ConnectionTimeout ?? 10) * 1000;
                var webResponse = (HttpWebResponse)request.GetResponse();
                AssertState.Equal(HttpStatusCode.OK, webResponse.StatusCode, "While attempting to check connectivity");
            }
        }
Esempio n. 3
0
        private void ValidateAppSetting(AppSettingsSection appSettings, string appSettingName, bool isOptional = false)
        {
            var appSettingIncludingConnectionStringName = string.Format("{0}{1}", ConnectionStringName, appSettingName);

            var setting = appSettings.Settings[appSettingIncludingConnectionStringName];

            if (setting == null)
            {
                throw new AssertionException(String.Format("AppSetting {0} not found in config", appSettingIncludingConnectionStringName));
            }

            if (isOptional)
            {
                return;
            }

            var appSettingFound = AppSettings.Find(a => a.SettingName == appSettingIncludingConnectionStringName);

            if (appSettingFound == null)
            {
                throw new AssertionException(String.Format("AppSetting {0} not found in test", appSettingIncludingConnectionStringName));
            }

            AssertState.Equal(setting.Value, appSettingFound.ExpectedValue);
        }
        public override void Run()
        {
            var startInfo = new ProcessStartInfo(Executable)
            {
                Arguments = Parameters
            };

            startInfo.CreateNoWindow         = true;
            startInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            startInfo.UseShellExecute        = false;
            startInfo.ErrorDialog            = false;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardInput  = true;

            var process = Process.Start(startInfo);

            if (process == null)
            {
                throw new InvalidOperationException("Process Could not Execute in <CallExecutableCheckReturnCodeTest>");
            }

            process.WaitForExit();

            var output = process.StandardOutput.ReadToEnd();

            AssertState.Equal(true, output.Contains(OutputContainsText));
        }
Esempio n. 5
0
        public override void Run()
        {
            var servicesSection = (ServicesSection)GetConfig().GetSection("system.serviceModel/services");

            var services = servicesSection.Services;

            if (services.Count == 0)
            {
                throw new AssertionException("No services section could be found.");
            }

            BaseAddressElement baseAddress = null;

            foreach (ServiceElement se in services.OfType <ServiceElement>().Where(se => se.Name == ServiceName))
            {
                var baseAddressElements = se.Host.BaseAddresses.OfType <BaseAddressElement>();
                baseAddress = baseAddressElements.FirstOrDefault(e => e.BaseAddress == ExpectedBaseAddressValue);
                AssertState.NotNull(baseAddress, "Base address is incorrect or not present");
            }

            if (baseAddress == null)
            {
                throw new AssertionException(string.Format("Could not find Base address with name {0}", ServiceName));
            }
        }
Esempio n. 6
0
        public override void Run()
        {
            var servicesSection = (ServicesSection)GetConfig().GetSection("system.serviceModel/services");
            var services        = servicesSection.Services;

            if (services.Count == 0)
            {
                throw new AssertionException("No services section could be found.");
            }

            var serviceWasFound = false;

            foreach (ServiceElement se in services.Cast <ServiceElement>().Where(se => se.Name == ServiceName))
            {
                serviceWasFound = true;

                Func <ServiceEndpointElement, bool> predicate;

                if (string.IsNullOrWhiteSpace(EndpointName))
                {
                    predicate = a => _addressMatchPredicate(a, ExpectedAddress);
                }
                else
                {
                    predicate = a => _nameMatchPredicate(a, EndpointName);
                }

                var endpoint = se.Endpoints.OfType <ServiceEndpointElement>().FirstOrDefault(predicate);

                if (endpoint == null)
                {
                    throw new AssertionException(string.Format("Could not find an Endpoint for Service [{0}] with the specified properties", ServiceName));
                }

                AssertState.Equal(ExpectedAddress, endpoint.Address.ToString(), "Address is incorrect");
                AssertState.Equal(ExpectedBehaviourConfiguration, endpoint.BehaviorConfiguration, "BehaviourConfiguration is incorrect");
                AssertState.Equal(ExpectedBinding, endpoint.Binding, "Binding is incorrect");
                AssertState.Equal(ExpectedBindingConfiguration, endpoint.BindingConfiguration, "BindingConfiguration is incorrect");
                AssertState.Equal(ExpectedContract, endpoint.Contract, "Contract is incorrect");
                AssertState.Equal(ExpectedEndpointConfiguration, endpoint.EndpointConfiguration, "EndpointConfiguration is incorrect");
            }

            if (!serviceWasFound)
            {
                throw new AssertionException(string.Format("No Service found with Name [{0}]", ServiceName));
            }

            if (CheckConnectivity.GetValueOrDefault())
            {
                var request = WebRequest.Create(ExpectedAddress);
                request.Timeout = (ConnectionTimeout ?? 10) * 1000;
                var webResponse = (HttpWebResponse)request.GetResponse();
                AssertState.Equal(HttpStatusCode.OK, webResponse.StatusCode, "While attempting to check connectivity");

                request.Abort();
            }
        }
Esempio n. 7
0
 public override void Run()
 {
     using (var md5 = MD5.Create())
     {
         using (var stream = File.OpenRead(Filename))
         {
             var actualChecksum = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", String.Empty).ToLower();
             AssertState.Equal(Checksum.ToLower(), actualChecksum);
         }
     }
 }
Esempio n. 8
0
        public override void Run()
        {
            var ctl = ServiceController.GetServices().FirstOrDefault(s => s.ServiceName == "W3SVC");

            if (ctl == null)
            {
                throw new AssertionException(@"IIS is not installed.");
            }

            AssertState.Equal(ServiceStatus, ctl.Status);
        }
Esempio n. 9
0
        public override void Run()
        {
            using (var stream = File.OpenRead(Filename))
            {
                var sha          = new SHA1Managed();
                var checksum     = sha.ComputeHash(stream);
                var fileChecksum = BitConverter.ToString(checksum).Replace("-", string.Empty).ToLower();

                AssertState.Equal(Checksum.ToLower(), fileChecksum);
            }
        }
        public override void Run()
        {
            var ctl = ServiceController.GetServices().FirstOrDefault(s => s.ServiceName == ServiceName);

            if (ctl == null)
            {
                throw new AssertionException(string.Format("Service with name [{0}] was not found", ServiceName));
            }

            AssertState.Equal(ServiceStatus, ctl.Status);
        }
Esempio n. 11
0
        public override void Run()
        {
            var             httpRequest = WebRequest.Create(UrlToTest);
            HttpWebResponse httpResponse;

            try
            {
                httpResponse = (HttpWebResponse)httpRequest.GetResponse();
            }
            catch (WebException ex)
            {
                httpResponse = (HttpWebResponse)ex.Response;
            }

            AssertState.Equal(ExpectedResponse.ToString(), httpResponse.StatusCode.ToString(), false, String.Format("The Http response was {0}. The Expected response is {1}", httpResponse.StatusCode, ExpectedResponse));
        }
        public override void Run()
        {
            var missingFile = false;
            var files       = _fileList.Split(';');

            foreach (var file in files)
            {
                if (string.IsNullOrEmpty(file))
                {
                    continue;
                }

                if (!File.Exists(FullFilePath(file)))
                {
                    missingFile = true;
                }
            }

            AssertState.Equal(false, missingFile, @"There was a file missing from the file list check.");
        }
Esempio n. 13
0
        public override void Run()
        {
            foreach (var entry in ExpectedEntries)
            {
                object actual   = GetValue(entry.ValueName);
                object expected = entry.ExpectedValue;

                switch (entry.ValueType)
                {
                case  RegistryValueType.REG_BINARY:
                    break;

                case RegistryValueType.REG_DWORD:
                case RegistryValueType.REG_DWORD_BIG_ENDIAN:
                case RegistryValueType.REG_DWORD_LITTLE_ENDIAN:
                    actual   = Convert.ToInt32(actual);
                    expected = Convert.ToInt32(entry.ExpectedValue);
                    break;

                case RegistryValueType.REG_SZ:
                case RegistryValueType.REG_EXPAND_SZ:
                    actual   = Convert.ToString(actual);
                    expected = Convert.ToString(entry.ExpectedValue);
                    break;

                case RegistryValueType.REG_MULTI_SZ:
                    actual   = Convert.ToInt32(actual);
                    expected = Convert.ToInt32(entry.ExpectedValue, 16);
                    break;

                case RegistryValueType.REG_QWORD:
                case RegistryValueType.REG_QWORD_LITTLE_ENDIAN:
                    actual   = Convert.ToInt32(actual);
                    expected = Convert.ToInt64(entry.ExpectedValue, 16);
                    break;
                }

                AssertState.Equal(expected.ToString(), actual.ToString());
            }
        }
Esempio n. 14
0
        public override void Run()
        {
            Assembly assembly;

            try
            {
                assembly = Assembly.LoadFrom(AssemblyPath);
            }
            catch (FileNotFoundException)
            {
                throw new AssertionException(string.Format("File Not Found: {0}", AssemblyPath));
            }

            var classType = assembly.GetTypes().FirstOrDefault(t => t.Name == ClassName);

            if (classType == null)
            {
                throw new AssertionException(string.Format("Class Not Found: {0}", ClassName));
            }

            if (!classType.IsSubclassOf(typeof(ApplicationSettingsBase)))
            {
                throw new AssertionException(string.Format("Class Does Not Implement ApplicationSettingsBase: {0}",
                                                           ClassName));
            }

            var propertyInfo = classType.GetProperty(SettingName);

            if (propertyInfo == null)
            {
                throw new AssertionException(string.Format("Setting Not Found: {0}", SettingName));
            }

            var instance = Activator.CreateInstance(classType);
            var value    = propertyInfo.GetValue(instance, null);

            AssertState.Equal(ExpectedValue, value.ToString());
        }
Esempio n. 15
0
        public override void Run()
        {
            var startInfo = new ProcessStartInfo(Executable)
            {
                Arguments = Parameters
            };

            startInfo.CreateNoWindow  = true;
            startInfo.WindowStyle     = ProcessWindowStyle.Hidden;
            startInfo.UseShellExecute = false;
            startInfo.ErrorDialog     = false;

            var process = Process.Start(startInfo);

            if (process == null)
            {
                throw new InvalidOperationException("Process Could not Execute in <CallExecutableCheckReturnCodeTest>");
            }

            process.WaitForExit();

            AssertState.Equal(ReturnCode, process.ExitCode);
        }
Esempio n. 16
0
 public override void Run()
 {
     AssertState.Equal(Version, GetAssemblyVersion());
 }
Esempio n. 17
0
 public override void Run()
 {
     AssertState.Equal(ShouldExist, DoesWebsiteExist(ServerName, WebsiteName), string.Format("The website {0} is {1}present on {2}", WebsiteName, ShouldExist.IfTrue("not "), ServerName));
 }
Esempio n. 18
0
 public override void Run()
 {
     AssertState.Equal(ShouldExist, File.Exists(FullFilePath), string.Format("File was {0}present", ShouldExist.IfTrue("not ")));
 }
 public override void Run()
 {
     AssertState.Equal(ShouldExist, IsQueueAvailable(_queueName), string.Format("MSMQ local queue {0} is {1}present", _queueName, ShouldExist.IfTrue("not ")));
 }
        public override void Run()
        {
            var soapRequest = new StringBuilder();

            soapRequest.Append("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
            soapRequest.Append("<s:Body>");
            soapRequest.Append(SoapRequestBody);
            soapRequest.Append("</s:Body>");
            soapRequest.Append("</s:Envelope>");

            var encodedSoapRequest = new UTF8Encoding();
            var bytesToWrite       = encodedSoapRequest.GetBytes(soapRequest.ToString());

            var webRequest = (HttpWebRequest)HttpWebRequest.Create(ServiceAddress);

            webRequest.Timeout       = (ConnectionTimeout ?? 10) * 1000;
            webRequest.Method        = !string.IsNullOrWhiteSpace(Method) ? Method : DEFAULT_METHOD;
            webRequest.ContentLength = bytesToWrite.Length;
            webRequest.ContentType   = !string.IsNullOrWhiteSpace(ContentType) ? ContentType : DEFAULT_CONTENT_TYPE;
            webRequest.Headers.Add("SOAPAction", SoapRequestAction);

            using (var newStream = webRequest.GetRequestStream())
            {
                newStream.Write(bytesToWrite, 0, bytesToWrite.Length);
                newStream.Close();
            }

            var response   = (HttpWebResponse)webRequest.GetResponse();
            var dataStream = response.GetResponseStream();
            var reader     = new StreamReader(dataStream);

            var soapResponse = new StringBuilder();

            soapResponse.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            soapResponse.Append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
            soapResponse.Append("<soap:Body>");
            soapResponse.Append(ExpectedSoapResponseBody);
            soapResponse.Append("</soap:Body>");
            soapResponse.Append("</soap:Envelope>");

            var expectedSoapResponse = new XmlDocument();

            expectedSoapResponse.LoadXml(soapResponse.ToString());

            if (!string.IsNullOrWhiteSpace(XPathNodesToBeRemoved))
            {
                var namespaceManager = new XmlNamespaceManager(expectedSoapResponse.NameTable);
                namespaceManager.AddNamespace("response", DefaultNamespace);

                var root            = expectedSoapResponse.DocumentElement;
                var nodeToBeRemoved = root.SelectSingleNode(XPathNodesToBeRemoved, namespaceManager);
                nodeToBeRemoved.ParentNode.RemoveChild(nodeToBeRemoved);
            }

            var actualSoapResponse = new XmlDocument();
            var responseFromServer = reader.ReadToEnd();

            actualSoapResponse.LoadXml(responseFromServer);

            if (!string.IsNullOrWhiteSpace(XPathNodesToBeRemoved))
            {
                var namespaceManager = new XmlNamespaceManager(actualSoapResponse.NameTable);
                namespaceManager.AddNamespace("response", DefaultNamespace);

                var root            = actualSoapResponse.DocumentElement;
                var nodeToBeRemoved = root.SelectSingleNode(XPathNodesToBeRemoved, namespaceManager);
                nodeToBeRemoved.ParentNode.RemoveChild(nodeToBeRemoved);
            }

            AssertState.Equal(expectedSoapResponse.OuterXml, actualSoapResponse.OuterXml, "While attempting to get a soap response");
            webRequest.Abort();
        }
Esempio n. 21
0
        public override void Run()
        {
            var soapRequest = new StringBuilder();

            soapRequest.Append("<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://www.w3.org/2005/08/addressing\">");
            soapRequest.Append("<s:Header>");
            soapRequest.Append(string.Concat("<a:Action s:mustUnderstand=\"1\">", SoapRequestAction, "</a:Action>"));
            soapRequest.Append("<a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>");
            soapRequest.Append(string.Concat("<a:To s:mustUnderstand=\"1\">", ServiceAddress, "</a:To>"));
            soapRequest.Append("</s:Header>");
            soapRequest.Append("<s:Body>");
            soapRequest.Append(SoapRequestBody);
            soapRequest.Append("</s:Body>");
            soapRequest.Append("</s:Envelope>");

            var encodedSoapRequest = new UTF8Encoding();
            var bytesToWrite       = encodedSoapRequest.GetBytes(soapRequest.ToString());

            var webRequest = (HttpWebRequest)HttpWebRequest.Create(ServiceAddress);

            webRequest.Timeout       = (ConnectionTimeout ?? 10) * 1000;
            webRequest.Method        = !string.IsNullOrWhiteSpace(Method) ? Method : DEFAULT_METHOD;
            webRequest.ContentLength = bytesToWrite.Length;
            webRequest.ContentType   = !string.IsNullOrWhiteSpace(ContentType) ? ContentType : DEFAULT_CONTENT_TYPE;

            using (var newStream = webRequest.GetRequestStream())
            {
                newStream.Write(bytesToWrite, 0, bytesToWrite.Length);
                newStream.Close();
            }

            var response   = (HttpWebResponse)webRequest.GetResponse();
            var dataStream = response.GetResponseStream();
            var reader     = new StreamReader(dataStream);

            var soapResponse = new StringBuilder();

            soapResponse.Append("<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://www.w3.org/2005/08/addressing\">");
            soapResponse.Append("<s:Header>");
            soapResponse.Append(string.Concat("<a:Action s:mustUnderstand=\"1\">", ExpectedSoapResponseAction, "</a:Action>"));
            soapResponse.Append("</s:Header>");
            soapResponse.Append("<s:Body>");
            soapResponse.Append(ExpectedSoapResponseBody);
            soapResponse.Append("</s:Body>");
            soapResponse.Append("</s:Envelope>");

            var expectedSoapResponse = new XmlDocument();

            expectedSoapResponse.LoadXml(soapResponse.ToString());

            if (!string.IsNullOrWhiteSpace(XPathNodesToBeRemoved))
            {
                var namespaceManager = new XmlNamespaceManager(expectedSoapResponse.NameTable);
                namespaceManager.AddNamespace("response", DefaultNamespace);

                var root            = expectedSoapResponse.DocumentElement;
                var nodeToBeRemoved = root.SelectSingleNode(XPathNodesToBeRemoved, namespaceManager);
                nodeToBeRemoved.ParentNode.RemoveChild(nodeToBeRemoved);
            }

            var actualSoapResponse = new XmlDocument();
            var responseFromServer = reader.ReadToEnd();

            actualSoapResponse.LoadXml(responseFromServer);

            if (!string.IsNullOrWhiteSpace(XPathNodesToBeRemoved))
            {
                var namespaceManager = new XmlNamespaceManager(actualSoapResponse.NameTable);
                namespaceManager.AddNamespace("response", DefaultNamespace);

                var root            = actualSoapResponse.DocumentElement;
                var nodeToBeRemoved = root.SelectSingleNode(XPathNodesToBeRemoved, namespaceManager);
                nodeToBeRemoved.ParentNode.RemoveChild(nodeToBeRemoved);
            }

            AssertState.Equal(expectedSoapResponse.OuterXml, actualSoapResponse.OuterXml, "While attempting to get a soap response");
            webRequest.Abort();
        }
Esempio n. 22
0
 public override void Run()
 {
     AssertState.Equal(ExpectedValue, GetSettingElement(), CaseSensitive);
 }
Esempio n. 23
0
 public override void Run()
 {
     AssertState.Equal(ShouldExist, DoesMsmqExist(), string.Format("MSMQ is {0}present", ShouldExist.IfTrue("not ")));
 }
Esempio n. 24
0
        public override void Run()
        {
            var result = WasSuccessful(PingHost(HostName));

            AssertState.Equal(ShouldExist, result, string.Format("Host is {0}contactable.", ShouldExist.IfTrue("not ")));
        }
 public override void Run()
 {
     AssertState.Equal(true, DoesUserExist());
 }
Esempio n. 26
0
 public override void Run()
 {
     AssertState.Equal(Version, GetIisVersion().ToString());
 }
 public override void Run()
 {
     AssertState.Equal(ExpectedValue, Environment.GetEnvironmentVariable(Variable));
 }