public void Messages_HasAllMessages()
        {
            var source1 = Substitute.For <IMessageSource>();

            source1.Messages.Returns(
                ImmutableDictionary.CreateRange <string, string>(new[]
            {
                new KeyValuePair <string, string>("hello", "ahoj"),
                new KeyValuePair <string, string>("coffee", "kafe")
            }));

            var source2 = Substitute.For <IMessageSource>();

            source2.Messages.Returns(
                ImmutableDictionary.CreateRange <string, string>(new[]
            {
                new KeyValuePair <string, string>("coffee", "kava")
            }));

            var sut = new CompositeMessageSource(new[] { source1, source2 });

            var expected = new[]
            {
                new KeyValuePair <string, string>("hello", "ahoj"),
                new KeyValuePair <string, string>("coffee", "kava")
            };

            Assert.Equal(expected.Length, sut.Messages.Count);
            Assert.True(sut.Messages.All(x => expected.Contains(x)));
        }
Exemple #2
0
        private void DoReload()
        {
            var newLocaleSources = new Dictionary <string, IMessageSource>();

            foreach (var factoriesByLocale in localeMessageSourceFactories.GroupBy(x => x.LocaleCode))
            {
                var messageSource = new CompositeMessageSource(
                    factoriesByLocale
                    .OrderBy(x => x.Priority)
                    .Select(x => x.MessageSource));
                newLocaleSources[factoriesByLocale.Key] = messageSource;
            }

            localeSources = newLocaleSources;
        }