예제 #1
0
        public void WhenCollectionIsEmpty_ShoulNotCallAnyOfTheApiTypeConverterMethods()
        {
            //Arange
            IApiTypeConverter apiTypeConverterMock = MockRepository.GenerateMock <IApiTypeConverter>();

            IObjectConverter objectConverter = new Converters.ObjectConverter(apiTypeConverterMock);

            ICollection <KeyValuePair <string, string> > emptyCollection = new List <KeyValuePair <string, string> >();

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

            //Assert
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToInt(Arg <string> .Is.Anything));
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToIntNullable(Arg <string> .Is.Anything));
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToUtcDateTimeNullable(Arg <string> .Is.Anything));
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToListOfInts(Arg <string> .Is.Anything));
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToStatus(Arg <string> .Is.Anything));
        }
예제 #2
0
        public void WhenCollectionContainsValidOrInvalidStringProperty_ShouldNotCallAnyOfTheApiTypeConverterMethods(string stringProperty)
        {
            //Arange
            IApiTypeConverter apiTypeConverterMock = MockRepository.GenerateMock <IApiTypeConverter>();

            IObjectConverter objectConverter = new Converters.ObjectConverter(apiTypeConverterMock);

            ICollection <KeyValuePair <string, string> > collection = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>(stringProperty, "some value")
            };

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

            //Assert
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToInt(Arg <string> .Is.Anything));
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToIntNullable(Arg <string> .Is.Anything));
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToUtcDateTimeNullable(Arg <string> .Is.Anything));
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToListOfInts(Arg <string> .Is.Anything));
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToStatus(Arg <string> .Is.Anything));
        }
예제 #3
0
        public void WhenCollectionContainsInvalidIntProperty_ShouldNotCallTheToIntMethod(string invalidIntPropertyName)
        {
            //Arange
            IApiTypeConverter apiTypeConverterMock = MockRepository.GenerateMock <IApiTypeConverter>();

            IObjectConverter objectConverter = new Converters.ObjectConverter(apiTypeConverterMock);

            ICollection <KeyValuePair <string, string> > collection = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>(invalidIntPropertyName, "5")
            };

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

            //Assert
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToInt(Arg <string> .Is.Anything));
        }
예제 #4
0
        public void WhenCollectionContainsInvalidNullableEnumProperty_ShouldNotCallTheToEnumNullableMethod(string invalidEnumNullableProperty)
        {
            //Arange
            IApiTypeConverter apiTypeConverterMock = MockRepository.GenerateMock <IApiTypeConverter>();

            apiTypeConverterMock.Expect(x => x.ToEnumNullable(Arg <string> .Is.Anything, Arg <Type> .Is.Anything)).IgnoreArguments();

            IObjectConverter objectConverter = new Converters.ObjectConverter(apiTypeConverterMock);

            ICollection <KeyValuePair <string, string> > collection = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>(invalidEnumNullableProperty, "some enum value")
            };

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

            //Assert
            apiTypeConverterMock.AssertWasNotCalled(x => x.ToEnumNullable(Arg <string> .Is.Anything, Arg <Type> .Is.Anything));
        }