public void Initialize()
 {
     _compare = new CompareObjects();
     _compare.MaxDifferences = 1000;
     _serializer             = new Serializer();
 }
        // Case 1628: 1.1.05.05_Call getGenericInstanceInfo to check the Dicom_Info for dicom instance
        public void Run_GenericInstance_GetInfoForDICOM_Case1628()
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    string instanceUID = string.Empty;
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "getInstanceInfo")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "instanceID")
                            {
                                instanceUID = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                    }

                    string epCode = string.Empty;
                    string epMessage = string.Empty;
                    GenericGetGenericInstanceInfoResponseType epGetGenericInstanceInfo = new GenericGetGenericInstanceInfoResponseType();
                    epGetGenericInstanceInfo.instance = new InstanceType();
                    epGetGenericInstanceInfo.instance.dicomInfo = new DicomInfoType();
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        switch (ids.ExpectedValues.GetParameter(i).Key)
                        {
                            case "code":
                                epCode = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "message":
                                epMessage = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_modality":
                                epGetGenericInstanceInfo.instance.dicomInfo.modality = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_acquisitionDate":
                                epGetGenericInstanceInfo.instance.dicomInfo.acquisitionDate = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_acquisitionTime":
                                epGetGenericInstanceInfo.instance.dicomInfo.acquisitionTime = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_patientFirstName":
                                epGetGenericInstanceInfo.instance.dicomInfo.patientFirstName = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_patientLastName":
                                epGetGenericInstanceInfo.instance.dicomInfo.patientLastName = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_patientId":
                                epGetGenericInstanceInfo.instance.dicomInfo.patientId = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_patientBirthDate":
                                epGetGenericInstanceInfo.instance.dicomInfo.patientBirthDate = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_patientAge":
                                epGetGenericInstanceInfo.instance.dicomInfo.patientAge = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_studyDate":
                                epGetGenericInstanceInfo.instance.dicomInfo.studyDate = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_kvp":
                                epGetGenericInstanceInfo.instance.dicomInfo.kvp = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_xrayTubeCurrent":
                                epGetGenericInstanceInfo.instance.dicomInfo.xrayTubeCurrent = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_exposureTime":
                                epGetGenericInstanceInfo.instance.dicomInfo.exposureTime = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_sopClassUid":
                                epGetGenericInstanceInfo.instance.dicomInfo.sopClassUid = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_instanceNumber":
                                epGetGenericInstanceInfo.instance.dicomInfo.instanceNumber = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_manufacturerModelName":
                                epGetGenericInstanceInfo.instance.dicomInfo.manufacturerModelName = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_imagerPixelSpacing":
                                epGetGenericInstanceInfo.instance.dicomInfo.imagerPixelSpacing = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_transferSyntax":
                                epGetGenericInstanceInfo.instance.dicomInfo.transferSyntax = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_anatomicRegion":
                                epGetGenericInstanceInfo.instance.dicomInfo.anatomicRegion = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            default:
                                break;
                        }
                    }

                    GenericIntanceServiceV2 genericInstanceSvc = new GenericIntanceServiceV2();

                    CheckPoint cpGetGenericInstanceInfo = new CheckPoint("getGenericInstanceInfo", "getGenericInstanceInfo");
                    r.CheckPoints.Add(cpGetGenericInstanceInfo);

                    GenericGetGenericInstanceInfoResponseType rtGetGenericInstanceInfo = genericInstanceSvc.getGenericInstanceInfo(instanceUID);
                    if (!genericInstanceSvc.LastReturnXMLValidateResult.isValid)
                    {
                        cpGetGenericInstanceInfo.Result = TestResult.Fail;
                        cpGetGenericInstanceInfo.Outputs.AddParameter("getGenericInstanceInfo", "Invalid XML", "GetGenericInstanceInfo response is not complied with schema. Actually get: " + genericInstanceSvc.LastReturnXML);
                        SaveRound(r);
                        continue;
                    }

                    if (rtGetGenericInstanceInfo.status.code != 0)
                    {
                        cpGetGenericInstanceInfo.Result = TestResult.Fail;
                        cpGetGenericInstanceInfo.Outputs.AddParameter("getGenericInstanceInfo", "Get Fail", "Get Fail.Code:" + rtGetGenericInstanceInfo.status.code.ToString() + " Message:" + rtGetGenericInstanceInfo.status.message);
                        SaveRound(r);
                        continue;
                    }

                    CompareObjects compareObjects = new CompareObjects();
                    if (compareObjects.Compare(epGetGenericInstanceInfo.instance.dicomInfo, rtGetGenericInstanceInfo.instance.dicomInfo))
                    {
                        cpGetGenericInstanceInfo.Result = TestResult.Pass;
                        cpGetGenericInstanceInfo.Outputs.AddParameter("getGenericInstanceInfo", "Check the DICOM Info", "The return value is equal to expected value" + genericInstanceSvc.LastReturnXML);
                    }
                    else
                    {
                        cpGetGenericInstanceInfo.Result = TestResult.Fail;
                        cpGetGenericInstanceInfo.Outputs.AddParameter("getGenericInstanceInfo", "Check the DICOM Info", "Fail. The return values is not equal to expected value." + compareObjects.DifferencesString + ". Actually get: " + genericInstanceSvc.LastReturnXML);
                        SaveRound(r);
                        continue;
                    }

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Result = TestResult.Fail;
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message);
                    SaveRound(r);
                }
            }

            Output();
        }
