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

fix: test model names to be PascalCase #42

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 8 additions & 8 deletions ButterCMS.Tests/ListPagesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,43 @@ public void ListPages_ShouldReturnPages()

butterClient.MockSuccessfullPagesResponse(parameters: dict);

var response = butterClient.ListPages<things>(PagesMocks.PageType, dict);
var response = butterClient.ListPages<Things>(PagesMocks.PageType, dict);
var page = response.Data.First();
Assert.AreEqual(page.Name, PagesMocks.Page.Name);
Assert.AreEqual(page.Slug, PagesMocks.Page.Slug);
Assert.AreEqual(page.Updated, PagesMocks.Page.Updated);
Assert.AreEqual(page.PageType, PagesMocks.Page.PageType);
Assert.AreEqual(page.Fields.thing1, PagesMocks.Fields.thing1);
Assert.AreEqual(page.Fields.thing2, PagesMocks.Fields.thing2);
Assert.AreEqual(page.Fields.Thing1, PagesMocks.Fields.Thing1);
Assert.AreEqual(page.Fields.Thing2, PagesMocks.Fields.Thing2);
}

[Test]
public async Task ListPagesAsync_ShouldReturnPages()
{
butterClient.MockSuccessfullPagesResponse();

var response = await butterClient.ListPagesAsync<things>(PagesMocks.PageType);
var response = await butterClient.ListPagesAsync<Things>(PagesMocks.PageType);

var page = response.Data.First();
Assert.AreEqual(page.Name, PagesMocks.Page.Name);
Assert.AreEqual(page.Slug, PagesMocks.Page.Slug);
Assert.AreEqual(page.Updated, PagesMocks.Page.Updated);
Assert.AreEqual(page.PageType, PagesMocks.Page.PageType);
Assert.AreEqual(page.Fields.thing1, PagesMocks.Fields.thing1);
Assert.AreEqual(page.Fields.thing2, PagesMocks.Fields.thing2);
Assert.AreEqual(page.Fields.Thing1, PagesMocks.Fields.Thing1);
Assert.AreEqual(page.Fields.Thing2, PagesMocks.Fields.Thing2);
}

[Test]
public void ListPages_NoResults_ShouldReturnNull()
{
var response = butterClient.ListPages<things>("nothings");
var response = butterClient.ListPages<Things>("nothings");
Assert.IsNull(response);
}

