public void SelectConstructorsFromNullTypeThrows() { // Fixture setup var sut = new FactoryMethodQuery(); // Exercise system and verify outcome Assert.Throws<ArgumentNullException>(() => sut.SelectConstructors(null)); // Teardown }
public void SelectFromTypeWithNoPublicConstructorReturnsCorrectResult() { // Fixture setup var sut = new FactoryMethodQuery(); var typeWithNoPublicConstructors = typeof(AbstractType); // Exercise system var result = sut.SelectConstructors(typeWithNoPublicConstructors); // Verify outcome Assert.False(result.Any()); // Teardown }
public void SelectFromTypeReturnsCorrectResult(Type type) { // Fixture setup var expectedMethods = from mi in type.GetMethods(BindingFlags.Static | BindingFlags.Public) where mi.ReturnType == type let parameters = mi.GetParameters() orderby parameters.Length ascending select new StaticMethod(mi) as IMethod; var sut = new FactoryMethodQuery(); // Exercise system var result = sut.SelectConstructors(type); // Verify outcome Assert.True(expectedMethods.SequenceEqual(result)); // Teardown }