private void CheckForNewCase(string caseNumber) { var task = Inquirer.GetInquirerCaseByNumber(caseNumber, _context.Token); Assert.IsNotNull(task); Assert.IsNotNull(task.Result); switch (task.Result.Type) { case Constants.CABLE_INQUIRY_PURPOSE: ChecksForCableOwnerCase(task.Result.CableInquiry); break; case Constants.PROJECT_INQUIRY_PURPOSE: ChecksForCableOwnerCase(task.Result.ProjectInquiry); break; case Constants.COLLABORATION_INQUIRY_PURPOSE: ChecksForCableOwnerCase(task.Result.CollaborationInquiry); break; case Constants.PLANNING_INQUIRY_PURPOSE: ChecksForCableOwnerCase(task.Result.PlanningInquiry); break; case Constants.EMERGENCY_INQUIRY_PURPOSE: ChecksForCableOwnerCase(task.Result.EmergencyInquiry); break; } }
public void CreateProjectCase() { var categories = GetWorkCategories(Constants.CABLE_INQUIRY_PURPOSE).Result; var random = new Random(); var category = categories[random.Next(categories.Count)]; var projectInquiryRecipients = GetInvolvedRecipients(new ProjectInquiry { Geometry = _featureCollection }).Result; var removeInvolvedOrgs = new List <string>(); var totalAffectedOrgs = projectInquiryRecipients.Count(cr => cr.AreaType == "affected"); if (totalAffectedOrgs > 1) { // so at least 2 => remove half var caseRecipients = projectInquiryRecipients.Where(cr => cr.AreaType == "affected"); var index = 0; foreach (var cr in caseRecipients) { if (index % 2 == 0) { removeInvolvedOrgs.Add(cr.Organization.Id); } index++; } } var removeInterestedOrgs = new List <string>(); var totalControlOrgs = projectInquiryRecipients.Count(cr => cr.AreaType == "control"); if (totalControlOrgs > 1) { // so at least 2 => remove half var caseRecipients = projectInquiryRecipients.Where(cr => cr.AreaType == "control"); var index = 0; foreach (var cr in caseRecipients) { if (index % 2 == 0) { removeInterestedOrgs.Add(cr.Organization.Id); } index++; } } var attachments = AddAttachmentFile(); var projectCase = PostInquiry <ProjectInquiry, CreateProjectInquiry>( new CreateProjectInquiry { Attachments = attachments, ExemptedInvolvedOrganzations = removeInvolvedOrgs, ExemptedInterestedOrganzations = removeInterestedOrgs, Inquiry = new ProjectInquiry { Name = "Testing adding project case through API", Comment = "Testing adding project case through API", Geometry = _featureCollection, ProjectStartDate = DateTime.Today.AddDays(1).ToString("O"), ProjectEndDate = DateTime.Today.AddDays(31).ToString("O"), NotifyOnReply = true, NotificationViaSms = "+46 123 321123", PreferedContactValue = "*****@*****.**", PreferedContactWay = Constants.CONTACT_WAY_EMAIL, // The properties ReplyAsPdf, GisFileFormat and FileCoordinateSystem are only // valid/set/saved if the prefered contact way (PreferedContactWay) is email. ReplyAsPdf = true, // GisFileFormat and FileCoordinateSystem can also be emtpy GisFileFormat = Constants.LkSupportedGisFileFormats().Last(), FileCoordinateSystem = Constants.LkSupportedCoordinateSystems().Keys.First(), ExcavationDepth = 1, WorkCategory = new List <string> { category.UniqueName } } }).Result; Assert.IsNotNull(projectCase); Assert.IsNotNull(projectCase.FirstOrDefault()); Assert.IsNotNullOrEmpty(projectCase.First()); CheckForNewCase(projectCase.First()); // doing extra checks, so the number of existing involved and interested orgs are as expected var task = Inquirer.GetInquirerCaseByNumber(projectCase.First(), _context.Token); Assert.That(task.Result.InvolvedRecipients.Count > 0); Assert.That(task.Result.InterestedRecipients.Count > 0); }