Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saintentropy committed Oct 22, 2023
1 parent 62a489d commit 9d9e67c
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/DynamoCoreTests/DSCoreDataTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using Dynamo.Graph.Nodes;
using DynamoUnits;
using Newtonsoft.Json.Linq;
using NUnit.Framework;

Expand Down Expand Up @@ -394,6 +396,50 @@ public void RoundTripForCylinderReturnsSameResult()
AssertPreviewValue("07366adaf0954529b1ed39b240192c96", true);
}

[Test]
[Category("UnitTests")]
public void RoundTripForColorReturnsSameResult()
{
var color = DSCore.Color.ByARGB(25, 30, 35, 40);
var json = DSCore.Data.StringifyJSON(color);
var color2 = (DSCore.Color)DSCore.Data.ParseJSON(json);

Assert.AreEqual(color.Red, color2.Red);
Assert.AreEqual(color.Green, color2.Green);
Assert.AreEqual(color.Blue, color2.Blue);
Assert.AreEqual(color.Alpha, color2.Alpha);
}

[Test]
[Category("UnitTests")]
public void RoundTripForLocationReturnsSameResult()
{
var location = DynamoUnits.Location.ByLatitudeAndLongitude(43.6606, 73.0357, "Dynamo");
var json = DSCore.Data.StringifyJSON(location);
var location2 = (DynamoUnits.Location)DSCore.Data.ParseJSON(json);

Assert.AreEqual(location.Latitude, location2.Latitude);
Assert.AreEqual(location.Longitude, location2.Longitude);
Assert.AreEqual(location.Name, location2.Name);
}

[Test]
[Category("UnitTests")]
public void RoundTripForImageReturnsSameResult()
{
string path = Path.Combine(TestDirectory, @"core\json\TestColor.bmp");
Bitmap bitmap1 = new Bitmap(path);
var json = DSCore.Data.StringifyJSON(bitmap1);
var bitmap2 = (Bitmap)DSCore.Data.ParseJSON(json);

Assert.AreEqual(bitmap1.Width, bitmap2.Width);
Assert.AreEqual(bitmap1.Height, bitmap2.Height);
Assert.AreEqual(bitmap1.GetPixel(5, 5), bitmap2.GetPixel(5, 5));
Assert.AreEqual(bitmap1.GetPixel(195, 5), bitmap2.GetPixel(195, 5));
Assert.AreEqual(bitmap1.GetPixel(195, 95), bitmap2.GetPixel(195, 95));
Assert.AreEqual(bitmap1.GetPixel(5, 95), bitmap2.GetPixel(5, 95));
}

[Test]
[Category("UnitTests")]
public void CanObjectBeCachedRejectsNull()
Expand Down

0 comments on commit 9d9e67c

Please sign in to comment.