public void TestAppendValueConvertToStream()
        {
            var testSize = DicomAttributeBinaryData <T> .TestStreamThresholdInValues;
            var array0   = GenerateValues(testSize);
            var data0    = new DicomAttributeBinaryData <T>(array0, true);

            Assert.IsNotNull(data0.TestGetArray(), "array before switch");
            Assert.IsNull(data0.TestGetStream(), "stream before switch");

            data0.AppendValue(default(T));

            Assert.IsNull(data0.TestGetArray(), "array after switch");
            Assert.IsNotNull(data0.TestGetStream(), "stream after switch");
        }
        public void TestConstructor()
        {
            Assert.AreEqual(0, new DicomAttributeBinaryData <T>().Count, ".ctor(0)");
            Assert.AreEqual(10, new DicomAttributeBinaryData <T>(10).Count, ".ctor(10)");

            var d = new DicomAttributeBinaryData <T>(DicomAttributeBinaryData <T> .TestStreamThresholdInValues);

            Assert.IsNotNull(d.TestGetArray(), "array in .ctor(threshold)");
            Assert.IsNull(d.TestGetStream(), "stream in .ctor(threshold)");

            d = new DicomAttributeBinaryData <T>(DicomAttributeBinaryData <T> .TestStreamThresholdInValues + 1);
            Assert.IsNull(d.TestGetArray(), "array in .ctor(threshold+1)");
            Assert.IsNotNull(d.TestGetStream(), "stream in .ctor(threshold+1)");
        }
        public void TestConstructorCopy2()
        {
            var array0 = GenerateValues(10000);
            var data0  = new DicomAttributeBinaryData <T>(array0, true);

            data0.TestUseStream();

            var data1   = new DicomAttributeBinaryData <T>(data0);
            var buffer1 = data1.TestGetStream().ToArray();
            var array1  = new T[10000];

            Buffer.BlockCopy(buffer1, 0, array1, 0, buffer1.Length);

            Assert.AreEqual(array0, array1, "arrays");
        }
        public void TestConstructorArray()
        {
            var array0 = GenerateValues(100);
            var data0  = new DicomAttributeBinaryData <T>(array0, false);

            Assert.AreSame(array0, data0.TestGetArray(), "no copy");

            data0 = new DicomAttributeBinaryData <T>(array0, true);
            Assert.AreNotSame(array0, data0.TestGetArray(), "copy (reference)");
            Assert.AreEqual(array0, data0.TestGetArray(), "copy (contents)");

            array0 = GenerateValues(DicomAttributeBinaryData <T> .TestStreamThresholdInValues + 1);
            data0  = new DicomAttributeBinaryData <T>(array0, true);
            Assert.IsNull(data0.TestGetArray(), "copy to stream (array)");
            Assert.AreEqual(array0, ConvertToTArray(data0.TestGetStream().ToArray()), "copy to stream (contents)");
        }