Esempio n. 1
0
        public void TryGetTypeDisplayName_WithInnerServiceHavingResult_ReturnsResult()
        {
            var typeInformationStub = MockRepository.GenerateStub <ITypeInformation>();
            var typeInformationForResourceResolutionStub = MockRepository.GenerateStub <ITypeInformation>();

            using (_mockRepository.Ordered())
            {
                _innerService1.Expect(
                    mock => mock.TryGetTypeDisplayName(
                        Arg.Is(typeInformationStub),
                        Arg.Is(typeInformationForResourceResolutionStub),
                        out Arg <string> .Out(null).Dummy)).Return(false);
                _innerService2.Expect(
                    mock => mock.TryGetTypeDisplayName(
                        Arg.Is(typeInformationStub),
                        Arg.Is(typeInformationForResourceResolutionStub),
                        out Arg <string> .Out("The Name").Dummy)).Return(true);
                _innerService3.Expect(
                    mock => mock.TryGetTypeDisplayName(
                        Arg <ITypeInformation> .Is.Anything,
                        Arg <ITypeInformation> .Is.Anything,
                        out Arg <string> .Out(null).Dummy))
                .Repeat.Never();
            }
            _mockRepository.ReplayAll();

            string value;
            var    result = _service.TryGetTypeDisplayName(typeInformationStub, typeInformationForResourceResolutionStub, out value);

            Assert.That(result, Is.True);
            Assert.That(value, Is.EqualTo("The Name"));

            _mockRepository.VerifyAll();
        }
Esempio n. 2
0
        public void ApplyLocalization_DisplayNameIsAssigned()
        {
            _memberInformationGlobalizationServiceMock
            .Expect(
                mock => mock.TryGetPropertyDisplayName(
                    Arg <IPropertyInformation> .Matches(pi => ((PropertyInfoAdapter)pi).PropertyInfo == (PropertyInfo)_propertyRule.Member),
                    Arg <ITypeInformation> .Matches(ti => ((TypeAdapter)ti).Type == typeof(Customer)),
                    out Arg <string> .Out("LocalizedPropertyName").Dummy))
            .Return(true);
            Assert.That(_propertyRule.DisplayName, Is.TypeOf(typeof(LazyStringSource)));

            _service.ApplyMetadata(_propertyRule, typeof(Customer));

            Assert.That(_propertyRule.DisplayName, Is.Not.Null);
            Assert.That(_propertyRule.DisplayName, Is.TypeOf(typeof(PropertyRuleDisplayNameStringSource)));
            Assert.That(_propertyRule.DisplayName.GetString(), Is.EqualTo("LocalizedPropertyName"));
            _memberInformationGlobalizationServiceMock.VerifyAllExpectations();
        }