Пример #1
0
        public static async Task InsertNewOrgTest()
        {
            await Networks.NetworkTests.InsertNewNetworkTest();

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

            Newtonsoft.Json.JsonSerializerSettings jsonSettings = new Newtonsoft.Json.JsonSerializerSettings();
            jsonSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.IgnoreAndPopulate;
            OrgList orgs       = Newtonsoft.Json.JsonConvert.DeserializeObject <OrgList>(json, jsonSettings);
            var     controller = new OrganizationsController();

            foreach (var org in orgs.Organizations)
            {
                var response = await controller.Register(org);

                OrgPair.Add(new KeyValuePair <Guid, Guid>(org.ID, response.ID.Value));
                using (var db = new Data.DataContext())
                {
                    var orgGet = await db.Organizations.FindAsync(response.ID);

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

                    Assert.IsTrue(!orgGet.IsEmpty());
                    Assert.IsTrue(metaData.Count() > 0);
                }
            }
        }
Пример #2
0
        public static async Task UpdateNewOrgTest()
        {
            string filepath = System.IO.Path.Combine(ResourceFolder, "OrganizationsUpdate.json");
            var    json     = System.IO.File.ReadAllText(filepath);

            Newtonsoft.Json.JsonSerializerSettings jsonSettings = new Newtonsoft.Json.JsonSerializerSettings();
            jsonSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.IgnoreAndPopulate;
            OrgList orgs       = Newtonsoft.Json.JsonConvert.DeserializeObject <OrgList>(json, jsonSettings);
            var     controller = new OrganizationsController();

            foreach (var org in orgs.Organizations)
            {
                using (var db = new Data.DataContext())
                {
                    var orgID = OrgPair.Where(x => x.Key == org.ID).Select(x => x.Value).FirstOrDefault();
                    org.ID = orgID;
                    var metadatas    = db.DomainDatas.OfType <Data.OrganizationDomainData>().Where(x => x.OrganizationID == orgID).ToArray();
                    var newMetaDatas = new List <DomainDataDTO>();
                    foreach (var metadata in metadatas)
                    {
                        if (metadata.DomainUseID == new Guid("082C0001-C179-4630-A0C9-A6560123AFC6") || metadata.DomainReferenceID == new Guid("16C392E9-FF26-47C6-AE6F-A62600B48C85"))
                        {
                            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("BF140BF4-91BF-41F0-BA4A-A62600AED2B9") || metadata.DomainReferenceID == new Guid("B7236848-CA4E-4F5F-B482-A62600AEC6C6"))
                        {
                            //Intensionally leaving this blank to not put into newMetaDatas List.
                        }
                        else if (org.ID == new Guid("CD50B39C-9A9E-48FB-91D0-A62700F623B0"))
                        {
                            var meta = new DomainDataDTO()
                            {
                                DomainUseID       = Guid.Parse("B5D00001-6085-44DA-8162-A6560124D48D"),
                                DomainReferenceID = Guid.Parse("95414CD3-B661-4F91-8957-A62600B243D9"),
                                SequenceNumber    = 0
                            };
                            newMetaDatas.Add(meta);
                        }
                        else if (org.ID == new Guid("8EDD0AF4-29CE-4B82-8D85-A62700F8EFDF"))
                        {
                            var meta = new DomainDataDTO()
                            {
                                DomainUseID       = Guid.Parse("B5D00001-6085-44DA-8162-A6560124D48D"),
                                DomainReferenceID = Guid.Parse("F108307B-B8C5-4DE4-A6E8-A62600B25065"),
                                Value             = "LPP Types of Data",
                                SequenceNumber    = 0
                            };
                            newMetaDatas.Add(meta);
                        }
                        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);
                        }
                    }
                    org.Metadata = newMetaDatas;



                    var response = await controller.Update(org);

                    var orgGet = await db.Organizations.FindAsync(orgID);

                    var metaData = await db.DomainDatas.OfType <Data.OrganizationDomainData>().Where(x => x.OrganizationID == orgID).ToArrayAsync();

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