Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 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());
 }
Ejemplo n.º 4
0
 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());
 }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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());
        }
Ejemplo n.º 7
0
        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());
        }
Ejemplo n.º 8
0
        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"));
        }
Ejemplo n.º 9
0
        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));
        }
Ejemplo n.º 10
0
        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());
        }
Ejemplo n.º 11
0
 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());
 }
Ejemplo n.º 12
0
        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"));
        }
Ejemplo n.º 13
0
        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"));
        }
Ejemplo n.º 14
0
        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());
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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"));
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        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;
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
 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));
 }
Ejemplo n.º 21
0
        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;
        }
Ejemplo n.º 22
0
        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]);
        }
Ejemplo n.º 23
0
        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);
        }
Ejemplo n.º 24
0
        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));
        }
Ejemplo n.º 25
0
        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));
        }
Ejemplo n.º 26
0
        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));
        }
Ejemplo n.º 27
0
        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);
        }
Ejemplo n.º 28
0
        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));
        }
Ejemplo n.º 29
0
        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"));
        }
Ejemplo n.º 30
0
        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());
        }
Ejemplo n.º 31
0
        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));
        }
Ejemplo n.º 32
0
        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"));
        }
Ejemplo n.º 33
0
        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"));
        }
Ejemplo n.º 34
0
        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);
        }
Ejemplo n.º 35
0
        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);
        }
Ejemplo n.º 36
0
		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;
		}
Ejemplo n.º 37
0
        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"));
        }
Ejemplo n.º 38
0
        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));
        }
Ejemplo n.º 39
0
        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;
        }