Example #1
0
        public void InstantiationWithASingleCodeDefaultsToEmptyDefaultMessage()
        {
            DefaultMessageSourceResolvable dmr = new DefaultMessageSourceResolvable("foo");

            Assert.AreEqual(string.Empty, dmr.DefaultMessage,
                            "Not defaulting to non null empty string value (it must).");
        }
Example #2
0
        public void ResolvableToStringNullArguments()
        {
            string[] codes                     = new string[] { "code1", "code2" };
            string   defaultMessage            = "defaultMessage";
            DefaultMessageSourceResolvable dmr = new DefaultMessageSourceResolvable(codes, null, defaultMessage);

            Assert.AreEqual(getResolvableStringNull(), dmr.ToString(), "to string");
        }
        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));
        }
Example #4
0
        public void ResolvableToString()
        {
            string[] codes                     = new string[] { "code1", "code2" };
            object[] arguments                 = new object[] { "argument1", "argument2" };
            string   defaultMessage            = "defaultMessage";
            DefaultMessageSourceResolvable dmr = new DefaultMessageSourceResolvable(codes, arguments, defaultMessage);

            Assert.AreEqual(getResolvableString(), dmr.ToString(), "to string");
        }
Example #5
0
        public void DefaultResolvableFromExistingResolvable()
        {
            IMessageSourceResolvable res = mocks.StrictMock <IMessageSourceResolvable>();

            Expect.Call(res.DefaultMessage).Return("defaultMessageFromMock").Repeat.AtLeastOnce();
            Expect.Call(res.GetCodes()).Return(new string[] { "code1FromMock" });
            Expect.Call(res.GetArguments()).Return(new object[] { "ArgumentFromMock" }).Repeat.AtLeastOnce();
            mocks.ReplayAll();
            DefaultMessageSourceResolvable dmr = new DefaultMessageSourceResolvable(res);

            Assert.AreEqual("defaultMessageFromMock", dmr.DefaultMessage, "default");
            Assert.AreEqual("code1FromMock", dmr.LastCode, "codes");
            Assert.AreEqual("ArgumentFromMock", (dmr.GetArguments())[0], "arguments");
            mocks.VerifyAll();
        }
Example #6
0
        public void LastCode()
        {
            DefaultMessageSourceResolvable dmr = new DefaultMessageSourceResolvable(new string[] { "code1" }, null);

            Assert.AreEqual("code1", dmr.LastCode);
        }
Example #7
0
        public void NullLastCode()
        {
            DefaultMessageSourceResolvable dmr = new DefaultMessageSourceResolvable(null, null);

            Assert.IsNull(dmr.LastCode);
        }