public void AssertTagValueChanged(uint tag, string valueToSet, string originalCharacterSet, string expectedNewCharacterSet)
        {
            DicomAttributeCollection dataset = new DicomAttributeCollection();

            SetupDataSet(dataset, originalCharacterSet);
            DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset);

            Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString());

            SetTagCommand cmd = new SetTagCommand(tag, valueToSet);

            Assert.AreEqual(cmd.CanSaveInUnicode, UnicodeAllowed, "SetTagCommand.CanSaveInUnicode returns an incorrect value");

            Assert.IsTrue(cmd.Apply(file), "SetTagCommand.Apply failed");

            var filename = string.Format("Test-{0}.dcm", DicomTagDictionary.GetDicomTag(tag).Name);

            Assert.IsTrue(file.Save(filename), "Unable to save dicom file");
            file = new DicomFile(filename);
            file.Load();

            if (valueToSet == null)
            {
                Assert.AreEqual(string.Empty, file.DataSet[tag].ToString());
            }
            else
            {
                Assert.AreEqual(valueToSet, file.DataSet[tag].ToString());
            }

            Assert.IsTrue(file.DataSet[DicomTags.SpecificCharacterSet].ToString().Equals(expectedNewCharacterSet));

            Delete(filename);
        }
예제 #2
0
        public void AssertTagValueChanged(uint tag, string valueToSet, string originalCharacterSet, string expectedNewCharacterSet)
        {
            DicomAttributeCollection dataset = new DicomAttributeCollection();
            SetupDataSet(dataset, originalCharacterSet);
            DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset);

            Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString());

            SetTagCommand cmd = new SetTagCommand(tag, valueToSet);

            Assert.AreEqual(cmd.CanSaveInUnicode, UnicodeAllowed, "SetTagCommand.CanSaveInUnicode returns an incorrect value");
            
            Assert.IsTrue(cmd.Apply(file), "SetTagCommand.Apply failed");

            var filename = string.Format("Test-{0}.dcm", DicomTagDictionary.GetDicomTag(tag).Name);
            Assert.IsTrue(file.Save(filename), "Unable to save dicom file");
            file = new DicomFile(filename);
            file.Load();

            if (valueToSet == null)
                Assert.AreEqual(string.Empty, file.DataSet[tag].ToString());
            else
                Assert.AreEqual(valueToSet, file.DataSet[tag].ToString());

            Assert.IsTrue(file.DataSet[DicomTags.SpecificCharacterSet].ToString().Equals(expectedNewCharacterSet));

            Delete(filename);

        }
        public void AssertExceptionThrown(uint tag, string valueToSet, string originalCharacterSet)
        {
            DicomAttributeCollection dataset = new DicomAttributeCollection();

            SetupDataSet(dataset, originalCharacterSet);
            DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset);

            Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString());

            SetTagCommand cmd = new SetTagCommand(tag, valueToSet);

            try
            {
                cmd.Apply(file);
                Assert.Fail("DicomCharacterSetException is expected");
            }
            catch (DicomCharacterSetException)
            {
                // good
                return;
            }
            catch (Exception)
            {
                Assert.Fail("DicomCharacterSetException is expected");
            }
        }
예제 #4
0
        public void AssertExceptionThrown(uint tag, string valueToSet, string originalCharacterSet)
        {
            DicomAttributeCollection dataset = new DicomAttributeCollection();

            SetupDataSet(dataset, originalCharacterSet);
            DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset);

            Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString());

            var sq = new OriginalAttributesSequence
            {
                ModifiedAttributesSequence        = new DicomSequenceItem(),
                ModifyingSystem                   = ProductInformation.Component,
                ReasonForTheAttributeModification = "CORRECT",
                AttributeModificationDatetime     = Platform.Time,
                SourceOfPreviousValues            = file.SourceApplicationEntityTitle
            };

            SetTagCommand cmd = new SetTagCommand(tag, valueToSet);

            try
            {
                cmd.Apply(file, sq);
                Assert.Fail("DicomCharacterSetException is expected");
            }
            catch (DicomCharacterSetException)
            {
                // good
                return;
            }
            catch (Exception)
            {
                Assert.Fail("DicomCharacterSetException is expected");
            }
        }