예제 #3
0
        /// <summary>
        ///  Compares the previous GlueProjectSave with the current one.
        /// </summary>
        /// <returns>True if the GlueProjectSaves are the same</returns>
        private static bool CompareGlueProjectSaves()
        {
            if (!string.IsNullOrEmpty(mCurrentGlueFile))
            {
                int       numberOfTries    = 0;
                const int maxNumberOfTries = 5;
                bool      succeeded        = false;

                GlueProjectSave newGlueProjectSave = null;
                Exception       lastException      = null;
                //ObjectFinder.GlueProject = null;
                while (numberOfTries < maxNumberOfTries)
                {
                    try
                    {
                        newGlueProjectSave = FileManager.XmlDeserialize <GlueProjectSave>(mCurrentGlueFile);
                        succeeded          = true;
                        break;
                    }
                    catch (Exception e)
                    {
                        System.Threading.Thread.Sleep(25);
                        numberOfTries++;
                        lastException = e;
                    }
                }

                if (!succeeded)
                {
                    MessageBox.Show("Error loading GLUX:\n\n" + lastException.ToString());
                }

                if (GlueProjectSave == null && newGlueProjectSave != null)
                {
                    // This method gets called on the primary
                    // thread so it's okay to call UnloadGluxActivity
                    // which is synchronous:


                    // October 23, 2012
                    // I don't understand
                    // why we call UnloadGluxActivity.
                    // If the GlueProjectSave is null then
                    // there is no need to unload it is there?
                    // Unloading wipes out mNextElement, which we
                    // don't want to do if we're loading a .glux for
                    // the first time.
                    //mShouldUnloadGlux = true;
                    //UnloadGluxActivity();
                    GlueProjectSave = newGlueProjectSave;

                    return(false);
                }

                CompareObjects compareObjects = new CompareObjects();

                compareObjects.ElementsToIgnore.Add("ContainerType");
                compareObjects.ElementsToIgnore.Add("ImageWidth");
                compareObjects.ElementsToIgnore.Add("ImageHeight");
                compareObjects.ElementsToIgnore.Add("EquilibriumParticleCount");
                compareObjects.ElementsToIgnore.Add("BurstParticleCount");
                compareObjects.ElementsToIgnore.Add("RuntimeType");
                compareObjects.ElementsToIgnore.Add("EventSave");
                compareObjects.ElementsToIgnore.Add("SharedCodeFullFileName");


                // This method gets called on the primary
                // thread so it's okay to call UnloadGluxActivity
                // which is synchronous:
                mShouldUnloadGlux = true;
                UnloadGluxActivity();

                GlueProjectSave = newGlueProjectSave;
            }
            return(false);
        }
