public GetDataMapper ( |
||
targetType | ||
return | IDataMapper |
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); }
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 ----------------------- }
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); }
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)); }
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); }