internal void TestDicomDecimalStringGetArray <T>() { var expected = new[] { 35.0m, 45.0m, 55.0m }; var element = new DicomDecimalString(DicomTag.MaterialThickness, expected); var actual = element.Get <T[]>(); Assert.Equal(expected.Select(i => (T)Convert.ChangeType(i, Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T))), actual); }
public void DicomDecimalString_HasData_GetNullableReturnsDefinedNullable() { const int expected = -30; var element = new DicomDecimalString(DicomTag.ChannelOffset, expected); var actual = element.Get <int?>().Value; Assert.Equal(expected, actual); }
internal void TestDicomDecimalStringGetItem <T>() { var expected = 45.0m; var element = new DicomDecimalString(DicomTag.MaterialThickness, 35.0m, expected, 55.0m); var actual = element.Get <T>(1); Assert.Equal((T)Convert.ChangeType(expected, Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T)), actual); }
public void DicomDecimalString_WorksInCommaCulture() { var currentCulture = Thread.CurrentThread.CurrentCulture; try { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("de-DE"); var decimals = new[] { 0.1m, 1e10m, -1m, 0, 3.141592656m }; var element = new DicomDecimalString(DicomTag.CumulativeMetersetWeight, decimals); Assert.Equal(decimals, element.Get <decimal[]>()); Assert.Equal(decimals.Select(x => (double)x), element.Get <double[]>()); } finally { Thread.CurrentThread.CurrentCulture = currentCulture; } }