public void AssertAttributeValue_should_not_throw_when_value_matches() { var tester = new XmlTester(FormattedXmlWithAppSetting("testKey", "testValue")); AssertExceptionNotThrown .WhenExecuting(() => tester.AssertAttributeValue(ConfigXPath.AppSettingForKey("testKey"), "value", "testValue")); }
public void GetAttributeValue_should_return_value_when_attribute_exists() { var tester = new XmlTester(FormattedXmlWithAppSetting("testKey", "testValue")); XElement elem = tester.GetElement(ConfigXPath.AppSettingForKey("testKey")); Assert.AreEqual("testValue", tester.GetAttributeValue(elem, "value")); }
public void GetAttributeValue_should_return_null_when_attribute_does_not_exist() { var tester = new XmlTester(FormattedXmlWithAppSetting("testKey", "actualValue")); XElement elem = tester.GetElement(ConfigXPath.AppSettingForKey("testKey")); Assert.IsNull(tester.GetAttributeValue(elem, "badAttributeName")); }
public void GetElement_should_return_element_when_it_exists() { var tester = new XmlTester(FormattedXmlWithAppSetting("testKey", "actualValue")); XElement elem = tester.GetElement(ConfigXPath.AppSettingForKey("testKey")); Assert.IsNotNull(elem); }
public void GetElement_should_return_null_when_element_does_not_exist() { var tester = new XmlTester(FormattedXml()); XElement elem = tester.GetElement(ConfigXPath.AppSettingForKey("testKey")); Assert.IsNull(elem); }
public void AssertAttributeValue_should_throw_exception_when_value_does_not_match() { var tester = new XmlTester(FormattedXmlWithAppSetting("testKey", "actualValue")); AssertExceptionThrown .OfType <XmlTesterException>() .WithMessageContaining("configuration/appSettings/add[@key='testKey']@value:" + " Expected: <expectedValue> actual: <actualValue>") .WhenExecuting(() => tester.AssertAttributeValue(ConfigXPath.AppSettingForKey("testKey"), "value", "expectedValue")); }
public void Exceptions_should_use_exceptionPrefix_when_supplied() { var tester = new XmlTester(FormattedXmlWithAppSetting("testKey", "actualValue"), "EXCEPTION_PREFIX: "); AssertExceptionThrown .OfType <XmlTesterException>() .WithMessage("EXCEPTION_PREFIX: Element found, but attribute does not exist: " + "configuration/appSettings/add[@key='testKey']@badAttribute") .WhenExecuting(() => tester.AssertAttributeValue(ConfigXPath.AppSettingForKey("testKey"), "badAttribute", "value")); }
public void AssertAttributeValueIsWellFormedUrl_should_not_throw_exeption_when_value_is_valid_URL() { var tester = new XmlTester(FormattedXml( "<system.serviceModel><client>" + "<endpoint address=\"http://www.somewhere.com/something/service.svc\" name=\"testName\" />" + "</client></system.serviceModel>")); AssertExceptionNotThrown.WhenExecuting(() => tester.AssertAttributeValueIsWellFormedUrl( ConfigXPath.ClientEndpointForName("testName"), "address")); }
public void AssertAttributeValueMatch_should_throw_exception_when_attribute_does_not_exist() { var tester = new XmlTester(FormattedXmlWithAppSetting("testKey", "actualValue")); AssertExceptionThrown .OfType <XmlTesterException>() .WithMessage("Element found, but attribute does not exist: " + "configuration/appSettings/add[@key='testKey']@badAttribute") .WhenExecuting(() => tester.AssertAttributeValueMatch(ConfigXPath.AppSettingForKey("testKey"), "badAttribute", "value")); }
public void AssertAttributeValueIsWellFormedUrl_should_throw_exeption_when_value_is_not_valid_URL() { var tester = new XmlTester(FormattedXml( "<system.serviceModel><client>" + "<endpoint address=\"bad URL\" name=\"testName\" />" + "</client></system.serviceModel>")); AssertExceptionThrown .OfType <XmlTesterException>() .WithMessage("configuration/system.serviceModel/client/endpoint[@name='testName']@address:" + " Value \"bad URL\" is not a well-formed URI string.") .WhenExecuting(() => tester.AssertAttributeValueIsWellFormedUrl( ConfigXPath.ClientEndpointForName("testName"), "address")); }
public void AssertAttributeValues_should_not_throw_exception_when_values_match() { string appSettingsXml = FormattedAppSettingsSection( "<add key=\"testKey\" value=\"testValue\" value2=\"testValue2\" value3=\"testValue3\" />"); var tester = new XmlTester(FormattedXml(appSettingsXml)); AssertExceptionNotThrown.WhenExecuting(() => tester.AssertAttributeValues( ConfigXPath.AppSettingForKey("testKey"), new Dictionary <string, string> { { "value", "testValue" }, { "value2", "testValue2" }, { "value3", "testValue3" } })); }
public void AssertAttributeValues_should_throw_exception_when_values_do_not_match() { string appSettingsXml = FormattedAppSettingsSection( "<add key=\"testKey\" value=\"testValue\" value2=\"testValue2X\" value3=\"testValue3\" />"); var tester = new XmlTester(FormattedXml(appSettingsXml)); AssertExceptionThrown .OfType <ScenarioTestFailureException>() .WithMessageContaining("@value2: Expected: <testValue2> actual: <testValue2X>") .WhenExecuting(() => tester.AssertAttributeValues( ConfigXPath.AppSettingForKey("testKey"), new Dictionary <string, string> { { "value", "testValue" }, { "value2", "testValue2" }, { "value3", "testValue3" } })); }
public void ClientEndpointForName_should_return_expected_value() { Assert.AreEqual( "configuration/system.serviceModel/client/endpoint[@name='testEndpoint']", ConfigXPath.ClientEndpointForName("testEndpoint")); }
public void AppSettingForKey_should_return_expected_value() { Assert.AreEqual( "configuration/appSettings/add[@key='specifiedKey']", ConfigXPath.AppSettingForKey("specifiedKey")); }