Exemplo n.º 1
0
        public static async Task InsertNewDataMartTest()
        {
            await Organizations.OrganizationTests.InsertNewOrgTest();

            string filepath = System.IO.Path.Combine(ResourceFolder, "DataSourcesRegister.json");
            var    json     = System.IO.File.ReadAllText(filepath);

            Newtonsoft.Json.JsonSerializerSettings jsonSettings = new Newtonsoft.Json.JsonSerializerSettings();
            jsonSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.IgnoreAndPopulate;
            DataSourceList datasources = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSourceList>(json, jsonSettings);
            var            controller  = new DataSourcesController();

            foreach (var ds in datasources.DataSources)
            {
                ds.OrganizationID = Organizations.OrganizationTests.OrgPair.Where(x => x.Key == ds.OrganizationID).Select(x => x.Value).FirstOrDefault();
                var response = await controller.Register(ds);

                DataSourcePair.Add(new KeyValuePair <Guid, Guid>(ds.ID, response.ID.Value));
                using (var db = new Data.DataContext())
                {
                    var dsGet = await db.DataSources.FindAsync(response.ID);

                    var metaData = await db.DomainDatas.OfType <Data.DataSourceDomainData>().Where(x => x.DataSourceID == response.ID).ToArrayAsync();

                    Assert.IsTrue(!dsGet.IsEmpty());
                    Assert.IsTrue(metaData.Count() > 0);
                }
            }
        }
Exemplo n.º 2
0
        public static async Task UpdateNewDataMartTest()
        {
            string filepath = System.IO.Path.Combine(ResourceFolder, "DataSourcesUpdate.json");
            var    json     = System.IO.File.ReadAllText(filepath);

            Newtonsoft.Json.JsonSerializerSettings jsonSettings = new Newtonsoft.Json.JsonSerializerSettings();
            jsonSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.IgnoreAndPopulate;
            DataSourceList dataSources = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSourceList>(json, jsonSettings);
            var            controller  = new DataSourcesController();

            foreach (var ds in dataSources.DataSources)
            {
                using (var db = new Data.DataContext())
                {
                    var dsID = DataSourcePair.Where(x => x.Key == ds.ID).Select(x => x.Value).FirstOrDefault();
                    ds.ID             = dsID;
                    ds.OrganizationID = Organizations.OrganizationTests.OrgPair.Where(x => x.Key == ds.OrganizationID).Select(x => x.Value).FirstOrDefault();
                    var metadatas    = db.DomainDatas.OfType <Data.DataSourceDomainData>().Where(x => x.DataSourceID == dsID).ToArray();
                    var newMetaDatas = new List <DomainDataDTO>();
                    foreach (var metadata in metadatas)
                    {
                        if (metadata.DomainUseID == new Guid("86560001-6947-4384-8CB1-A6560123B537") || metadata.DomainReferenceID == new Guid("6C9E0001-D50F-406D-A099-A6560124734C"))
                        {
                            var meta = new DomainDataDTO();
                            meta.Value          = metadata.Value + " Update Test";
                            meta.SequenceNumber = 0;
                            meta.ID             = metadata.ID;
                            meta.DomainUseID    = metadata.DomainUseID;
                            if (metadata.DomainReferenceID.HasValue)
                            {
                                meta.DomainReferenceID = metadata.DomainReferenceID.Value;
                            }
                            newMetaDatas.Add(meta);
                        }
                        else if (metadata.DomainReferenceID == new Guid("BB90ED02-2DF6-4219-A495-A62600C583AD"))
                        {
                            //Intensionally leaving this blank to not put into newMetaDatas List.
                        }
                        else
                        {
                            //This is filling in all the rest to remain untouched
                            var meta = new DomainDataDTO()
                            {
                                ID             = metadata.ID,
                                DomainUseID    = metadata.DomainUseID,
                                Value          = metadata.Value,
                                SequenceNumber = metadata.SequenceNumber
                            };
                            if (metadata.DomainReferenceID.HasValue)
                            {
                                meta.DomainReferenceID = metadata.DomainReferenceID;
                            }
                            newMetaDatas.Add(meta);
                        }
                    }
                    var addMeta = new DomainDataDTO()
                    {
                        DomainUseID       = Guid.Parse("B5D00001-6085-44DA-8162-A6560124D48D"),
                        DomainReferenceID = Guid.Parse("28D4092C-A14A-4C4D-B089-A62600C57733"),
                        Value             = "LPP Inpatient Encounter",
                        SequenceNumber    = 0
                    };
                    newMetaDatas.Add(addMeta);
                    ds.Metadata = newMetaDatas;



                    var response = await controller.Update(ds);

                    var dsGet = await db.DataSources.FindAsync(dsID);

                    var metaData = await db.DomainDatas.OfType <Data.DataSourceDomainData>().Where(x => x.DataSourceID == dsID).ToArrayAsync();

                    Assert.IsTrue(!dsGet.IsEmpty());
                    Assert.IsTrue(metaData.Count() > 0);
                }
            }
        }