GetDataMapper() public method

Returns the DataMapper for the targetType.
public GetDataMapper ( Type targetType ) : IDataMapper
targetType System.Type
return IDataMapper
Exemplo n.º 1
0
 public void GetDataMapper_ShouldReturnBoolDataMapper_WhenTargetTypeIsBool()
 {
     //---------------Set up test pack-------------------
     var factory = new DataMapperFactory();
     var targetType = typeof(bool);
     //---------------Execute Test ----------------------
     var dataMapper = factory.GetDataMapper(targetType);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<BoolDataMapper>(dataMapper);
 }
Exemplo n.º 2
0
        public void GetDataMapper_ShouldBeThreadSafeForNonStandardTypes()
        {
            //---------------Set up test pack-------------------
            var enumType = typeof(TestEnum);
            var sut = new DataMapperFactory();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            Assert.DoesNotThrow(() => Parallel.For(0, 1000, i => sut.GetDataMapper(enumType) ));

            //---------------Test Result -----------------------
        }
Exemplo n.º 3
0
 public void GetDataMapper_ShouldReturnDifferentGeneralDataMapper_WhenDifferentTypeIsAskedFor()
 {
     //---------------Set up test pack-------------------
     var factory = new DataMapperFactory();
     var targetType = typeof(TestDataMapperFactory);
     var expectedDataMapper = factory.GetDataMapper(typeof(DataMapper));
     //---------------Execute Test ----------------------
     var dataMapper = factory.GetDataMapper(targetType);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<GeneralDataMapper>(dataMapper);
     Assert.AreNotSame(expectedDataMapper, dataMapper);
 }
Exemplo n.º 4
0
 public void SetDataMapper_ShouldSetMapperForType()
 {
     //---------------Set up test pack-------------------
     var factory = new DataMapperFactory();
     var targetType = typeof(Image);
     var expectedDataMapper = new GuidDataMapper();
     //---------------Execute Test ----------------------
     factory.SetDataMapper(targetType, expectedDataMapper);
     //---------------Test Result -----------------------
     Assert.AreSame(expectedDataMapper, factory.GetDataMapper(targetType));
 }
Exemplo n.º 5
0
 public void GetDataMapper_ShouldReturnSameGeneralDataMapperEachTime_WhenSameTypeIsAskedFor()
 {
     //---------------Set up test pack-------------------
     var factory = new DataMapperFactory();
     var targetType = typeof(TestDataMapperFactory);
     var expectedDataMapper = factory.GetDataMapper(targetType);
     //---------------Execute Test ----------------------
     var dataMapper = factory.GetDataMapper(targetType);
     //---------------Test Result -----------------------
     Assert.AreSame(expectedDataMapper, dataMapper);
 }