Example #1
0
        public void GetString_ErrorMessageServiceReturnsNotNull_ReturnsErrorMessageFromService()
        {
            _validatorGlobalizationServiceMock.Expect(mock => mock.GetErrorMessage(_propertyValidator)).Return("FakeMessage");

            var result = _stringSource.GetString();

            _validatorGlobalizationServiceMock.VerifyAllExpectations();
            Assert.That(result, Is.EqualTo("FakeMessage"));
        }
Example #2
0
        public void ApplyLocalization_ResourceNotFound_NoDefaultMessageAssigned()
        {
            _defaultMessageEvaluatorMock.Expect(mock => mock.HasDefaultMessageAssigned(_validator1)).Return(false);
            _defaultMessageEvaluatorMock.Expect(mock => mock.HasDefaultMessageAssigned(_validator2)).Return(false);
            _defaultMessageEvaluatorMock.Expect(mock => mock.HasDefaultMessageAssigned(_validator3)).Return(false);

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

            _defaultMessageEvaluatorMock.VerifyAllExpectations();
            Assert.That(_validator1.ErrorMessageSource, Is.SameAs(_errorMessageSource1));
            Assert.That(_validator2.ErrorMessageSource, Is.SameAs(_errorMessageSource2));
            Assert.That(_validator3.ErrorMessageSource, Is.SameAs(_errorMessageSource3));
            _validatorGlobalizationServiceMock.VerifyAllExpectations(); //lazy evaluation => has to placed after the assertions!
        }