Skip to content

Commit

Permalink
Exposed accessible flag on categories
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Aug 23, 2019
1 parent ee5492f commit 2355d3e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 7 additions & 1 deletion SeatsioDotNet.Test/Charts/CreateChartTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void Categories()
var chart = Client.Charts.Create(null, null, new[]
{
new Category(1, "Category 1", "#aaaaaa"),
new Category(2, "Category 2", "#bbbbbb"),
new Category(2, "Category 2", "#bbbbbb", true),
new Category("cat-3", "Category 3", "#cccccc")
});

Expand All @@ -68,13 +68,19 @@ public void Categories()
Assert.Equal("Untitled chart", retrievedChart.Name);
var drawing = Client.Charts.RetrievePublishedVersion(chart.Key);
var actualCategories = drawing.Categories;

Assert.Equal(3, actualCategories.Count);

Assert.Equal(1L, actualCategories[0].Key);
Assert.Equal("Category 1", actualCategories[0].Label);
Assert.Equal("#aaaaaa", actualCategories[0].Color);
Assert.False(actualCategories[0].Accessible);

Assert.Equal(2L, actualCategories[1].Key);
Assert.Equal("Category 2", actualCategories[1].Label);
Assert.Equal("#bbbbbb", actualCategories[1].Color);
Assert.True(actualCategories[1].Accessible);

Assert.Equal("cat-3", actualCategories[2].Key);
}
}
Expand Down
2 changes: 1 addition & 1 deletion SeatsioDotNet.Test/Charts/UpdateChartTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Categories()
{
var chart = Client.Charts.Create("aChart", "BOOTHS");

Client.Charts.Update(chart.Key, categories: new[] {new Category(1, "Category 1", "#aaaaaa"), new Category("cat-2", "Category 2", "#bbbbbb")});
Client.Charts.Update(chart.Key, categories: new[] {new Category(1, "Category 1", "#aaaaaa"), new Category("cat-2", "Category 2", "#bbbbbb", true)});

Chart retrievedChart = Client.Charts.Retrieve(chart.Key);
Assert.Equal("aChart", retrievedChart.Name);
Expand Down
12 changes: 10 additions & 2 deletions SeatsioDotNet/Charts/Category.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@ public class Category
public object Key { get; set; }
public string Label { get; set; }
public string Color { get; set; }
public bool? Accessible { get; set; }

public Category()
{
}

public Category(int key, string label, string color)
public Category(int key, string label, string color, bool? accessible = false)
{
Key = key;
Label = label;
Color = color;
Accessible = accessible;
}

public Category(string key, string label, string color)
public Category(string key, string label, string color, bool? accessible = false)
{
Key = key;
Label = label;
Color = color;
Accessible = accessible;
}

public Dictionary<string, object> AsDictionary()
Expand All @@ -43,6 +46,11 @@ public Dictionary<string, object> AsDictionary()
if (Color != null)
{
dictionary.Add("color", Color);
}

if (Accessible != null)
{
dictionary.Add("accessible", Accessible);
}

return dictionary;
Expand Down

0 comments on commit 2355d3e

Please sign in to comment.