public void Array() { var customAttributeNamedArgumentMock = MockRepository.GenerateStrictMock <ICustomAttributeNamedArgument> (); var input = new object[] { "str", 7 }; var output = "output"; customAttributeNamedArgumentMock .Expect(x => x.MemberType) .Return(typeof(object[])); customAttributeNamedArgumentMock .Expect(x => x.Value) .Return(input); Func <Type, object, object> elementConstructor = (type, value) => value; Func <Type, IEnumerable <object>, object> arrayConstructor = (type, enumerable) => { Assert.That(type, Is.EqualTo(typeof(object))); Assert.That(enumerable, Is.EquivalentTo(input)); return(output); }; var result = ICustomAttributeDataExtensions.ConvertTo(customAttributeNamedArgumentMock, elementConstructor, arrayConstructor); Assert.That(result, Is.SameAs(output)); customAttributeNamedArgumentMock.VerifyAllExpectations(); }
public void Element() { var customAttributeNamedArgumentMock = MockRepository.GenerateStrictMock <ICustomAttributeNamedArgument> (); var input = "test"; var output = "output"; customAttributeNamedArgumentMock .Expect(x => x.MemberType) .Return(typeof(string)); customAttributeNamedArgumentMock .Expect(x => x.Value) .Return(input); Func <Type, object, object> elementConstructor = (type, value) => { Assert.That(type, Is.EqualTo(typeof(string))); Assert.That(value, Is.SameAs(input)); return(output); }; Func <Type, IEnumerable <object>, object> arrayConstructor = (type, enumerable) => { throw new Exception("should not get here"); }; var result = ICustomAttributeDataExtensions.ConvertTo(customAttributeNamedArgumentMock, elementConstructor, arrayConstructor); Assert.That(result, Is.SameAs(output)); customAttributeNamedArgumentMock.VerifyAllExpectations(); }