public void IfItemIsNotNullAddItToTheList() { var itemUnderTest = new TypeUnderTest{Name="Name", Address= "Address"}; var listUnderTest = new List<TypeUnderTest>(); listUnderTest.AddIfNotNull(itemUnderTest); Assert.IsTrue(listUnderTest.Contains(itemUnderTest)); }
public IEnumerable <IMethodInfo> EnumerateTestMethods() { foreach (var method in TypeUnderTest.GetMethods()) { if (IsTestMethod(method)) { yield return(method); } } }
/// <summary> /// Validate the type under test before any actual operation is done. /// /// Exception will be thrown if the validation failed. The thrown exception /// is expected be caught in external frame. /// </summary> private void ValidateTypeUnderTest() { // check framework attribute if (NuwaTestClassCommand.GetNuwaFrameworkAttr(this) == null) { throw new InvalidOperationException( string.Format( "The test class must be marked by {0}.", typeof(NuwaFrameworkAttribute).Name)); } // check configuration method attribute var configMethodAttr = TypeUnderTest.GetCustomAttributes <NuwaConfigurationAttribute>(); if (configMethodAttr.Length > 1) { throw new InvalidOperationException( string.Format("More than two methods are marked by {0}.", typeof(NuwaConfigurationAttribute).Name)); } }
public IEnumerable <IMethodInfo> EnumerateTestMethods() { return(TypeUnderTest.GetMethods().Where(IsTestMethod)); }
public IEnumerable <IMethodInfo> EnumerateTestMethods() { return(from method in TypeUnderTest.GetMethods() where IsTestMethod(method) select method); }