コード例 #1
0
        public void GetMessageWithNoParentMessageSourceAndNullDefaultMessageSourceResolvableAndCulture()
        {
            IMessageSourceResolvable resolver = new DefaultMessageSourceResolvable(
                new string[] { "foo" }, new object[] {}, string.Empty);
            DelegatingMessageSource source = new DelegatingMessageSource();

            Assert.Throws <NoSuchMessageException>(() => source.GetMessage(resolver, CultureInfo.InvariantCulture));
        }
コード例 #2
0
        public void GetMessage()
        {
            const string expectedName = "Rick Evans";

            Expect.Call(MockMessageSource.GetMessage(LookupKey)).Return(expectedName);
            DelegatingMessageSource source
                = new DelegatingMessageSource(MockMessageSource);

            mocks.ReplayAll();
            string name = source.GetMessage(LookupKey);

            Assert.AreEqual(expectedName, name);
            mocks.VerifyAll();
        }
コード例 #3
0
        public void GetMessageWithMessageSourceResolvableAndCulture()
        {
            const string            expectedName = "Rick Evans";
            DelegatingMessageSource source
                = new DelegatingMessageSource(MockMessageSource);

            Expect.Call(MockMessageSource.GetMessage((IMessageSourceResolvable)null, CultureInfo.InvariantCulture)).Return(expectedName);
            mocks.ReplayAll();
            string name = source.GetMessage(
                (IMessageSourceResolvable)null, CultureInfo.InvariantCulture);

            Assert.AreEqual(expectedName, name);
            mocks.VerifyAll();
        }
コード例 #4
0
        public void GetMessageWithCultureAndParams()
        {
            const string expectedName = "Rick Evans";

            Expect.Call(MockMessageSource.GetMessage(LookupKey, CultureInfo.InvariantCulture, new string[] { "Rick", "Evans" }))
            .Return(expectedName);
            DelegatingMessageSource source
                = new DelegatingMessageSource(MockMessageSource);

            mocks.ReplayAll();
            string name = source.GetMessage(LookupKey, CultureInfo.InvariantCulture, "Rick", "Evans");

            Assert.AreEqual(expectedName, name);
            mocks.VerifyAll();
        }
コード例 #5
0
        public void GetMessageWithNoParentMessageSourceAndMessageSourceResolvableAndCulture()
        {
            const string expectedName = "Rick Evans";

            IMessageSourceResolvable resolvable = mocks.StrictMock <IMessageSourceResolvable>();

            Expect.Call(resolvable.DefaultMessage).Return(expectedName);
            Expect.Call(resolvable.DefaultMessage).Return(expectedName);

            DelegatingMessageSource source = new DelegatingMessageSource();

            mocks.ReplayAll();
            string name = source.GetMessage(resolvable, CultureInfo.InvariantCulture);

            Assert.AreEqual(expectedName, name);
            //mock.Verify();
            mocks.VerifyAll();
        }
コード例 #6
0
        public void GetMessageNoDelegateTarget()
        {
            DelegatingMessageSource source = new DelegatingMessageSource();

            Assert.Throws <NoSuchMessageException>(() => source.GetMessage(LookupKey));
        }
コード例 #7
0
        public void GetMessageWithCultureAndParamsNoDelegateTarget()
        {
            DelegatingMessageSource source = new DelegatingMessageSource();

            Assert.Throws <NoSuchMessageException>(() => source.GetMessage(LookupKey, CultureInfo.InvariantCulture, "Rick", "Evans"));
        }