예제 #4
0
        public void TestWriteThenReadManyTimes()
        {
            if (!_runTests)
            {
                return;
            }

            Random           random = new Random();
            List <AssetBase> assets = new List <AssetBase>();

            int start;

            try
            {
                for (int i = 0; i < 25; i++)
                {
                    AssetBase baseAsset = new AssetBase();

                    var arr = new byte[512 * 1024];
                    random.NextBytes(arr);

                    baseAsset.Data                  = arr;
                    baseAsset.Name                  = "Name1234567 ΏΏ";
                    baseAsset.Description           = "Description TEstttt ΏΏΏÿÿ";
                    baseAsset.FullID                = UUID.Random();
                    baseAsset.Local                 = true;
                    baseAsset.Temporary             = true;
                    baseAsset.Type                  = 5;
                    baseAsset.Metadata.CreationDate = DateTime.Now;

                    start = Environment.TickCount;
                    _client.StoreAsset(baseAsset);
                    Console.WriteLine("Time to store: {0}", Environment.TickCount - start);

                    assets.Add(baseAsset);
                }

                // Use ConcurrentQueue to enable safe enqueueing from multiple threads.
                var exceptions = new ConcurrentQueue <Exception>();

                System.Threading.Tasks.Parallel.For(0, 10, i =>
                {
                    try
                    {
                        foreach (var baseAsset in assets)
                        {
                            start             = Environment.TickCount;
                            AssetBase cfAsset = _client.RequestAssetSync(baseAsset.FullID);
                            Console.WriteLine("Time to read: {0}", Environment.TickCount - start);

                            CompareObjects comp          = new CompareObjects();
                            comp.CompareStaticFields     = false;
                            comp.CompareStaticProperties = false;

                            Assert.IsTrue(comp.Compare(baseAsset, cfAsset), comp.DifferencesString);
                            CollectionAssert.AreEqual(baseAsset.Data, cfAsset.Data);
                        }
                    }
                    catch (Exception e)
                    {
                        exceptions.Enqueue(e);
                    }
                });

                if (exceptions.Count > 0)
                {
                    throw new AggregateException(exceptions);
                }
            }
            finally
            {
                foreach (var baseAsset in assets)
                {
                    start = Environment.TickCount;
                    //cleanup
                    _client.PurgeAssetSync(baseAsset.FullID);
                    Console.WriteLine("Time to purge: {0}", Environment.TickCount - start);
                }
            }
        }
예제 #5
0
        public void TestWriteTHENRetrieveLargeAssets()
        {
            if (!_runTests)
            {
                return;
            }

            Random           random = new Random();
            List <AssetBase> assets = new List <AssetBase>();

            int start;

            try
            {
                for (int i = 0; i < 25; i++)
                {
                    AssetBase baseAsset = new AssetBase();

                    var arr = new byte[1 * 1024 * 1024];
                    random.NextBytes(arr);

                    baseAsset.Data                  = arr;
                    baseAsset.Name                  = "Name1234567 ΏΏ";
                    baseAsset.Description           = "Description TEstttt ΏΏΏÿÿ";
                    baseAsset.FullID                = UUID.Random();
                    baseAsset.Local                 = true;
                    baseAsset.Temporary             = true;
                    baseAsset.Type                  = 5;
                    baseAsset.Metadata.CreationDate = DateTime.Now;

                    start = Environment.TickCount;
                    _client.StoreAsset(baseAsset);
                    Console.WriteLine("Time to store: {0}", Environment.TickCount - start);

                    assets.Add(baseAsset);
                }


                foreach (var baseAsset in assets)
                {
                    start = Environment.TickCount;
                    AssetBase cfAsset = _client.RequestAssetSync(baseAsset.FullID);
                    Console.WriteLine("Time to read: {0}", Environment.TickCount - start);

                    CompareObjects comp = new CompareObjects();
                    comp.CompareStaticFields     = false;
                    comp.CompareStaticProperties = false;

                    Assert.IsTrue(comp.Compare(baseAsset, cfAsset), comp.DifferencesString);
                    CollectionAssert.AreEqual(baseAsset.Data, cfAsset.Data);
                }
            }
            finally
            {
                foreach (var baseAsset in assets)
                {
                    start = Environment.TickCount;
                    //cleanup
                    _client.PurgeAssetSync(baseAsset.FullID);
                    Console.WriteLine("Time to purge: {0}", Environment.TickCount - start);
                }
            }
        }
 public void Cleanup()
 {
     _compare = null;
 }
 public void Initialize()
 {
     _compare = new CompareObjects();
 }