Exemple #1
0
        public void GetResourceObjectThatAintPreviouslyBeenAddedDoesntYieldAnything()
        {
            StaticMessageSource msgSource = new StaticMessageSource();
            TestObject          retrieved = (TestObject)
                                            msgSource.GetResourceObject("rick");

            Assert.IsNull(retrieved,
                          "Getting 'some (?) weird object out of an empty StaticMessageSource");
        }
Exemple #2
0
        public void GetResourceObjectWithCodeAssumesCurrentUICulture()
        {
            TestObject          value     = new TestObject("Rick", 30);
            StaticMessageSource msgSource = new StaticMessageSource();

            msgSource.AddObject("rick", CultureInfo.InvariantCulture, value);

            // assumes object was previously added using CultureInfo.CurrentUICulture
            TestObject retrieved = (TestObject)
                                   msgSource.GetResourceObject("rick");

            Assert.IsNull(retrieved,
                          "Object previously added to StaticMessageSource " +
                          "(using CultureInfo.InvariantCulture) was (wrongly) retrieved " +
                          "when using same lookup code.");
        }
Exemple #3
0
        public void GetResourceObjectWithCode()
        {
            TestObject          value     = new TestObject("Rick", 30);
            StaticMessageSource msgSource = new StaticMessageSource();

            msgSource.AddObject("rick", CultureInfo.CurrentUICulture, value);

            TestObject retrieved = (TestObject)
                                   msgSource.GetResourceObject("rick");

            Assert.IsNotNull(retrieved,
                             "Object previously added to StaticMessageSource was not retrieved " +
                             "when using same lookup code.");
            Assert.IsTrue(ReferenceEquals(value, retrieved),
                          "Object returned from StaticMessageSource was not the same one " +
                          "that was previously added (it must be).");
        }