Skip to content

Comments

Add a few more tests for JsonWriter and YamlWriter#40

Merged
PerthCharern merged 5 commits intomasterfrom
PerthCharern/ImproveUnitTests
Oct 30, 2017
Merged

Add a few more tests for JsonWriter and YamlWriter#40
PerthCharern merged 5 commits intomasterfrom
PerthCharern/ImproveUnitTests

Conversation

@PerthCharern
Copy link
Contributor

  • Add a few more tests for JsonWriter and YamlWriter
  • The YamlWriter itself still has quite a few bugs. I'm working on that and will send out a separate PR.


public OpenApiJsonWriterTests(ITestOutputHelper output)
{
_output = output;
Copy link
Contributor

@xuzhg xuzhg Oct 26, 2017

Choose a reason for hiding this comment

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

remember to remove the console output #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm always conflicted with this. Every time you need to debug a unit test, it's impossible to do without console output. But then people don't want console output in the test because it's not clean :(

I think we should leave the constructor here at least, so that when someone needs to debug something, they don't need to start from scratch. I'll remove the calls _output.WriteLine().


[Theory]
[MemberData(nameof(WriteListData))]
public void WriteList(string[] stringValues)
Copy link
Contributor

@xuzhg xuzhg Oct 26, 2017

Choose a reason for hiding this comment

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

make the test case function name more meaningful? #Resolved


using System;

namespace Microsoft.OpenApi
Copy link
Contributor

@xuzhg xuzhg Oct 27, 2017

Choose a reason for hiding this comment

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

why do you think to push such extension in the Core lib? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking this could be useful for serialization. But maybe I was wrong, I'll put it in the Unit Tests for now.

}

protected void ValifyCanWritePropertyName(string name)
protected void VerifyCanWritePropertyName(string name)
Copy link
Contributor

@xuzhg xuzhg Oct 27, 2017

Choose a reason for hiding this comment

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

👍 #Resolved

</ItemGroup>
<ItemGroup>
<Compile Include="ExampleTests.cs" />
<Compile Include="OpenApiJsonWriterTests.cs" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Put the test C# files into the corresponding sub folders?

- Move string extensions to unit test project
- remove console output from unit test
@PerthCharern PerthCharern mentioned this pull request Oct 27, 2017
@PerthCharern
Copy link
Contributor Author

@xuzhg I addressed your comments above. Feel free to let me know if there's anything else.

@xuzhg
Copy link
Contributor

xuzhg commented Oct 27, 2017

Others look good to me. :shipit:

@xuzhg
Copy link
Contributor

xuzhg commented Oct 27, 2017

@PerthCharern please use "Rebase and Merge" button to merge. Then we can have the straight line history.

@PerthCharern
Copy link
Contributor Author

@xuzhg I'm not a big fan of rebase and merge. The small commits are not complete on its own and it's difficult to figure out "one change" once we do rebase and merge. I can do it for this one but we should have a discussion on the policy on which kind of merge is allowed at some point. This is lower priority though, so we can do it whenever we have down time.

@PerthCharern
Copy link
Contributor Author

@xuzhg Actually, if you don't mind, I won't do rebase and merge for this PR, since github is complaining that there are conflicts when I do rebase and merge, but NOT when I do normal merge. I don't want to spend time on git technology at this point. There's a potential we might have to clean up history before release anyway (I think...).

@PerthCharern PerthCharern merged commit f67eab8 into master Oct 30, 2017
@xuzhg
Copy link
Contributor

xuzhg commented Oct 30, 2017

@PerthCharern Got it.

@xuzhg
Copy link
Contributor

xuzhg commented Oct 30, 2017

@PerthCharern It seems you removed a if (!IsTopLevelObjectScope()) in the OpenApiYamlWriter.cs.

I don't think we should always add a "new line" for the top level property. Right?

@PerthCharern
Copy link
Contributor Author

YamlWriter has a lot of issues. I need to look at the PR to recall the exact reason, but that check was causing some inconsistencies. I'll get back to you.

@PerthCharern
Copy link
Contributor Author

@xuzhg Technically, YAML can have --- to indicate the starting point of the document. This means that you'll need to have the first newline before the first property as I see in most docs here: http://www.yaml.org/spec/1.2/spec.html

Even without ---, I don't think adding a newline is wrong.

Always adding newline for property seems more consistent to me in that regard. Unless of course, you think this violates the YAML spec.

@xuzhg
Copy link
Contributor

xuzhg commented Oct 30, 2017

No, I don't mean it's wrong or violate the spec.
I mean to add a "newline" at the start of document looks useless.

@darrelmiller what's your opinion?

@PerthCharern
Copy link
Contributor Author

@xuzhg Yeah, I understand your point. I don't mind either way. The aesthetics depends on whether we want to have --- at the beginning of the YAML doc.

@xuzhg
Copy link
Contributor

xuzhg commented Oct 30, 2017

Let me file an issue to track on this issue.

@xuzhg
Copy link
Contributor

xuzhg commented Oct 30, 2017

Oh, we have it: #39. Let's use it.

@PerthCharern PerthCharern deleted the PerthCharern/ImproveUnitTests branch November 3, 2017 00:34
baywet added a commit that referenced this pull request Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants