public void WhenCollectionContainsValidBooleanStatusPropertyAndPublishedValue_ShouldCallTheToStatusMethod(string booleanStatusPropertyName) { //Arange IApiTypeConverter apiTypeConverterMock = MockRepository.GenerateMock <IApiTypeConverter>(); apiTypeConverterMock.Expect(x => x.ToStatus(Arg <string> .Is.Anything)).IgnoreArguments().Return(true); IObjectConverter objectConverter = new Converters.ObjectConverter(apiTypeConverterMock); ICollection <KeyValuePair <string, string> > collection = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>(booleanStatusPropertyName, "some published value") }; //Act objectConverter.ToObject <SomeTestingObject>(collection); //Assert apiTypeConverterMock.AssertWasCalled(x => x.ToStatus(Arg <string> .Is.Anything)); }
public void WhenCollectionContainsValidNullableEnumProperty_ShouldCallTheToEnumNullableMethod(string enumNullableProperty) { //Arange IApiTypeConverter apiTypeConverterMock = MockRepository.GenerateMock <IApiTypeConverter>(); apiTypeConverterMock.Expect(x => x.ToEnumNullable(Arg <string> .Is.Anything, Arg <Type> .Is.Anything)).IgnoreArguments().Return(null); IObjectConverter objectConverter = new Converters.ObjectConverter(apiTypeConverterMock); ICollection <KeyValuePair <string, string> > collection = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>(enumNullableProperty, "some enum value") }; //Act objectConverter.ToObject <SomeTestingObject>(collection); //Assert apiTypeConverterMock.AssertWasCalled(x => x.ToEnumNullable(Arg <string> .Is.Anything, Arg <Type> .Is.Anything)); }
public void WhenCollectionContainsValidDateTimeProperty_ShouldCallTheToDateTimeNullableMethod(string dateTimePropertyName) { //Arange IApiTypeConverter apiTypeConverterMock = MockRepository.GenerateMock <IApiTypeConverter>(); apiTypeConverterMock.Expect(x => x.ToUtcDateTimeNullable(Arg <string> .Is.Anything)).IgnoreArguments().Return(DateTime.Now); IObjectConverter objectConverter = new Converters.ObjectConverter(apiTypeConverterMock); ICollection <KeyValuePair <string, string> > collection = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>(dateTimePropertyName, "2016-12-12") }; //Act objectConverter.ToObject <SomeTestingObject>(collection); //Assert apiTypeConverterMock.AssertWasCalled(x => x.ToUtcDateTimeNullable(Arg <string> .Is.Anything)); }