public void given_command_data_expect_data_type_conversion() { var mockData = new MockCommandData() { Data = 178.90, DataType = typeof(double).AssemblyQualifiedName }; Assert.AreEqual(178.90, mockData.DataAs <double>()); }
public void given_command_data_expect_data_type_presence_after_serialization() { var mockData = new MockCommandData() { Data = 178.90, DataType = typeof(double).AssemblyQualifiedName }; var serial = mockData.SerializeToJson(); var mockDataDeserial = serial.DeserializeJson <InternalMockCommandData>(); Assert.AreEqual(178.90, mockDataDeserial.DataAs <double>()); }
public void given_command_data_expect_data_type_of_noncore_type() { var mockData = new MockCommandData() { Data = new { propertyOne = 10, propertyTwo = "test" }, DataType = "geojson" }; var serial = mockData.SerializeToJson(); var mockDataDeserial = serial.DeserializeJson <InternalMockCommandData>(); Assert.AreEqual("geojson", mockDataDeserial.DataType); Assert.AreEqual(10, ((dynamic)mockDataDeserial.Data).propertyOne); Assert.AreEqual("test", ((dynamic)mockDataDeserial.Data).propertyTwo); }