コード例 #1
0
        public void WhenCollectionContainsValidIntProperty_ShouldCallTheToIntMethod(string intPropertyName)
        {
            //Arange
            int expectedInt = 5;
            IApiTypeConverter apiTypeConverterMock = MockRepository.GenerateMock <IApiTypeConverter>();

            apiTypeConverterMock.Expect(x => x.ToInt(Arg <string> .Is.Anything)).IgnoreArguments().Return(expectedInt);

            IObjectConverter objectConverter = new Converters.ObjectConverter(apiTypeConverterMock);

            ICollection <KeyValuePair <string, string> > collection = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>(intPropertyName, expectedInt.ToString())
            };

            //Act
            objectConverter.ToObject <SomeTestingObject>(collection);

            //Assert
            apiTypeConverterMock.VerifyAllExpectations();
        }