예제 #5
0
        public void AssertTagValueChanged(uint tag, string valueToSet, string originalCharacterSet, string expectedNewCharacterSet)
        {
            DicomAttributeCollection dataset = new DicomAttributeCollection();

            SetupDataSet(dataset, originalCharacterSet);
            DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset);

            Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString());

            SetTagCommand cmd = new SetTagCommand(tag, valueToSet);

            Assert.AreEqual(cmd.CanSaveInUnicode, UnicodeAllowed, "SetTagCommand.CanSaveInUnicode returns an incorrect value");

            var sq = new OriginalAttributesSequence
            {
                ModifiedAttributesSequence        = new DicomSequenceItem(),
                ModifyingSystem                   = ProductInformation.Component,
                ReasonForTheAttributeModification = "CORRECT",
                AttributeModificationDatetime     = Platform.Time,
                SourceOfPreviousValues            = file.SourceApplicationEntityTitle
            };

            Assert.IsTrue(cmd.Apply(file, sq), "SetTagCommand.Apply failed");

            var filename = string.Format("Test-{0}.dcm", DicomTagDictionary.GetDicomTag(tag).Name);

            Assert.IsTrue(file.Save(filename), "Unable to save dicom file");
            file = new DicomFile(filename);
            file.Load();

            if (valueToSet == null)
            {
                Assert.AreEqual(string.Empty, file.DataSet[tag].ToString());
            }
            else
            {
                Assert.AreEqual(valueToSet, file.DataSet[tag].ToString());
            }

            Assert.IsTrue(file.DataSet[DicomTags.SpecificCharacterSet].ToString().Equals(expectedNewCharacterSet));

            Delete(filename);
        }
예제 #6
0
        public void AssertExceptionThrown(uint tag, string valueToSet, string originalCharacterSet)
        {
            DicomAttributeCollection dataset = new DicomAttributeCollection();
            SetupDataSet(dataset, originalCharacterSet);
            DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset);

            Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString());

            SetTagCommand cmd = new SetTagCommand(tag, valueToSet);
            try
            {
                cmd.Apply(file);
                Assert.Fail("DicomCharacterSetException is expected");
            }
            catch(DicomCharacterSetException)
            {
                // good
                return;
            }
            catch(Exception)
            {
                Assert.Fail("DicomCharacterSetException is expected");
            }
        }
예제 #7
0
        public void AssertTagValueChanged(uint tag, string valueToSet, string originalCharacterSet, string expectedNewCharacterSet)
        {
            DicomAttributeCollection dataset = new DicomAttributeCollection();
            SetupDataSet(dataset, originalCharacterSet);
            DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset);

            Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString());

            SetTagCommand cmd = new SetTagCommand(tag, valueToSet);

            Assert.AreEqual(cmd.CanSaveInUnicode, UnicodeAllowed, "SetTagCommand.CanSaveInUnicode returns an incorrect value");

			var sq = new OriginalAttributesSequence
			{
				ModifiedAttributesSequence = new DicomSequenceItem(),
				ModifyingSystem = ProductInformation.Component,
				ReasonForTheAttributeModification = "CORRECT",
				AttributeModificationDatetime = Platform.Time,
				SourceOfPreviousValues = file.SourceApplicationEntityTitle
			};

            Assert.IsTrue(cmd.Apply(file, sq), "SetTagCommand.Apply failed");

            var filename = string.Format("Test-{0}.dcm", DicomTagDictionary.GetDicomTag(tag).Name);
            Assert.IsTrue(file.Save(filename), "Unable to save dicom file");
            file = new DicomFile(filename);
            file.Load();

            if (valueToSet == null)
                Assert.AreEqual(string.Empty, file.DataSet[tag].ToString());
            else
                Assert.AreEqual(valueToSet, file.DataSet[tag].ToString());

            Assert.IsTrue(file.DataSet[DicomTags.SpecificCharacterSet].ToString().Equals(expectedNewCharacterSet));

            Delete(filename);

        }
예제 #8
0
        public void AssertExceptionThrown(uint tag, string valueToSet, string originalCharacterSet)
        {
            DicomAttributeCollection dataset = new DicomAttributeCollection();
            SetupDataSet(dataset, originalCharacterSet);
            DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset);

            Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString());
			
			var sq = new OriginalAttributesSequence
			{
				ModifiedAttributesSequence = new DicomSequenceItem(),
				ModifyingSystem = ProductInformation.Component,
				ReasonForTheAttributeModification = "CORRECT",
				AttributeModificationDatetime = Platform.Time,
				SourceOfPreviousValues = file.SourceApplicationEntityTitle
			};

            SetTagCommand cmd = new SetTagCommand(tag, valueToSet);
            try
            {
                cmd.Apply(file, sq);
                Assert.Fail("DicomCharacterSetException is expected");
            }
            catch(DicomCharacterSetException)
            {
                // good
                return;
            }
            catch(Exception)
            {
                Assert.Fail("DicomCharacterSetException is expected");
            }
        }