Ejemplo n.º 1
0
 public override List <string> GetParent(string path)
 {
     if (Parents.ContainsKey(path))
     {
         return(Parents[path]);
     }
     return(new List <string>());
 }
Ejemplo n.º 2
0
 public void AddParent(ParentEntry entry)
 {
     if (Parents.ContainsKey(entry.Id))
     {
         throw new ObjectAlreadyExistsException("Object is already parented by this parent");
     }
     Parents.Add(entry.Id, entry);
 }
        // Internal for testing
        internal async Task CreateParents(IEnumerable <IGrouping <string, ITestResult> > testResultsByParent, CancellationToken cancellationToken)
        {
            // Find the parents that don't exist
            string[] parentsToAdd = testResultsByParent
                                    .Select(x => x.Key)
                                    .Where(x => !Parents.ContainsKey(x))
                                    .ToArray();

            // Batch an add operation and record the new parent IDs
            DateTime startedDate = DateTime.UtcNow;

            if (parentsToAdd.Length > 0)
            {
                string request = "[ " + string.Join(", ", parentsToAdd.Select(x =>
                {
                    Dictionary <string, object> properties = new Dictionary <string, object>
                    {
                        { "testCaseTitle", x },
                        { "automatedTestName", x },
                        { "resultGroupType", "generic" },
                        { "outcome", "Passed" }, // Start with a passed outcome initially
                        { "state", "InProgress" },
                        { "startedDate", startedDate.ToString("yyyy-MM-ddTHH:mm:ss.FFFZ") },
                        { "automatedTestType", "UnitTest" },
                        { "automatedTestTypeId", "13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" } // This is used in the sample response and also appears in web searches
                    };
                    if (!string.IsNullOrEmpty(Source))
                    {
                        properties.Add("automatedTestStorage", Source);
                    }
                    return(properties.ToJson());
                })) + " ]";
                string responseString = await _apiClient.SendAsync(HttpMethod.Post, TestRunEndpoint, "5.0", request, cancellationToken).ConfigureAwait(false);

                using (StringReader reader = new StringReader(responseString))
                {
                    JsonObject response = JsonDeserializer.Deserialize(reader) as JsonObject;
                    JsonArray  parents  = (JsonArray)response.Value("value");
                    if (parents.Length != parentsToAdd.Length)
                    {
                        throw new Exception("Unexpected number of parents added");
                    }
                    for (int c = 0; c < parents.Length; c++)
                    {
                        int id = ((JsonObject)parents[c]).ValueAsInt("id");
                        Parents.Add(parentsToAdd[c], new TestResultParent(id, startedDate));
                    }
                }
            }
        }
Ejemplo n.º 4
0
 internal void RemoveParent(int hash)
 {
     if (Parents.ContainsKey(hash))
     {
         if (Parents[hash] <= 1)
         {
             Parents.Remove(hash);
         }
         else
         {
             Parents[hash]--;
         }
     }
 }
Ejemplo n.º 5
0
        protected virtual void RemoveParent(MockObject parent, DateTime updateTime, bool relationshipOnChild)
        {
            if (parent == null || !Parents.ContainsKey(parent.Uuid))
            {
                return;
            }

            Parents.Remove(parent.Uuid);
            parent.RemoveChild(this, updateTime, relationshipOnChild);
            if (relationshipOnChild)
            {
                UpdateObjectLastWrite(updateTime);
            }
        }
Ejemplo n.º 6
0
        internal void AddParent(int hash)
        {
            if (hash == 0)
            {
                return;
            }

            if (!Parents.ContainsKey(hash))
            {
                Parents.Add(hash, 1);
            }
            else
            {
                Parents[hash]++;
            }
        }
Ejemplo n.º 7
0
 public IBindableListControl GetParent(BindEntities entity)
 {
     return(!Parents.ContainsKey(entity) ? null : Parents[entity]);
 }
Ejemplo n.º 8
0
        public override void Load()
        {
            EditorUtility.DisplayCancelableProgressBar("Hold on", "", 0);
            AssetDatabase.SaveAssets();
            string[]         allAsset     = AssetDatabase.GetAllAssetPaths();
            HashSet <string> removedPaths = new HashSet <string>(LastUpdateTimes.Keys);

            removedPaths.ExceptWith(allAsset);
            Debug.Log(removedPaths.Count);
            foreach (var path in removedPaths)
            {
                if (Childrens.ContainsKey(path))
                {
                    foreach (var p in Childrens[path])
                    {
                        if (Parents.ContainsKey(p))
                        {
                            Parents[p].Remove(path);
                        }
                    }
                    Childrens.Remove(path);
                }
                if (Parents.ContainsKey(path))
                {
                    foreach (var p in Parents[path])
                    {
                        if (Childrens.ContainsKey(p))
                        {
                            Childrens[p].Remove(path);
                        }
                    }
                    Parents.Remove(path);
                }
                LastUpdateTimes.Remove(path);
            }
            int count = allAsset.Length;

            for (int i = 0; i < count; i++)
            {
                if (i % 100 == 0)
                {
                    if (EditorUtility.DisplayCancelableProgressBar("Hold on", "GetDependencies " + i + "/" + count, (float)i / count))
                    {
                        EditorUtility.ClearProgressBar();
                        return;
                    }
                }
                string p    = allAsset[i];
                var    time = File.GetLastWriteTime(p);
                if (!LastUpdateTimes.ContainsKey(p) || LastUpdateTimes[p] < time)
                {
                    if (Childrens.ContainsKey(p))
                    {
                        foreach (var ps in Childrens[p])
                        {
                            if (Parents.ContainsKey(ps))
                            {
                                Parents[ps].Remove(p);
                            }
                        }
                    }
                    var dp = AssetDatabase.GetDependencies(p, false);
                    Childrens[p] = new UStringList();
                    Childrens[p].AddRange(dp);
                    Childrens[p].Remove(p);
                    foreach (var d in dp)
                    {
                        if (d == p)
                        {
                            continue;
                        }
                        if (!Parents.ContainsKey(d))
                        {
                            Parents.Add(d, new UStringList());
                        }
                        Parents[d].Remove(p);
                        Parents[d].Add(p);
                    }
                    LastUpdateTimes[p] = time;
                }
            }
            EditorUtility.SetDirty(this);
            AssetDatabase.SaveAssets();
            EditorUtility.ClearProgressBar();
        }