-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from Joelius300/feature/dataset-rework
Dataset rework
- Loading branch information
Showing
63 changed files
with
1,730 additions
and
918 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using ChartJs.Blazor.ChartJS.Common; | ||
using ChartJs.Blazor.ChartJS.LineChart; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Text; | ||
using Xunit; | ||
|
||
namespace ChartJs.Blazor.Tests | ||
{ | ||
public partial class ClippingTests | ||
{ | ||
[Theory] | ||
[InlineData(0)] | ||
[InlineData(-100)] | ||
[InlineData(100)] | ||
[InlineData(int.MinValue)] | ||
[InlineData(int.MaxValue)] | ||
public void Deserialize_AllEdgesEqual_FromRoot(int value) | ||
{ | ||
// Arrange | ||
string json = value.ToString(CultureInfo.InvariantCulture); | ||
Clipping expected = new Clipping(value); | ||
|
||
// Act | ||
Clipping deserialized = JsonConvert.DeserializeObject<Clipping>(json); | ||
|
||
// Assert | ||
Assert.Equal(expected, deserialized); | ||
} | ||
|
||
[Fact] | ||
public void Deserialize_DifferentEdges_FromRoot() | ||
{ | ||
// Arrange | ||
const string json = "{\"Bottom\":0,\"Left\":false,\"Top\":10,\"Right\":-100}"; | ||
Clipping expected = new Clipping(top: 10, right: -100, bottom: 0, left: null); | ||
|
||
// Act | ||
Clipping deserialized = JsonConvert.DeserializeObject<Clipping>(json); | ||
|
||
// Assert | ||
Assert.Equal(expected, deserialized); | ||
} | ||
|
||
[Fact] | ||
public void Deserialize_DifferentEdges_MissingMembers_FromRoot() | ||
{ | ||
// Arrange | ||
const string json = "{\"Top\":-123,\"Right\":false}"; | ||
Clipping expected = new Clipping(top: -123); | ||
|
||
// Act | ||
Clipping deserialized = JsonConvert.DeserializeObject<Clipping>(json); | ||
|
||
// Assert | ||
Assert.Equal(expected, deserialized); | ||
} | ||
|
||
[Fact] | ||
public void Deserialize_DifferentEdges_AdditionalMembers_FromRoot() | ||
{ | ||
// Arrange | ||
const string json = "{\"Left\":500,\"Top\":false,\"ABC\":19.2}"; | ||
Clipping expected = new Clipping(left: 500); | ||
|
||
// Act | ||
Clipping deserialized = JsonConvert.DeserializeObject<Clipping>(json); | ||
|
||
// Assert | ||
Assert.Equal(expected, deserialized); | ||
} | ||
|
||
[Fact] | ||
public void Deserialize_Double_ThrowsJsonReaderException() | ||
{ | ||
// Arrange | ||
const string json = "19.2"; | ||
|
||
// Act & Assert | ||
Assert.Throws<JsonReaderException>(() => JsonConvert.DeserializeObject<Clipping>(json)); | ||
} | ||
|
||
[Fact] | ||
public void Deserialize_Array_ThrowsJsonReaderException() | ||
{ | ||
// Arrange | ||
const string json = "[]"; | ||
|
||
// Act & Assert | ||
Assert.Throws<JsonReaderException>(() => JsonConvert.DeserializeObject<Clipping>(json)); | ||
} | ||
|
||
[Fact] | ||
public void Deserialize_String_ThrowsJsonReaderException() | ||
{ | ||
// Arrange | ||
const string json = "\"asdf\""; | ||
|
||
// Act & Assert | ||
Assert.Throws<JsonReaderException>(() => JsonConvert.DeserializeObject<Clipping>(json)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using ChartJs.Blazor.ChartJS.Common; | ||
using ChartJs.Blazor.ChartJS.LineChart; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xunit; | ||
|
||
namespace ChartJs.Blazor.Tests | ||
{ | ||
public partial class ClippingTests | ||
{ | ||
[Fact] | ||
public void Equals_SameAll_ReturnsTrue() | ||
{ | ||
// Arrange | ||
const int Value = 10; | ||
Clipping a = new Clipping(Value); | ||
Clipping b = new Clipping(Value); | ||
|
||
// Act | ||
bool equals = a.Equals(b); | ||
|
||
// Assert | ||
Assert.True(equals); | ||
} | ||
|
||
[Fact] | ||
public void Equals_AllAndIndividual_ReturnsTrue() | ||
{ | ||
// Arrange | ||
const int Value = -10; | ||
Clipping a = new Clipping(Value); | ||
Clipping b = new Clipping(Value, Value, Value, Value); | ||
|
||
// Act | ||
bool equals = a.Equals(b); | ||
|
||
// Assert | ||
Assert.True(equals); | ||
} | ||
|
||
[Fact] | ||
public void GetHashCode_AllAndIndividual_Equals() | ||
{ | ||
// Arrange | ||
const int Value = 12345; | ||
Clipping a = new Clipping(Value); | ||
Clipping b = new Clipping(Value, Value, Value, Value); | ||
|
||
// Act | ||
int hashA = a.GetHashCode(); | ||
int hashB = b.GetHashCode(); | ||
|
||
// Assert | ||
Assert.Equal(hashA, hashB); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using ChartJs.Blazor.ChartJS.Common; | ||
using ChartJs.Blazor.ChartJS.LineChart; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Text; | ||
using Xunit; | ||
|
||
namespace ChartJs.Blazor.Tests | ||
{ | ||
public partial class ClippingTests | ||
{ | ||
[Theory] | ||
[InlineData(0)] | ||
[InlineData(-100)] | ||
[InlineData(100)] | ||
[InlineData(int.MinValue)] | ||
[InlineData(int.MaxValue)] | ||
public void Serialize_AllEdgesEqual_AsRoot(int value) | ||
{ | ||
// Arrange | ||
string Expected = value.ToString(CultureInfo.InvariantCulture); | ||
Clipping clipping = new Clipping(value); | ||
|
||
// Act | ||
string serialized = JsonConvert.SerializeObject(clipping); | ||
|
||
// Assert | ||
Assert.Equal(Expected, serialized); | ||
} | ||
|
||
[Fact] | ||
public void Serialize_DifferentEdges_AsRoot() | ||
{ | ||
// Arrange | ||
const string Expected = "{\"Top\":0,\"Right\":false,\"Bottom\":10,\"Left\":-100}"; | ||
Clipping clipping = new Clipping(top: 0, right: null, bottom: 10, left: -100); | ||
|
||
// Act | ||
string serialized = JsonConvert.SerializeObject(clipping); | ||
|
||
// Assert | ||
Assert.Equal(Expected, serialized); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.