Skip to content
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

Add some tests of Swagger.ObjectModel #128

Merged
merged 5 commits into from
Oct 12, 2017
Merged

Conversation

catcherwong
Copy link
Contributor

After reading the #127 , I use my spare time to begin this task .

But based on existing test code , I can not clearly know the code style this project wants to have !

So I choose Swagger.ObjectModel as my first step and do some tests .

And these tests need you review and suggestion whether the test code fit this project.

For this PR , what I have done are as following

  • Modify the empty check of ToCamelCase method
  • Add tests for ToCamelCase method
  • Add tests for BodyParameterBuilder class
  • Add tests for ContactBuilder class
  • Add tests for ExternalDocumentationBuilder class
  • Add tests for HeaderBuilder class

@jnallard
Copy link
Collaborator

Hm. I need to work on the build. It seems Nancy.Swagger.Annotations hasn't been pushed to NuGet in a while. But the build didn't claim to fail. (Unrelated to your PR, but just posting because I noticed it on yours. But I'll also need to make sure the build fails if the test fails.)

}

[Fact]
public void Should_ThrowRequiredFieldException_WhenUrlIsNullOrEmpty()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, the tests are not all following the same format. But could you follow one of the current ones?
https://github.com/catcherwong/Nancy.Swagger/blob/ae38a293c225ff29d3bf6ada755847316c705e69/test/Nancy.Swagger.Tests/SwaggerModelDataBuilderTests.cs
The naming bothers me with the underscores.

Copy link
Owner

Choose a reason for hiding this comment

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

Oh really? I'm actually usually a fan of using _ to separate sentences like that:
[Should|ShouldNot][DoThisThing][When|If|ThisThing]

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just feel like the keywords are helpful enough.

I'm fine either way though - I mostly brought it up because there was the precedent not to use them. Maybe rename the existing functions then?

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 find some Open Source projectss use this style for their tests , such as NancyFx . I use _ to separate for both of my own projects as well , so what I did is just follow this style .

@jnallard
Copy link
Collaborator

This is a good start for tests though! I'll approve once the function names are changed.
Maybe @yahehe might have more feedback.

Don't worry about the build issue - I'll make a new issue for that.

@@ -5,9 +5,14 @@ namespace Swagger.ObjectModel
{
public static class Utilities
{
/// <summary>
/// convert a string to camelcase with special rules.
/// </summary>
Copy link
Owner

Choose a reason for hiding this comment

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

Not a fan of redundant comments usually

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All right , this comment needs to be remove !

[Fact]
public void Should_AbleToSetNameAndSchema()
{
// Arrange
Copy link
Owner

@yahehe yahehe Oct 10, 2017

Choose a reason for hiding this comment

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

Unnecessary comments
EDIT: I see now that you probably added these comments to be more in line with the tests that already exist. Don't follow that pattern, I'll clean those up

private readonly BodyParameterBuilder builder;
private readonly string name;
private readonly Schema schema;
public BodyParameterBuilderTest()
Copy link
Owner

Choose a reason for hiding this comment

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

Missing a line break here

@yahehe
Copy link
Owner

yahehe commented Oct 10, 2017

These look pretty good to me aside from the very minor things I've pointed out. Thanks for contributing!

@yahehe
Copy link
Owner

yahehe commented Oct 10, 2017

Holding off on merging until jnallard and I sync up on the test name thing

@catcherwong
Copy link
Contributor Author

@yahehe I think Swagger.ObjectModel is more easier to begin the tasks and consider somethings need to be unified . so I choose it for the beginning !

@jnallard
Copy link
Collaborator

Spoke to @yahehe and we agreed that you could use the underscores for the test names.
Just clean up those comments (there's a typo in one, but Ciaran said to remove it anyways) and add that new line and I'll merge.

@catcherwong
Copy link
Contributor Author

@jnallard OK , I will make revisions accordingly which are based on your reviews ! Thank you !

@jnallard jnallard merged commit e9057d5 into yahehe:master Oct 12, 2017
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.

3 participants