-
Notifications
You must be signed in to change notification settings - Fork 25
Fixed feature test for XmlAttributeProperties.GetXmlNamespaceMaps and XmlAttributeProperties.SetXmlNamespaceMaps #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c302ed3
b370102
b4118bb
0f0a6b5
8755e20
0a4ce28
02bc665
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -958,4 +958,3 @@ private void DumpRequest(WebRequest request) | |
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
using System.Windows.Threading; | ||
using Microsoft.Test.Serialization; | ||
using System.Windows.Media; | ||
using Microsoft.Test.Logging; | ||
using Microsoft.Test.Discovery; | ||
using Microsoft.Test.Xaml.Utilities; | ||
|
||
|
@@ -210,36 +211,60 @@ public void VerifyXmlAttributeProperties() | |
// GetXmlNamespaceMaps(DependencyObject dependencyObject) | ||
// SetXmlNamespaceMaps(DependencyObject dependencyObject, string value) | ||
// | ||
// NOTE: These methods are broken and won't be fixed. We're just calling | ||
// them to keep them off the radar. The exception verification will | ||
// alert us if the implementation is ever fixed. | ||
// | ||
Exception ex = null; | ||
|
||
try | ||
{ | ||
//commenting this for now - api got updated and for making it work we need to update tests as well | ||
//PR has been raised already, once reviewed, this code will be updated | ||
//XmlAttributeProperties.SetXmlNamespaceMaps(dobj, "foo"); | ||
//Pass null to both dependencyObject and value in SetXmlNamespaceMaps, this will throw exception | ||
XmlAttributeProperties.SetXmlNamespaceMaps(null, null); | ||
|
||
} | ||
catch (Exception e) | ||
{ | ||
ex = e; | ||
GlobalLog.LogStatus("Exception is expected. Exception in SetXmlNamespaceMaps : " + e.ToString()); | ||
} | ||
if (ex == null) throw new Microsoft.Test.TestValidationException("FAILED"); | ||
|
||
ex = null; | ||
|
||
try | ||
{ | ||
XmlAttributeProperties.GetXmlNamespaceMaps(dobj); | ||
//Pass null to dependencyObject in GetXmlNamespaceMaps, this will throw exception | ||
XmlAttributeProperties.GetXmlNamespaceMaps(null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here as well I think we should have a test case where we test whether we can get the correct value from the namespace maps or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please refer the code snippet from line 237 to 262. |
||
} | ||
catch (Exception e) | ||
{ | ||
ex = e; | ||
GlobalLog.LogStatus("Exception is expected. Exception in GetXmlNamespaceMaps : " + e.ToString()); | ||
} | ||
|
||
//Pass value in SetXmlNamespaceMaps, then verify if the value is set correctly by GetXmlNamespaceMaps | ||
|
||
DependencyObject dObj = new DependencyObject(); | ||
Hashtable hashTable = new Hashtable(); | ||
var hashTableKey = "dummyKey"; | ||
var hashTableValue = "dummyValue"; | ||
hashTable.Add(hashTableKey, hashTableValue); | ||
XmlAttributeProperties.SetXmlNamespaceMaps(dObj, hashTable); | ||
var xmlNamespaceMapsValue = XmlAttributeProperties.GetXmlNamespaceMaps(dObj); | ||
|
||
if (xmlNamespaceMapsValue.GetType() == typeof(Hashtable)) | ||
{ | ||
foreach (DictionaryEntry entry in xmlNamespaceMapsValue) | ||
{ | ||
_IsStringEqual(entry.Key.ToString(), hashTableKey); | ||
if (entry.Value != null) | ||
{ | ||
_IsStringEqual(entry.Value.ToString(), hashTableValue); | ||
} | ||
else | ||
{ | ||
throw new Microsoft.Test.TestValidationException("Value is unexpected. Expected:" + hashTableValue + ", Actual:null"); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
throw new Microsoft.Test.TestValidationException("Value is unexpected. Expected:" + typeof(Hashtable) + ", Actual:" + xmlNamespaceMapsValue.GetType()); | ||
} | ||
|
||
if (ex == null) throw new Microsoft.Test.TestValidationException("FAILED"); | ||
} | ||
// Checks that 2 string values are equalivalent. | ||
|
||
// Checks that 2 string values are equivalent. | ||
private static void _IsStringEqual(string expected, string actual) | ||
{ | ||
if (actual == null) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we are testing whether
SetXmlNamespaceMaps
throws exception when setting null instead of testing if we can set the namespace maps with a correct value.I am not aware if we have such a test case already. If not, I think we should add one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are testing for null value just to see if it results in exception or not because
SetXmlNamespaceMaps
will throw exception in that scenario.However for the correct value test we are checking that as well, please refer the code snippet from line 237 to 262.