Пример #1
0
        public void SetUp()
        {
            _globalizationServiceMock = MockRepository.GenerateStub <IGlobalizationService>();
            _resourceManagerMock      = MockRepository.GenerateStrictMock <IResourceManager>();
            _resourceManagerMock.Stub(stub => stub.IsNull).Return(false);
            _resourceManagerMock.Stub(stub => stub.Name).Return("RM1");

            _typeInformationStub = MockRepository.GenerateStub <ITypeInformation>();
            _typeInformationStub.Stub(stub => stub.Name).Return("TypeName");

            _typeInformationForResourceResolutionStub = MockRepository.GenerateStub <ITypeInformation>();
            _typeInformationForResourceResolutionStub.Stub(stub => stub.Name).Return("TypeNameForResourceResolution");

            _propertyInformationStub = MockRepository.GenerateStub <IPropertyInformation>();
            _propertyInformationStub.Stub(stub => stub.Name).Return("PropertyName");

            _memberInformationNameResolverStub = MockRepository.GenerateStub <IMemberInformationNameResolver>();
            _memberInformationNameResolverStub.Stub(stub => stub.GetPropertyName(_propertyInformationStub)).Return("FakePropertyFullName");
            _memberInformationNameResolverStub.Stub(stub => stub.GetTypeName(_typeInformationStub)).Return("FakeTypeFullName");

            _shortPropertyResourceID = "property:PropertyName";
            _longPropertyResourceID  = "property:FakePropertyFullName";
            _shortTypeResourceID     = "type:TypeName";
            _longTypeResourceID      = "type:FakeTypeFullName";

            _service = new ResourceManagerBasedMemberInformationGlobalizationService(_globalizationServiceMock, _memberInformationNameResolverStub);
        }
Пример #2
0
        public void TryGetEnumerationValueDisplayName_WithResourceManager()
        {
            var resourceManagerStub = MockRepository.GenerateStub <IResourceManager>();

            resourceManagerStub.Stub(_ => _.IsNull).Return(false);
            resourceManagerStub.Stub(_ => _.TryGetString(Arg.Is("enumName"), out Arg <string> .Out("expected").Dummy)).Return(true);

            _globalizationServiceStub.Stub(_ => _.GetResourceManager(TypeAdapter.Create(typeof(EnumWithResources)))).Return(resourceManagerStub);
            _memberInformationNameResolverStub.Stub(_ => _.GetEnumName(EnumWithResources.Value1)).Return("enumName");

            string resourceValue;

            Assert.That(_service.TryGetEnumerationValueDisplayName(EnumWithResources.Value1, out resourceValue), Is.True);
            Assert.That(resourceValue, Is.EqualTo("expected"));
        }