Best NSpec code snippet using describe_OtherNameSpace.SomeDerivedDerivedClass
describe_SpecFinder.cs
Source:describe_SpecFinder.cs
...95 {96 GivenDllContains(typeof(SomeClass),97 typeof(SomeDerivedClass),98 typeof(SomeClassInOtherNameSpace),99 typeof(SomeDerivedDerivedClass));100 }101 [Test]102 public void it_should_find_all_specs_if_regex_is_not_specified()103 {104 GivenFilter("");105 TheSpecClasses()106 .should_contain(typeof(SomeClass))107 .should_contain(typeof(SomeDerivedClass))108 .should_contain(typeof(SomeClassInOtherNameSpace));109 }110 [Test]111 public void it_should_find_specs_for_derived_class_and_include_base_class()112 {113 GivenFilter("DerivedClass$");114 TheSpecClasses()115 .should_contain(typeof(SomeClass))116 .should_contain(typeof(SomeDerivedClass))117 .should_contain(typeof(SomeDerivedDerivedClass))118 .should_not_contain(typeof(SomeClassInOtherNameSpace));119 TheSpecClasses().Count().should_be(3);120 }121 [Test]122 public void it_should_find_specs_that_contain_namespace()123 {124 GivenFilter("describe_SomeNameSpace");125 TheSpecClasses()126 .should_contain(typeof(SomeClass))127 .should_contain(typeof(SomeDerivedClass))128 .should_not_contain(typeof(SomeClassInOtherNameSpace));129 }130 [Test]131 public void it_should_find_distinct_specs()132 {133 GivenFilter("Derived");134 TheSpecClasses()135 .should_contain(typeof(SomeClass))136 .should_contain(typeof(SomeDerivedClass))137 .should_contain(typeof(SomeDerivedDerivedClass));138 TheSpecClasses().Count().should_be(3);139 }140 }141 public class when_finding_specs142 {143 protected void GivenDllContains(params Type[] types)144 {145 reflector = new Mock<IReflector>();146 reflector.Setup(r => r.GetTypesFrom()).Returns(types);147 someDLL = "an nspec project dll";148 finder = new SpecFinder(reflector.Object);149 }150 protected void GivenFilter(string filter)151 {152 finder = new SpecFinder(reflector.Object, filter);153 }154 155 protected IEnumerable<Type> TheSpecClasses()156 {157 return finder.SpecClasses();158 }159 protected ISpecFinder finder;160 protected Mock<IReflector> reflector;161 protected string someDLL;162 }163}164namespace describe_SomeNameSpace165{166 class SomeClass : nspec167 {168 void context_method()169 {170 171 }172 }173 class SomeDerivedClass : SomeClass174 {175 void context_method()176 {177 }178 }179 class SomeDerivedDerivedClass : SomeClass180 {181 void context_method()182 {183 }184 }185}186namespace describe_OtherNameSpace187{188 class SomeClassInOtherNameSpace : nspec189 {190 void context_method()191 {192 }193 }...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!