public void DoesNotContainNull() { var lookup = new MutableLookup <string, string>(); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.IsFalse(lookup.Contains(null)); }
public void AddMultipleNull() { var values = new [] { "Foo", "Foobar" }; var lookup = new MutableLookup<string, string>(); lookup.Add (null, values); Assert.AreEqual (1, lookup.Count); Assert.IsTrue (values.SequenceEqual (lookup[null]), "S"); Assert.Throws<ArgumentNullException> (() => lookup.Add ("foo", (IEnumerable<string>)null)); }
public void AddNull() { var lookup = new MutableLookup<string, string>(); lookup.Add (null, "Foo"); Assert.AreEqual (1, lookup.Count); Assert.AreEqual (1, lookup[null].Count()); lookup.Add (null, null); Assert.AreEqual (1, lookup.Count); Assert.AreEqual (2, lookup[null].Count()); }
public void Add() { var lookup = new MutableLookup<string, string>(); lookup.Add ("F", "Foo"); Assert.AreEqual (1, lookup.Count); Assert.AreEqual ("Foo", lookup["F"].First()); lookup.Add ("F", "Foobar"); Assert.AreEqual (1, lookup.Count); Assert.AreEqual (2, lookup["F"].Count()); }
public void AddMultipleNull() { var values = new [] { "Foo", "Foobar" }; var lookup = new MutableLookup <string, string>(); lookup.Add(null, values); Assert.AreEqual(1, lookup.Count); Assert.IsTrue(values.SequenceEqual(lookup[null]), "S"); Assert.Throws <ArgumentNullException> (() => lookup.Add("foo", (IEnumerable <string>)null)); }
public void Add() { var lookup = new MutableLookup <string, string>(); lookup.Add("F", "Foo"); Assert.AreEqual(1, lookup.Count); Assert.AreEqual("Foo", lookup["F"].First()); lookup.Add("F", "Foobar"); Assert.AreEqual(1, lookup.Count); Assert.AreEqual(2, lookup["F"].Count()); }
public void AddNull() { var lookup = new MutableLookup <string, string>(); lookup.Add(null, "Foo"); Assert.AreEqual(1, lookup.Count); Assert.AreEqual(1, lookup[null].Count()); lookup.Add(null, (string)null); Assert.AreEqual(1, lookup.Count); Assert.AreEqual(2, lookup[null].Count()); }
public void DoesNotContain() { var lookup = new MutableLookup <string, string>(); lookup.Add(null, "blah"); lookup.Add(null, "monkeys"); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.IsFalse(lookup.Contains("D")); }
public void ContainsNull() { var lookup = new MutableLookup <string, string>(); lookup.Add(null, "blah"); lookup.Add(null, "monkeys"); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.IsTrue(lookup.Contains(null)); }
public void IndexerNotFound() { var lookup = new MutableLookup <string, string>(); lookup.Add(null, "blah"); lookup.Add(null, "monkeys"); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.AreEqual(0, lookup["D"].Count()); }
public void AddMultiple() { var values = new [] { "Foo", "Foobar" }; var lookup = new MutableLookup<string, string>(); lookup.Add ("key", values); Assert.AreEqual (1, lookup.Count); Assert.Contains (values[0], lookup["key"].ToList()); Assert.Contains (values[1], lookup["key"].ToList()); lookup.Add ("key2", values); Assert.AreEqual (2, lookup.Count); Assert.Contains (values[0], lookup["key2"].ToList()); Assert.Contains (values[1], lookup["key2"].ToList()); }
public void ClearWithNull() { var lookup = new MutableLookup <string, string>(); lookup.Add(null, "blah"); lookup.Add("F", "Foo"); lookup.Clear(); Assert.AreEqual(0, lookup.Count); Assert.IsFalse(lookup.Contains(null)); Assert.IsFalse(lookup.Contains("F")); }
public void ClearWithoutNull() { var lookup = new MutableLookup <string, string>(); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); lookup.Clear(); Assert.AreEqual(0, lookup.Count); Assert.IsFalse(lookup.Contains("F")); Assert.IsFalse(lookup.Contains("B")); }
public void AddMultiple() { var values = new [] { "Foo", "Foobar" }; var lookup = new MutableLookup <string, string>(); lookup.Add("key", values); Assert.AreEqual(1, lookup.Count); Assert.Contains(values[0], lookup["key"].ToList()); Assert.Contains(values[1], lookup["key"].ToList()); lookup.Add("key2", values); Assert.AreEqual(2, lookup.Count); Assert.Contains(values[0], lookup["key2"].ToList()); Assert.Contains(values[1], lookup["key2"].ToList()); }
public void CountRefType() { var lookup = new MutableLookup <string, string>(); Assert.AreEqual(0, lookup.Count); lookup.Add(null, "blah"); Assert.AreEqual(1, lookup.Count); lookup.Add("F", "Foo"); Assert.AreEqual(2, lookup.Count); lookup.Add("F", "Foobar"); Assert.AreEqual(2, lookup.Count); lookup.Remove(null, "blah"); Assert.AreEqual(1, lookup.Count); }
public void EnumeratorNull() { var lookup = new MutableLookup <string, string>(); lookup.Add(null, "blah"); lookup.Add(null, "monkeys"); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.AreEqual(3, lookup.Count()); Assert.IsTrue(lookup.Any(g => g.Key == null)); Assert.IsTrue(lookup.Any(g => g.Key == "F")); Assert.IsTrue(lookup.Any(g => g.Key == "B")); }
public void CountValueType() { var lookup = new MutableLookup <int, int>(); Assert.AreEqual(0, lookup.Count); lookup.Add(1, 10); Assert.AreEqual(1, lookup.Count); lookup.Add(2, 20); Assert.AreEqual(2, lookup.Count); lookup.Add(2, 21); Assert.AreEqual(2, lookup.Count); lookup.Remove(1, 10); Assert.AreEqual(1, lookup.Count); }
private void SetupNotifications() { if (this.notifications != null) { this.notifications.Close(); this.notifications = null; } this.notifications = new NotificationHandler(this.gablarski); var enabledSpeech = new MutableLookup <ITextToSpeech, NotificationType>(); foreach (var enabled in Settings.EnabledNotifications) { Type type = Type.GetType(enabled.Key); if (type == null) { LogManager.GetLogger("Notifications").WarnFormat("Notifier {0} not found", enabled.Key); continue; } object n = Activator.CreateInstance(type); var notifier = n as INotifier; if (notifier != null) { this.notifications.AddNotifier(notifier, enabled); } else if (n is ITextToSpeech) { enabledSpeech.Add((ITextToSpeech)n, enabled); } } if (enabledSpeech.Count > 0) { foreach (var enabled in enabledSpeech) { ITextToSpeech tts = enabled.Key; tts.Media = this.mediaPlayerIntegration; var format = tts.SupportedFormats.OrderByDescending(af => af.SampleRate).FirstOrDefault(); if (format == null) { format = new AudioFormat(WaveFormatEncoding.LPCM, 1, 16, 44100); } var source = this.gablarski.Sources.CreateFake("speech", format, (short)(format.SampleRate / 100)); this.speechSources.Add(tts, source); tts.AudioSource = source; this.gablarski.Audio.Attach(this.audioPlayback, source, new AudioEnginePlaybackOptions()); this.notifications.AddNotifier(tts, enabled); } this.notifications.SpeechReceiver = this.gablarski.Sources; } this.notifications.MediaController = this.mediaPlayerIntegration; }
public void RemoveNonExisting() { var lookup = new MutableLookup <string, string>(); lookup.Add(null, "blah"); lookup.Add(null, "monkeys"); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.IsFalse(lookup.Remove("D")); Assert.AreEqual(3, lookup.Count); Assert.IsFalse(lookup.Remove("F", "asdf")); Assert.AreEqual(3, lookup.Count); lookup.Remove(null); Assert.IsFalse(lookup.Remove(null)); Assert.AreEqual(2, lookup.Count); }
public override bool Autoload(ref string name, ref string texture) { if (Plants == null) { Plants = new MutableLookup <int, PlantTile>(); } foreach (var tileType in GrowthTiles) { Plants.Add(tileType, this); } return(base.Autoload(ref name, ref texture)); }
public void UpdateSettings() { Settings.EnableNotifications = NotificationsEnabled; var notifications = new MutableLookup <string, NotificationType>(); foreach (var notifier in Notifiers.Where(vm => vm.IsEnabled)) { string name = notifier.Notifier.GetType().GetSimpleName(); notifications.Add(name, this.globalNotifications[name].Where(vm => vm.IsEnabled).Select(vm => vm.Type)); } Settings.EnabledNotifications = notifications; }
public void Test() { MutableLookup <string, int> lookup = new MutableLookup <string, int>(); lookup.Add("A", 001); lookup.Add("A", 002); lookup.Add("A", 003); lookup.Add("B", 004); lookup.Add("B", 005); lookup.Add("A", 006); lookup.Add("C", 007); lookup.Add("C", 008); lookup.Add(null, 008); List <int> list = lookup["A"].ToList(); Assert.AreEqual(4, list.Count); Assert.AreEqual(1, list[0]); Assert.AreEqual(2, list[1]); Assert.AreEqual(3, list[2]); Assert.AreEqual(6, list[3]); }
public MutableLookup <string, string> GetTestLookup() { var lookup = new MutableLookup <string, string>(); lookup.Add(null, (string)null); lookup.Add(null, "blah"); lookup.Add(null, "monkeys"); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); return(lookup); }
public void ClearValueType() { var lookup = new MutableLookup<int, int>(); lookup.Add (1, 10); lookup.Add (1, 12); lookup.Add (1, 13); lookup.Add (2, 21); lookup.Add (2, 22); lookup.Add (2, 23); lookup.Clear(); Assert.AreEqual (0, lookup.Count); Assert.IsFalse (lookup.Contains (1)); Assert.IsFalse (lookup.Contains (2)); }
public void NullGroupingEnumerator() { var lookup = new MutableLookup <string, string>(); lookup.Add(null, null); lookup.Add(null, "blah"); lookup.Add(null, "monkeys"); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.AreEqual(3, lookup[null].Count()); Assert.IsTrue(lookup[null].Any(s => s == "blah")); Assert.IsTrue(lookup[null].Any(s => s == "monkeys")); Assert.IsTrue(lookup[null].Any(s => s == null)); }
public void ClearValueType() { var lookup = new MutableLookup <int, int>(); lookup.Add(1, 10); lookup.Add(1, 12); lookup.Add(1, 13); lookup.Add(2, 21); lookup.Add(2, 22); lookup.Add(2, 23); lookup.Clear(); Assert.AreEqual(0, lookup.Count); Assert.IsFalse(lookup.Contains(1)); Assert.IsFalse(lookup.Contains(2)); }
public void RemoveNonExisting() { var lookup = new MutableLookup<string, string>(); lookup.Add(null, "blah"); lookup.Add(null, "monkeys"); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.IsFalse (lookup.Remove ("D")); Assert.AreEqual(3, lookup.Count); Assert.IsFalse (lookup.Remove ("F", "asdf")); Assert.AreEqual(3, lookup.Count); lookup.Remove (null); Assert.IsFalse (lookup.Remove (null)); Assert.AreEqual (2, lookup.Count); }
public void ContainsNull() { var lookup = new MutableLookup<string, string>(); lookup.Add(null, "blah"); lookup.Add(null, "monkeys"); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.IsTrue (lookup.Contains (null)); }
public void EnumeratorNull() { var lookup = new MutableLookup<string, string>(); lookup.Add (null, "blah"); lookup.Add (null, "monkeys"); lookup.Add ("F", "Foo"); lookup.Add ("F", "Foobar"); lookup.Add ("B", "Bar"); Assert.AreEqual (3, lookup.Count()); Assert.IsTrue (lookup.Any (g => g.Key == null)); Assert.IsTrue (lookup.Any (g => g.Key == "F")); Assert.IsTrue (lookup.Any (g => g.Key == "B")); }
public void IndexerNull() { var lookup = new MutableLookup<string, string>(); lookup.Add(null, "blah"); lookup.Add(null, "monkeys"); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.AreEqual (2, lookup[null].Count()); }
public void NullGroupingEnumerator() { var lookup = new MutableLookup<string, string>(); lookup.Add (null, null); lookup.Add (null, "blah"); lookup.Add (null, "monkeys"); lookup.Add ("F", "Foo"); lookup.Add ("F", "Foobar"); lookup.Add ("B", "Bar"); Assert.AreEqual (3, lookup[null].Count()); Assert.IsTrue (lookup[null].Any (s => s == "blah")); Assert.IsTrue (lookup[null].Any (s => s == "monkeys")); Assert.IsTrue (lookup[null].Any (s => s == null)); }
public void ClearWithoutNull() { var lookup = new MutableLookup<string, string>(); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); lookup.Clear(); Assert.AreEqual (0, lookup.Count); Assert.IsFalse (lookup.Contains ("F")); Assert.IsFalse (lookup.Contains ("B")); }
public void ClearWithNull() { var lookup = new MutableLookup<string, string>(); lookup.Add (null, "blah"); lookup.Add ("F", "Foo"); lookup.Clear(); Assert.AreEqual (0, lookup.Count); Assert.IsFalse (lookup.Contains (null)); Assert.IsFalse (lookup.Contains ("F")); }
public void CountRefType() { var lookup = new MutableLookup<string, string>(); Assert.AreEqual (0, lookup.Count); lookup.Add (null, "blah"); Assert.AreEqual (1, lookup.Count); lookup.Add ("F", "Foo"); Assert.AreEqual (2, lookup.Count); lookup.Add ("F", "Foobar"); Assert.AreEqual (2, lookup.Count); lookup.Remove (null, "blah"); Assert.AreEqual (1, lookup.Count); }
public void CountValueType() { var lookup = new MutableLookup<int, int>(); Assert.AreEqual (0, lookup.Count); lookup.Add (1, 10); Assert.AreEqual (1, lookup.Count); lookup.Add (2, 20); Assert.AreEqual (2, lookup.Count); lookup.Add (2, 21); Assert.AreEqual (2, lookup.Count); lookup.Remove (1, 10); Assert.AreEqual(1, lookup.Count); }
private void SetupNotifications () { if (this.notifications != null) { this.notifications.Close(); this.notifications = null; } this.notifications = new NotificationHandler (this.gablarski); var enabledSpeech = new MutableLookup<ITextToSpeech, NotificationType>(); foreach (var enabled in Settings.EnabledNotifications) { Type type = Type.GetType (enabled.Key); if (type == null) { LogManager.GetLogger ("Notifications").WarnFormat ("Notifier {0} not found", enabled.Key); continue; } object n = Activator.CreateInstance (type); var notifier = n as INotifier; if (notifier != null) this.notifications.AddNotifier (notifier, enabled); else if (n is ITextToSpeech) enabledSpeech.Add ((ITextToSpeech) n, enabled); } if (enabledSpeech.Count > 0) { foreach (var enabled in enabledSpeech) { ITextToSpeech tts = enabled.Key; tts.Media = this.mediaPlayerIntegration; var format = tts.SupportedFormats.OrderByDescending (af => af.SampleRate).FirstOrDefault(); if (format == null) format = new AudioFormat (WaveFormatEncoding.LPCM, 1, 16, 44100); var source = this.gablarski.Sources.CreateFake ("speech", format, (short)(format.SampleRate / 100)); this.speechSources.Add (tts, source); tts.AudioSource = source; this.gablarski.Audio.Attach (this.audioPlayback, source, new AudioEnginePlaybackOptions()); this.notifications.AddNotifier (tts, enabled); } this.notifications.SpeechReceiver = this.gablarski.Sources; } this.notifications.MediaController = this.mediaPlayerIntegration; }
public void DoesNotContain() { var lookup = new MutableLookup<string, string>(); lookup.Add(null, "blah"); lookup.Add(null, "monkeys"); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.IsFalse (lookup.Contains ("D")); }
public void DoesNotContainNull() { var lookup = new MutableLookup<string, string>(); lookup.Add("F", "Foo"); lookup.Add("F", "Foobar"); lookup.Add("B", "Bar"); Assert.IsFalse (lookup.Contains (null)); }
internal MutableLookup<string, string> GetTestLookup() { var lookup = new MutableLookup<string, string>(); lookup.Add (null, (string)null); lookup.Add (null, "blah"); lookup.Add (null, "monkeys"); lookup.Add ("F", "Foo"); lookup.Add ("F", "Foobar"); lookup.Add ("B", "Bar"); return lookup; }
public void UpdateSettings() { Settings.EnableNotifications = NotificationsEnabled; var notifications = new MutableLookup<string, NotificationType>(); foreach (var notifier in Notifiers.Where (vm => vm.IsEnabled)) { string name = notifier.Notifier.GetType().GetSimpleName(); notifications.Add (name, this.globalNotifications[name].Where (vm => vm.IsEnabled).Select (vm => vm.Type)); } Settings.EnabledNotifications = notifications; }