Пример #1
0
        public void Create_ShouldThrowNotSupportedException_WhenSpecificTypeIsPassed()
        {
            // Given
            var underTest = new ObjectCreator();

            // When
            TestDelegate instantiateInt32 = () => underTest.Create(typeof (Int32));

            // Then
            Assert.That(instantiateInt32, Throws.TypeOf<NotSupportedException>());
        }
Пример #2
0
        public void Create_ShouldCallMatchingConstructorAndReturnItsValue_WhenComplexTypeIsPassed()
        {
            // Given
            var underTest = new ObjectCreator();

            // When
            var result = underTest.Create(typeof(DummyObject)) as DummyObject;

            // Then
            Assert.That(result, Is.Not.Null);
            Assert.That(result.DummyNumber, Is.EqualTo(0));
        }
Пример #3
0
        public void Create_ShouldCallMatchingConstructorAndReturnItsValue_WhenCallingConstructorWithComplexTypeAndPrimitiveType()
        {
            // Given
            var underTest = new ObjectCreator();
            var complexType = underTest.Create(typeof (LittleBitSmarterObject), /* old value */ 23);

            // When
            var result = underTest.Create(typeof(DummyObjectDealer), /* expected value */ 32, complexType) as DummyObjectDealer;

            // Then
            Assert.That(result, Is.Not.Null);
            Assert.That(result.DummyObject, Is.Not.Null);
            Assert.That(result.DummyObject.DummyNumber, Is.EqualTo(32));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultSelectorFactory"/> class.
 /// </summary>
 public DefaultSelectorFactory()
 {
     objectCreator = new ObjectCreator();
 }