public void ContainsValue_ReturnsTrueIfKeyValueCombinationExists()
        {
            _target.Add("A", "B");

            var result = _target.ContainsValue("A", "B");

            Assert.True(result);
        }
Esempio n. 2
0
 /// <summary>
 /// Since collisions are added as the original updater being tangible1, any overlaps are likely
 /// to have tangible2 being the key, therefore tangible2 is checked first in each && statement
 /// </summary>
 /// <param name="tangible1"></param>
 /// <param name="tangible2"></param>
 /// <returns>True if the collision already exists, false otherwise</returns>
 private bool collisionExists(Tangible tangible1, Tangible tangible2)
 {
     // If this collision already exists, dictionary has to contain one or the other as a key
     //if (!collisions.ContainsKey(tangible2) && !collisions.ContainsKey(tangible1)) {
     //	return false;
     //}
     // The collision may exist as key-value pair of <tangible1, tangible2> or <tangible2, tangible1>
     if (!collisions.ContainsValue(tangible2, tangible1) && !collisions.ContainsValue(tangible1, tangible2))
     {
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
        public static void ShouldContainValue()
        {
            var multiDict = new MultiValueDictionary <int, string>();

            multiDict.AddRange(100, values2);
            multiDict.AddRange(-5, values1);
            multiDict.Add(1337, "海亀");

            Assert.IsTrue(multiDict.ContainsValue("dojpa2"));
            Assert.IsTrue(multiDict.ContainsValue("海亀"));
            Assert.IsTrue(multiDict.ContainsValue("test4"));
            Assert.IsTrue(multiDict.Contains("海亀"));
            Assert.IsTrue(multiDict.Contains("test1"));
            Assert.IsTrue(multiDict.Contains("dojpa4"));
        }
Esempio n. 4
0
        public void ContainsValue(int size)
        {
            MultiValueDictionary <int, int> dict = CreateMVD(size);

            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                    for (int i = 0; i <= 20000; i++)
                    {
                        dict.ContainsValue(i); dict.ContainsValue(i); dict.ContainsValue(i);
                        dict.ContainsValue(i); dict.ContainsValue(i); dict.ContainsValue(i);
                        dict.ContainsValue(i); dict.ContainsValue(i); dict.ContainsValue(i);
                    }
            }
        }
Esempio n. 5
0
    private Dictionary <string, string> GetAssetNamesFromGUIDsAndRemoveOutdatedOnes(MultiValueDictionary <string, string> a_rMultiDict, IEnumerable <string> a_rGUIDs)
    {
        Dictionary <string, string> oGUIDNamesDict = new Dictionary <string, string>( );
        List <string> oOutdatedGUIDs = new List <string>( );

        foreach (string rGUID in a_rGUIDs)
        {
            string oName = Uni2DEditorUtils.GetAssetNameFromUnityGUID(rGUID);

            if (oName != null)
            {
                oGUIDNamesDict.Add(rGUID, oName);
            }
            else
            {
                // Name is null => asset doesn't exist anymore
                oOutdatedGUIDs.Add(rGUID);
            }
        }

        // Remove the outdated GUID from our multi-value dict
        foreach (string rOutdatedGUID in oOutdatedGUIDs)
        {
            MultiValueDictionary <string, string> .KeyCollection rKeys = a_rMultiDict.Keys;
            foreach (string rKey in rKeys)
            {
                if (a_rMultiDict.ContainsValue(rKey, rOutdatedGUID))
                {
                    a_rMultiDict.Remove(rKey, rOutdatedGUID);
                }
            }
            // TODO: save?
        }

        return(oGUIDNamesDict);
    }
Esempio n. 6
0
 public bool ContainsValue() => _dict.ContainsValue(_value);
Esempio n. 7
0
        public static void ShouldContainValue()
        {
            var multiDict = new MultiValueDictionary<int, string>();
            multiDict.AddRange(100, values2);
            multiDict.AddRange(-5, values1);
            multiDict.Add(1337, "海亀");

            Assert.IsTrue(multiDict.ContainsValue("dojpa2"));
            Assert.IsTrue(multiDict.ContainsValue("海亀"));
            Assert.IsTrue(multiDict.ContainsValue("test4"));
            Assert.IsTrue(multiDict.Contains("海亀"));
            Assert.IsTrue(multiDict.Contains("test1"));
            Assert.IsTrue(multiDict.Contains("dojpa4"));
        }
Esempio n. 8
0
 public bool Contains(V item) => _dic.ContainsValue(item);