Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Adding Unit Tests for XmlFormatters with DeclaredType as object. #1143

Closed
wants to merge 3 commits into from

Conversation

sornaks
Copy link

@sornaks sornaks commented Sep 16, 2014

Issue #1072


[Theory]
[MemberData(nameof(BasicTypeValues))]
public async Task XmlDataContractSerializerOutputFormatterCanWriteBasicTypes(object input, string expectedOutput)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test CanWriteResult and GetSupportedContentTypes as well as WriteAsync

@yishaigalatzer
Copy link
Contributor

When @rynowak is happy

@sornaks
Copy link
Author

sornaks commented Sep 19, 2014

Updated..


// Act
var resultArray = formatter.GetSupportedContentTypes(
typeof(DummyClass), typeof(DummyClass), MediaTypeHeaderValue.Parse("application/xml")).AsArray();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't test the difference between declaredType and runtimeType, which is what this bug is about

@rynowak
Copy link
Member

rynowak commented Sep 19, 2014

Discussed with Sorna in person, he's also going to add tests for #1081 to this PR

@sornaks
Copy link
Author

sornaks commented Sep 19, 2014

Updated.. I separated the #1081 PR..

// Assert
if (expectedOutput != null)
{
Assert.Equal(expectedOutput, (result.AsArray())[0].RawValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert.Equal(expectedOutput, Assert.Single(result).RawValue);

much clearer and validates something else that you care about

@rynowak
Copy link
Member

rynowak commented Sep 22, 2014

cleanup asserts and then :shipit:

@sornaks
Copy link
Author

sornaks commented Sep 22, 2014

Done. Thanks Ryan! Checked in - 96318dc

@sornaks sornaks closed this Sep 22, 2014
@sornaks sornaks deleted the XmlUnitTests branch September 23, 2014 23:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants