public void Returns_HashSet_if_assignable() { var factory = new CollectionTypeFactory(); Assert.Same(typeof(HashSet <Random>), factory.TryFindTypeToInstantiate(typeof(ICollection <Random>))); Assert.Same(typeof(HashSet <Random>), factory.TryFindTypeToInstantiate(typeof(ISet <Random>))); }
public void Returns_given_type_if_public_parameterless_constructor_available() { var factory = new CollectionTypeFactory(); Assert.Same(typeof(CustomHashSet), factory.TryFindTypeToInstantiate(typeof(CustomHashSet))); Assert.Same(typeof(CustomList), factory.TryFindTypeToInstantiate(typeof(CustomList))); Assert.Same(typeof(HashSet <Random>), factory.TryFindTypeToInstantiate(typeof(HashSet <Random>))); Assert.Same(typeof(List <Random>), factory.TryFindTypeToInstantiate(typeof(List <Random>))); Assert.Same(typeof(ObservableCollection <Random>), factory.TryFindTypeToInstantiate(typeof(ObservableCollection <Random>))); }
public void Returns_null_when_no_usable_concrete_type_found() { var factory = new CollectionTypeFactory(); Assert.Null(factory.TryFindTypeToInstantiate(typeof(PrivateConstructor))); Assert.Null(factory.TryFindTypeToInstantiate(typeof(InternalConstructor))); Assert.Null(factory.TryFindTypeToInstantiate(typeof(ProtectedConstructor))); Assert.Null(factory.TryFindTypeToInstantiate(typeof(NoParameterlessConstructor))); Assert.Null(factory.TryFindTypeToInstantiate(typeof(Abstract))); Assert.Null(factory.TryFindTypeToInstantiate(typeof(object))); Assert.Null(factory.TryFindTypeToInstantiate(typeof(Random))); Assert.Null(factory.TryFindTypeToInstantiate(typeof(IEnumerable <Random>))); }