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

[WIP] Unit test and fix for #195, "Help Center CreateSection API endpoint not correct, cannot create new sections." #216

Merged
merged 2 commits into from
Apr 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/Tests/HelpCenter/SectionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using NUnit.Framework;
using ZendeskApi_v2;
using ZendeskApi_v2.Models.Sections;
using ZendeskApi_v2.Requests.HelpCenter;

namespace Tests.HelpCenter
{
[TestFixture]
[Category( "HelpCenter" )]
class SectionTests
{
private ZendeskApi api = new ZendeskApi( Settings.Site, Settings.Email, Settings.Password );

[Test]

public void CanGetSections()
{
var res = api.HelpCenter.Sections.GetSections();
Assert.Greater( res.Count, 0 );

var res1 = api.HelpCenter.Sections.GetSectionById( res.Sections[ 0 ].Id.Value );
Assert.AreEqual( res1.Section.Id, res.Sections[ 0 ].Id.Value );
}

[Test]
public void CanCreateUpdateAndDeleteSections()
{
//https://csharpapi.zendesk.com/hc/en-us/categories/200382245-Category-1
long category_id = 200382245;

var res = api.HelpCenter.Sections.CreateSection( new Section()
{
Name = "My Test section",
CategoryId = category_id
} );
Assert.Greater( res.Section.Id, 0 );

res.Section.Description = "updated description";
var update = api.HelpCenter.Sections.UpdateSection( res.Section );
Assert.AreEqual( update.Section.Description, res.Section.Description );

Assert.True( api.HelpCenter.Sections.DeleteSection( res.Section.Id.Value ) );
}
}
}
1 change: 1 addition & 0 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="HelpCenter\SectionTests.cs" />
<Compile Include="HelpCenter\VoteTests.cs" />
<Compile Include="HelpCenter\CommentTests.cs" />
<Compile Include="HelpCenter\ArticleTests.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/ZendeskApi_v2/Requests/HelpCenter/Sections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public IndividualSectionResponse GetSectionById(long id)
public IndividualSectionResponse CreateSection(Section section)
{
var body = new { section };
return GenericPost<IndividualSectionResponse>(string.Format("help_center/sections.json"), body);
return GenericPost<IndividualSectionResponse>(string.Format( "help_center/categories/{0}/sections.json", section.CategoryId ), body);
}

public IndividualSectionResponse UpdateSection(Section section)
Expand Down