public void Instantiation() { DelegatingMessageSource source = new DelegatingMessageSource(); Assert.IsNotNull(source.ParentMessageSource, "ParentMessageSource property must *never* be null."); }
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)); }
public void InstantiationWithSuppliedParentMessageSource() { DelegatingMessageSource source = new DelegatingMessageSource(MockMessageSource); Assert.IsNotNull(source.ParentMessageSource, "ParentMessageSource property must *never* be null."); Assert.IsTrue(Object.ReferenceEquals(source.ParentMessageSource, MockMessageSource)); }
public void ApplyResources() { MockMessageSource.ApplyResources((object)12, "rick", CultureInfo.InvariantCulture); DelegatingMessageSource source = new DelegatingMessageSource(MockMessageSource); mocks.ReplayAll(); source.ApplyResources(12, "rick", CultureInfo.InvariantCulture); mocks.VerifyAll(); }
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(); }
public void GetResourceObjectWithCulture() { const string expectedName = "Rick Evans"; Expect.Call(MockMessageSource.GetResourceObject(LookupKey, CultureInfo.InvariantCulture)).Return(expectedName); DelegatingMessageSource source = new DelegatingMessageSource(MockMessageSource); mocks.ReplayAll(); string name = (string)source.GetResourceObject(LookupKey, CultureInfo.InvariantCulture); Assert.AreEqual(expectedName, name); mocks.VerifyAll(); }
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(); }
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(); }
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(); }
public void GetMessageNoDelegateTarget() { DelegatingMessageSource source = new DelegatingMessageSource(); Assert.Throws <NoSuchMessageException>(() => source.GetMessage(LookupKey)); }
public void ApplyResourcesWithNoParentMessageSource() { DelegatingMessageSource source = new DelegatingMessageSource(); Assert.Throws <ApplicationContextException>(() => source.ApplyResources(12, "rick", CultureInfo.InvariantCulture)); }
public void GetResourceObjectWithNoParentMessageSourceWithCulture() { DelegatingMessageSource source = new DelegatingMessageSource(); Assert.Throws <ApplicationContextException>(() => source.GetResourceObject(LookupKey, CultureInfo.InvariantCulture)); }
public void GetResourceObjectWithNoParentMessageSource() { DelegatingMessageSource source = new DelegatingMessageSource(); Assert.Throws <ApplicationContextException>(() => source.GetResourceObject(LookupKey)); }
public void GetMessageWithCultureAndParamsNoDelegateTarget() { DelegatingMessageSource source = new DelegatingMessageSource(); Assert.Throws <NoSuchMessageException>(() => source.GetMessage(LookupKey, CultureInfo.InvariantCulture, "Rick", "Evans")); }