public void RemoveAll() { //**************************************** var Random = Initialise(); var Records = new StringKeyDictionary <int>(); var Dictionary = new Dictionary <string, int>(1024); //**************************************** foreach (var Pair in YieldRandom(Random, 1024)) { Dictionary.Add(Pair.Key, Pair.Value); Records.Add(Pair.Key, Pair.Value); } //**************************************** Records.RemoveAll((pair) => { if (Random.Next() > int.MaxValue / 2) { return(Dictionary.Remove(pair.Key)); } return(false); }); //**************************************** CollectionAssert.AreEquivalent(Dictionary, Records, "Collections don't match"); foreach (var MyPair in Dictionary) { Assert.IsTrue(Records.TryGetValue(MyPair.Key, out var Value)); Assert.AreEqual(MyPair.Value, Value); } Thread.Sleep(1); }
public override void DoLoad() { StringKeyDictionary dict = new StringKeyDictionary(); dict.Add(BACKGROUND_SPRITE_KEY, _backgroundSprite); DoLoadImpl(dict, false); }
public void GetIndexOutOfRange() { //**************************************** var MyRecords = new StringKeyDictionary <int>(); //**************************************** MyRecords["A"] = 42; //**************************************** try { var Pair = ((IList <KeyValuePair <string, int> >)MyRecords)[1]; Assert.Fail("Key found"); } catch (ArgumentOutOfRangeException) { } try { var Pair = ((IList <KeyValuePair <string, int> >)MyRecords)[-1]; Assert.Fail("Key found"); } catch (ArgumentOutOfRangeException) { } }
[Test()] //, Repeat(2)] public void AddRemoveAll() { //**************************************** var Random = Initialise(); var Records = new StringKeyDictionary <int>(1024); //**************************************** foreach (var Pair in YieldRandom(Random, 1024)) { Records.Add(Pair.Key, Pair.Value); } //**************************************** while (Records.Count > 0) { var Key = ((IList <KeyValuePair <string, int> >)Records)[Random.Next(0, Records.Count)].Key; Records.Remove(Key); } foreach (var Pair in YieldRandom(Random, 1024)) { Records.Add(Pair.Key, Pair.Value); } }
{ public void DidAppear(StringKeyDictionary pInfo) { foreach (var uiControl in this.gameObject.GetComponentsInChildren <Selectable>(true)) { uiControl.enabled = true; } }
[Test()] //, Repeat(2)] public void AddRemove() { //**************************************** var Random = Initialise(); var Records = new StringKeyDictionary <int>(); //**************************************** foreach (var Pair in YieldRandom(Random, 16)) { Records.Add(Pair.Key, Pair.Value); } var Inputs = new Queue <KeyValuePair <string, int> >(YieldRandom(Random, 1024)); //**************************************** for (var Index = 0; Index < 1024; Index++) { if (Index % 10 >= 5 && Records.Count > 0) { var Key = ((IList <KeyValuePair <string, int> >)Records)[Random.Next(0, Records.Count)].Key; Records.Remove(Key); } else { var Pair = Inputs.Dequeue(); Records[Pair.Key] = Pair.Value; } } }
{ public void WillDisappear(StringKeyDictionary pInfo) { foreach (var uiControl in this.gameObject.GetComponentsInChildren <Selectable>(true)) { //Disable uiControl.enabled = false; } }
public void AddRangeDuplicateInDictionary() { //**************************************** var MyRecords = new StringKeyDictionary <int>(64); //**************************************** MyRecords["E"] = 1; MyRecords["F"] = 2; MyRecords["G"] = 3; MyRecords["H"] = 4; try { MyRecords.AddRange(new[] { new KeyValuePair <string, int>("A", 1), new KeyValuePair <string, int>("B", 2), new KeyValuePair <string, int>("C", 3), new KeyValuePair <string, int>("G", 4) }); Assert.Fail("Range succeeded"); } catch (ArgumentException) { } //**************************************** Assert.AreEqual(4, MyRecords.Count, "Items were added"); }
public void PrePopulate() { //**************************************** var Random = Initialise(); var Dictionary = new Dictionary <string, int>(1024); //**************************************** foreach (var Pair in YieldRandom(Random, 1024)) { Dictionary.Add(Pair.Key, Pair.Value); } //**************************************** var Records = new StringKeyDictionary <int>(Dictionary); //**************************************** Assert.AreEqual(1024, Records.Count, "Count incorrect"); CollectionAssert.AreEquivalent(Dictionary, Records, "Collections don't match"); foreach (var MyPair in Dictionary) { Assert.IsTrue(Records.TryGetValue(MyPair.Key, out var Value)); Assert.AreEqual(MyPair.Value, Value); } Thread.Sleep(1); }
public override object Visit(HashNode obj) { StringKeyDictionary <object> tuple = new StringKeyDictionary <object>(); foreach (var kvp in obj.KVPairs) { tuple.Add(kvp.Key, kvp.Value.Accept(this)); } return(tuple); }
public void GetKeySpan() { //**************************************** var MyRecords = new StringKeyDictionary <int>(); //**************************************** MyRecords["A"] = 42; //**************************************** Assert.AreEqual(42, MyRecords["A".AsSpan()]); }
public void GetIndex() { //**************************************** var MyRecords = new StringKeyDictionary <int>(); //**************************************** MyRecords["A"] = 42; //**************************************** Assert.AreEqual(new KeyValuePair <string, int>("A", 42), ((IList <KeyValuePair <string, int> >)MyRecords)[0]); }
public void IndexOfKeyMissing() { //**************************************** var MyRecords = new StringKeyDictionary <int>(); //**************************************** MyRecords["A"] = 42; //**************************************** Assert.AreEqual(-1, MyRecords.IndexOfKey("B")); }
public void IndexOfMissingValue() { //**************************************** var MyRecords = new StringKeyDictionary <int>(); //**************************************** MyRecords["A"] = 42; //**************************************** Assert.AreEqual(-1, MyRecords.IndexOf(new KeyValuePair <string, int>("A", 30))); }
override public IEnumerator DoTransition(StringKeyDictionary pInfo) { IEnumerator doTransition = base.DoTransition(pInfo); while (doTransition.MoveNext()) { yield return(doTransition.Current); } TransitionAnimator.Play(_idleClip, -1, 0.0f); TransitionAnimator.speed = 0.0f; yield return(null); }
override public IEnumerator DoTransition(StringKeyDictionary pInfo) { Assert.IsNotNull(_animator, System.String.Format(ANIMATOR_MISSING_EXCEPTION_FORMAT, gameObject.name)); Debug.Assert(_animator != null, System.String.Format(ANIMATOR_MISSING_EXCEPTION_FORMAT, gameObject.name)); System.Diagnostics.Debug.Assert(_animator != null, System.String.Format(ANIMATOR_MISSING_EXCEPTION_FORMAT, gameObject.name)); _animator.speed = 1f; _animator.Play(_animClip, -1, 0.0f); while (_animator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1) { yield return(null); } }
public TransitionOutro TransitionOutro(string pName, StringKeyDictionary pInfo, bool pSkip = false) { if (!String.IsNullOrEmpty(pName)) { foreach (var trans in TransitionsOut) { if (trans.TransitionName == pName) { return(trans); } } } return(null); }
public void GetItem_Int_Test() { // Arrange var dic = new StringKeyDictionary <int?>(new Dictionary <string, int?>() { { "null", null }, { "ok", 123 } }); // Act & assert Assert.IsNull(dic.GetItem("null")); Assert.IsNotNull(dic.GetItem("ok")); var key = dic.GetItem("key"); Assert.IsNull(key); }
public void Replace() { //**************************************** var MyRecords = new StringKeyDictionary <int>(); //**************************************** MyRecords.Add("A", 1); MyRecords.Add("B", 2); MyRecords.Add("C", 3); MyRecords.Add("D", 4); MyRecords["B"] = 84; //**************************************** Assert.AreEqual(84, MyRecords["B"]); }
public void GetIndexMulti() { //**************************************** var MyRecords = new StringKeyDictionary <int>(); //**************************************** MyRecords["A"] = 40; MyRecords["B"] = 41; MyRecords["C"] = 42; MyRecords["D"] = 43; MyRecords["E"] = 44; //**************************************** Assert.AreEqual(new KeyValuePair <string, int>("C", 42), ((IList <KeyValuePair <string, int> >)MyRecords)[2]); }
public void SetKey() { //**************************************** var MyRecords = new StringKeyDictionary <int>(); //**************************************** MyRecords["A"] = 1; MyRecords["B"] = 2; MyRecords["C"] = 3; MyRecords["D"] = 4; MyRecords["B"] = 84; //**************************************** Assert.AreEqual(84, MyRecords["B"]); }
public void Clear() { //**************************************** var Random = Initialise(); var Records = new StringKeyDictionary <int>(1024); //**************************************** foreach (var Pair in YieldRandom(Random, 1024)) { Records.Add(Pair.Key, Pair.Value); } //**************************************** Records.Clear(); Assert.AreEqual(0, Records.Count); }
public void AddRangePrePopulated() { //**************************************** var Random = Initialise(); var Records = new StringKeyDictionary <int>(); var Dictionary = new Dictionary <string, int>(1024); var SecondSet = new List <KeyValuePair <string, int> >(512); //**************************************** foreach (var Pair in YieldRandom(Random, 1024)) { Dictionary.Add(Pair.Key, Pair.Value); if (Records.Count < 512) { Records.Add(Pair.Key, Pair.Value); } else { SecondSet.Add(Pair); } } //**************************************** Records.AddRange(SecondSet); //**************************************** Assert.AreEqual(1024, Records.Count, "Count incorrect"); CollectionAssert.AreEquivalent(Dictionary, Records, "Collections don't match"); foreach (var MyPair in Dictionary) { Assert.IsTrue(Records.TryGetValue(MyPair.Key, out var Value)); Assert.AreEqual(MyPair.Value, Value); } Thread.Sleep(1); }
public void AddExists() { //**************************************** var MyRecords = new StringKeyDictionary <int>(); //**************************************** MyRecords.Add("A", 84); //**************************************** try { MyRecords.Add("A", 84); Assert.Fail("Add succeeded"); } catch (ArgumentException) { } }
public void GoBackTo(string pViewName, StringKeyDictionary pInfo = null, string pTransitionName = null, bool pWaitIfBusy = false) { bool found = false; int viewStackLength = _viewStack.Count; int viewCount = 0; while (!found && viewCount < viewStackLength) { if (_viewStack[viewCount].ViewName == pViewName) { found = true; } else { viewCount++; } } GoBack(viewCount, pInfo, pTransitionName, pWaitIfBusy); }
public void GetKeyMissing() { //**************************************** var MyRecords = new StringKeyDictionary <int>(); //**************************************** MyRecords["A"] = 42; //**************************************** try { var Pair = MyRecords["B"]; Assert.Fail("Key found"); } catch (KeyNotFoundException) { } }
public void RemoveAt() { //**************************************** var Random = Initialise(); var Records = new StringKeyDictionary <int>(); var Dictionary = new Dictionary <string, int>(1024); //**************************************** foreach (var Pair in YieldRandom(Random, 1024)) { Dictionary.Add(Pair.Key, Pair.Value); Records.Add(Pair.Key, Pair.Value); } //**************************************** for (var Index = 0; Index < 512; Index++) { var InnerIndex = Random.Next(Records.Count); var Key = Records.Keys[InnerIndex]; Records.RemoveAt(InnerIndex); Assert.IsTrue(Dictionary.Remove(Key)); } //**************************************** Assert.AreEqual(512, Records.Count, "Count incorrect"); CollectionAssert.AreEquivalent(Dictionary, Records, "Collections don't match"); foreach (var MyPair in Dictionary) { Assert.IsTrue(Records.TryGetValue(MyPair.Key, out var Value)); Assert.AreEqual(MyPair.Value, Value); } Thread.Sleep(1); }
[Test()] //, Repeat(2)] public void EnumerateValues() { //**************************************** var Random = Initialise(); var Records = new StringKeyDictionary <int>(); var Dictionary = new Dictionary <string, int>(1024); //**************************************** foreach (var Pair in YieldRandom(Random, 1024)) { Dictionary.Add(Pair.Key, Pair.Value); Records.Add(Pair.Key, Pair.Value); } //**************************************** Assert.AreEqual(1024, Records.Count, "Count incorrect"); CollectionAssert.AreEquivalent(Dictionary.Values, Records.Values, "Collections don't match"); Thread.Sleep(1); }
public void RemoveRange() { //**************************************** var Random = Initialise(); var Records = new StringKeyDictionary <int>(); var Dictionary = new Dictionary <string, int>(1024); //**************************************** foreach (var Pair in YieldRandom(Random, 1024)) { Dictionary.Add(Pair.Key, Pair.Value); Records.Add(Pair.Key, Pair.Value); } //**************************************** foreach (var Key in Enumerable.Skip <string>(Records.Keys, 256).Take(256)) { Dictionary.Remove(Key); } Records.RemoveRange(256, 256); //**************************************** CollectionAssert.AreEquivalent(Dictionary, Records, "Collections don't match"); foreach (var MyPair in Dictionary) { Assert.IsTrue(Records.TryGetValue(MyPair.Key, out var Value)); Assert.AreEqual(MyPair.Value, Value); } Thread.Sleep(1); }
protected void DoLoadImpl(StringKeyDictionary pDict, bool pWaitIfBusy) { //Load the view from the manager _viewManager.LoadView(_viewName, pDict, _transitionName, pWaitIfBusy, _replaceCurrent); }
public IgnoreCaseStringDictTest() { _dict = new StringKeyDictionary<int>(true); _dict.Add("One", 1); _dict.Add("Two", 2); }