public void CanTestContainsKeyWhenKeyExists()
        {
            var dictionary = new OptionDictionary <string, string>
            {
                { "key", "value" }
            };

            Assert.That(dictionary.ContainsKey("key"), Is.True);
        }
        public void CanTestContainsKeyWhenKeyDoesNotExist()
        {
            var dictionary = new OptionDictionary <string, string>
            {
                { "key", "value" }
            };

            Assert.That(dictionary.ContainsKey("other-key"), Is.False);
        }
Exemple #3
0
        public T Get <T>(string key)
        {
            OptionDictionary <T> options = GetOptionCollection <T>();

            if (!options.ContainsKey(key) || IsOverrideIsRequired(key))
            {
                T value = GetDefaultValue <T>(key);
                options[key] = value;
            }

            return(options[key]);
        }
Exemple #4
0
        void OnEnable()
        {
            if (EnabledOptions == null)
                EnabledOptions = new OptionDictionary();

            foreach (string name in Enum.GetNames(typeof(BuildAssetBundleOptions)))
            {
                // the first enum value is 'None' so we skip it.
                if (string.IsNullOrEmpty(name) || name == "None")
                    continue;

                BuildAssetBundleOptions key = (BuildAssetBundleOptions)Enum.Parse(typeof(BuildAssetBundleOptions), name);
                if (!EnabledOptions.ContainsKey(key))
                {
                    bool val = false;
#if UNITY_5
                    // Skip some options which are not neccessary on Unity 5.x
                    // CollectDependencies and DeterministicAssetBundle are always enabled in the new AssetBundle build system introduced in 5.0.
                    // CompleteAssets is ingored as we always start from assets rather than objects, it should be complete by default.
                    if (key != BuildAssetBundleOptions.None && 
                       (key == BuildAssetBundleOptions.UncompressedAssetBundle ||
                        key == BuildAssetBundleOptions.DisableWriteTypeTree ||
                        key == BuildAssetBundleOptions.ForceRebuildAssetBundle ||
                        key == BuildAssetBundleOptions.IgnoreTypeTreeChanges ||
                        key == BuildAssetBundleOptions.AppendHashToAssetBundleName
                #if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2) // from Unity 5.3x, it supports ChunkBasedCompression
                        || key == BuildAssetBundleOptions.ChunkBasedCompression))
                #endif
                    {
                        EnabledOptions.Add(key, val);
                    }
#else
                        EnabledOptions.Add(key, val);
#endif
                }
            }
        }
        public void NeverContainsNullKey()
        {
            var dictionary = new OptionDictionary <string, string>();

            Assert.That(dictionary.ContainsKey(null), Is.False);
        }