[Test]
public async Task ListPagesAsync_NoResults_ShouldReturnNull()
{
var response = await butterClient.ListPagesAsync<things>("nothings");
var response = await butterClient.ListPagesAsync<Things>("nothings");
Assert.IsNull(response);
}
}
Expand Down
16 changes: 8 additions & 8 deletions ButterCMS.Tests/Mocks/ContentFieldsMocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ public static class ContentFieldsMocks
{
Data = new TeamMembersHeadline()
{
homepage_headline = "ButterCMS C# SDK",
team_members = new[]
HomepageHeadline = "ButterCMS C# SDK",
TeamMembers = new[]
{
new Team_Members()
new TeamMembers()
{
name = "Elon",
bio = "CEO"
Name = "Elon",
Bio = "CEO"
},
new Team_Members()
new TeamMembers()
{
name = "Steve",
bio = "CTO"
Name = "Steve",
Bio = "CTO"
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions ButterCMS.Tests/Mocks/PagesMocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ namespace ButterCMS.Tests
{
public static class PagesMocks
{
public static things Fields = new things() { thing1 = "Bike", thing2 = "MTB" };
public static Things Fields = new Things() { Thing1 = "Bike", Thing2 = "MTB" };

public const string PageType = "BikeList";

public static Page<things> Page = new Page<things>()
public static Page<Things> Page = new Page<Things>()
{
Name = "Bike page",
Slug = "bikes",
Expand All @@ -22,7 +22,7 @@ public static class PagesMocks
Fields = Fields
};

public static PagesResponse<things> PagesResponse = new PagesResponse<things>()
public static PagesResponse<Things> PagesResponse = new PagesResponse<Things>()
{
Data = new[] { Page },
Meta = new PageMeta()
Expand All @@ -33,7 +33,7 @@ public static class PagesMocks
}
};

public static PageResponse<things> PageResponse = new PageResponse<things>()
public static PageResponse<Things> PageResponse = new PageResponse<Things>()
{
Data = Page,
};
Expand All @@ -52,7 +52,7 @@ public static void MockSuccessfullPageResponse(this ButterCMSClientWithMockedHtt

public static void MockSuccessfullNullPageResponse(this ButterCMSClientWithMockedHttp butterClient, string slug, string pageType = PageType)
{
butterClient.MockSuccessfullJSONResponse($"https://api.buttercms.com/v2/pages/{pageType}/{slug}/?auth_token={ButterCMSClientWithMockedHttp.MockedApiKey}", new PageResponse<things>() { Data = null });
butterClient.MockSuccessfullJSONResponse($"https://api.buttercms.com/v2/pages/{pageType}/{slug}/?auth_token={ButterCMSClientWithMockedHttp.MockedApiKey}", new PageResponse<Things>() { Data = null });
}
}
}
12 changes: 6 additions & 6 deletions ButterCMS.Tests/Models/RecipePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{
public class RecipePage
{
public string category { get; set; }
public string recipe_name { get; set; }
public string main_ingredient { get; set; }
public double estimated_cooking_time_in_minutes { get; set; }
public string ingredient_list { get; set; }
public string instructions { get; set; }
public string Category { get; set; }
public string RecipeName { get; set; }
public string MainIngredient { get; set; }
public double EstimatedCookingTimeInMinutes { get; set; }
public string IngredientList { get; set; }
public string Instructions { get; set; }
}
}
15 changes: 9 additions & 6 deletions ButterCMS.Tests/Models/TeamMembersHeadline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace ButterCMS.Tests.Models
{
public class TeamMembersHeadline
{
public Team_Members[] team_members { get; set; }
public string homepage_headline { get; set; }
[JsonProperty("team_members")]
public TeamMembers[] TeamMembers { get; set; }
[JsonProperty("homepage_headline")]
public string HomepageHeadline { get; set; }
}

public class Team_Members
public class TeamMembers
{
public string bio { get; set; }
public string picture { get; set; }
public string name { get; set; }
public string Bio { get; set; }
public string Picture { get; set; }
public string Name { get; set; }
}

}
6 changes: 3 additions & 3 deletions ButterCMS.Tests/Models/things.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

namespace ButterCMS.Tests.Models
{
public class things
public class Things
{
public string thing1 { get; set; }
public string thing2 { get; set; }
public string Thing1 { get; set; }
public string Thing2 { get; set; }
}

}
24 changes: 12 additions & 12 deletions ButterCMS.Tests/ReadmePageTypeExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public void ReadmeExample_ListPages()
foreach (Page<RecipePage> recipe in recipePages.Data)
{
RecipeViewModel recipeViewModel = new RecipeViewModel();
recipeViewModel.Category = recipe.Fields.category;
recipeViewModel.RecipeName = recipe.Fields.recipe_name;
recipeViewModel.MainIngredient = recipe.Fields.main_ingredient;
recipeViewModel.EstimatedCookingTimeInMinutes = recipe.Fields.estimated_cooking_time_in_minutes;
recipeViewModel.IngredientList = recipe.Fields.ingredient_list;
recipeViewModel.Instructions = recipe.Fields.instructions;
recipeViewModel.Category = recipe.Fields.Category;
recipeViewModel.RecipeName = recipe.Fields.RecipeName;
recipeViewModel.MainIngredient = recipe.Fields.MainIngredient;
recipeViewModel.EstimatedCookingTimeInMinutes = recipe.Fields.EstimatedCookingTimeInMinutes;
recipeViewModel.IngredientList = recipe.Fields.IngredientList;
recipeViewModel.Instructions = recipe.Fields.Instructions;

viewModel.Recipes.Add(recipeViewModel);
}
Expand All @@ -64,12 +64,12 @@ public void ReadmeExample_RetrievePage()
PageResponse<RecipePage> recipe = butterClient.RetrievePage<RecipePage>("recipe", slug);

var viewModel = new RecipeViewModel();
viewModel.Category = recipe.Data.Fields.category;
viewModel.RecipeName = recipe.Data.Fields.recipe_name;
viewModel.MainIngredient = recipe.Data.Fields.main_ingredient;
viewModel.EstimatedCookingTimeInMinutes = recipe.Data.Fields.estimated_cooking_time_in_minutes;
viewModel.IngredientList = recipe.Data.Fields.ingredient_list;
viewModel.Instructions = recipe.Data.Fields.instructions;
viewModel.Category = recipe.Data.Fields.Category;
viewModel.RecipeName = recipe.Data.Fields.RecipeName;
viewModel.MainIngredient = recipe.Data.Fields.MainIngredient;
viewModel.EstimatedCookingTimeInMinutes = recipe.Data.Fields.EstimatedCookingTimeInMinutes;
viewModel.IngredientList = recipe.Data.Fields.IngredientList;
viewModel.Instructions = recipe.Data.Fields.Instructions;
viewModel.Updated = recipe.Data.Updated;
viewModel.Published = recipe.Data.Published;

Expand Down
4 changes: 2 additions & 2 deletions ButterCMS.Tests/RetrieveContentFieldsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ private void AssertContentFieldJSON(string json, TeamMembersHeadline expected)
return;
}

Assert.AreEqual(expected.homepage_headline, teamMembersAndHeadline.homepage_headline);
Assert.AreEqual(expected.team_members[0].bio, teamMembersAndHeadline.team_members[0].bio);
Assert.AreEqual(expected.HomepageHeadline, teamMembersAndHeadline.HomepageHeadline);
Assert.AreEqual(expected.TeamMembers[0].Bio, teamMembersAndHeadline.TeamMembers[0].Bio);
}

[Test]
Expand Down
12 changes: 6 additions & 6 deletions ButterCMS.Tests/RetrievePageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ public void RetrievePage_ShouldReturnPage()
{
butterClient.MockSuccessfullPageResponse(PagesMocks.Page.Slug);

var response = butterClient.RetrievePage<things>(PagesMocks.Page.PageType, PagesMocks.Page.Slug);
var response = butterClient.RetrievePage<Things>(PagesMocks.Page.PageType, PagesMocks.Page.Slug);
Assert.IsNotNull(response);

var page = response.Data;
Assert.AreEqual(PagesMocks.Page.Name, page.Name);
Assert.AreEqual(PagesMocks.Page.Slug, page.Slug);
Assert.AreEqual(PagesMocks.Page.Updated, page.Updated);
Assert.AreEqual(PagesMocks.Page.Fields.thing1, page.Fields.thing1);
Assert.AreEqual(PagesMocks.Page.Fields.Thing1, page.Fields.Thing1);
}

[Test]
public async Task RetrievePageAsync_ShouldReturnPage()
{
butterClient.MockSuccessfullPageResponse(PagesMocks.Page.Slug);

var response = await butterClient.RetrievePageAsync<things>(PagesMocks.Page.PageType, PagesMocks.Page.Slug);
var response = await butterClient.RetrievePageAsync<Things>(PagesMocks.Page.PageType, PagesMocks.Page.Slug);
Assert.IsNotNull(response);

var page = response.Data;
Assert.AreEqual(PagesMocks.Page.Name, page.Name);
Assert.AreEqual(PagesMocks.Page.Slug, page.Slug);
Assert.AreEqual(PagesMocks.Page.Updated, page.Updated);
Assert.AreEqual(PagesMocks.Page.Fields.thing1, page.Fields.thing1);
Assert.AreEqual(PagesMocks.Page.Fields.Thing1, page.Fields.Thing1);
}

[Test]
Expand All @@ -55,7 +55,7 @@ public void RetrievePage_NoResults_ShouldReturnNull()

butterClient.MockSuccessfullNullPageResponse(slug);

var response = butterClient.RetrievePage<things>(slug, slug);
var response = butterClient.RetrievePage<Things>(slug, slug);
Assert.IsNull(response);
}

Expand All @@ -66,7 +66,7 @@ public async Task RetrievePageAsync_NoResults_ShouldReturnNull()

butterClient.MockSuccessfullNullPageResponse(slug);

var response = await butterClient.RetrievePageAsync<things>(slug, slug);
var response = await butterClient.RetrievePageAsync<Things>(slug, slug);
Assert.IsNull(response);
}
}
Expand Down