How to use SomeClass class of describe_OtherNameSpace package

Best NSpec code snippet using describe_OtherNameSpace.SomeClass

Run NSpec automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

describe_SpecFinder.cs

Source: describe_SpecFinder.cs Github

copy
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using NSpec;
5using NSpec.Domain;
6using NUnit.Framework;
7using describe_OtherNameSpace;
8using describe_SomeNameSpace;
9using Moq;
10
11namespace NSpecSpecs
12{
13    public class SpecClass : nspec
14    {
15        public void public_method() { }
16        private void private_method() { }
17    }
18
19    public class AnotherSpecClass : nspec
20    {
21        void public_method() { }
22    }
23
24    public class NonSpecClass { }
25
26    public class SpecClassWithNoVoidMethods : nspec
27    {
28        string parameter_less_method() { return ""; }
29    }
30
31    public class SpecClassWithNoParameterLessMethods : nspec
32    {
33        void private_method(string parameter) { }
34
35        public void public_method(string parameter) { }
36    }
37
38    [TestFixture]
39    [Category("SpecFinder")]
40    public class without_filtering : when_finding_specs
41    {
42        [SetUp]
43        public void setup()
44        {
45            GivenDllContains();
46        }
47
48        [Test]
49        public void it_should_get_types_from_reflection()
50        {
51            reflector.Verify(r => r.GetTypesFrom());
52        }
53
54        [Test]
55        public void it_should_include_classes_that_implement_nspec_and_have_paramterless_void_methods()
56        {
57            GivenDllContains(typeof(SpecClass));
58
59            finder.SpecClasses().should_contain(typeof(SpecClass));
60        }
61
62        [Test]
63        public void it_should_exclude_classes_that_inherit_from_nspec_but_have_no_parameterless_methods()
64        {
65            GivenDllContains(typeof(SpecClassWithNoParameterLessMethods));
66
67            finder.SpecClasses().should_be_empty();
68        }
69
70        [Test]
71        public void it_should_exclude_classes_that_do_not_inherit_from_nspec()
72        {
73            GivenDllContains(typeof(NonSpecClass));
74
75            finder.SpecClasses().should_be_empty();
76        }
77
78        [Test]
79        public void it_should_exclude_classes_that_have_no_void_methods()
80        {
81            GivenDllContains(typeof(SpecClassWithNoVoidMethods));
82
83            finder.SpecClasses().should_be_empty();
84        }
85    }
86
87    [TestFixture]
88    [Category("SpecFinder")]
89    public class when_filtering_specs : when_finding_specs
90    {
91        [Test]
92        public void it_should_filter_in()
93        {
94            GivenDllContains(typeof(AnotherSpecClass));
95
96            GivenFilter(typeof(AnotherSpecClass).Name);
97
98            finder.SpecClasses().should_contain(typeof(AnotherSpecClass));
99        }
100
101        [Test]
102        public void it_should_filter_out()
103        {
104            GivenDllContains(typeof(SpecClass));
105
106            GivenFilter(typeof(AnotherSpecClass).Name);
107
108            finder.SpecClasses().should_be_empty();
109        }
110    }
111
112    [TestFixture]
113    [Category("SpecFinder")]
114    public class when_finding_specs_based_on_regex : when_finding_specs
115    {
116        [SetUp]
117        public void Setup()
118        {
119            GivenDllContains(typeof(SomeClass),
120                typeof(SomeDerivedClass),
121                typeof(SomeClassInOtherNameSpace),
122                typeof(SomeDerivedDerivedClass));
123        }
124
125        [Test]
126        public void it_should_find_all_specs_if_regex_is_not_specified()
127        {
128            GivenFilter("");
129
130            TheSpecClasses()
131                .should_contain(typeof(SomeClass))
132                .should_contain(typeof(SomeDerivedClass))
133                .should_contain(typeof(SomeClassInOtherNameSpace));
134        }
135
136        [Test]
137        public void it_should_find_specs_for_derived_class_and_include_base_class()
138        {
139            GivenFilter("DerivedClass$");
140
141            TheSpecClasses()
142                .should_contain(typeof(SomeClass))
143                .should_contain(typeof(SomeDerivedClass))
144                .should_contain(typeof(SomeDerivedDerivedClass))
145                .should_not_contain(typeof(SomeClassInOtherNameSpace));
146
147            TheSpecClasses().Count().should_be(3);
148        }
149
150        [Test]
151        public void it_should_find_specs_that_contain_namespace()
152        {
153            GivenFilter("describe_SomeNameSpace");
154
155            TheSpecClasses()
156                .should_contain(typeof(SomeClass))
157                .should_contain(typeof(SomeDerivedClass))
158                .should_not_contain(typeof(SomeClassInOtherNameSpace));
159        }
160
161        [Test]
162        public void it_should_find_distinct_specs()
163        {
164            GivenFilter("Derived");
165
166            TheSpecClasses()
167                .should_contain(typeof(SomeClass))
168                .should_contain(typeof(SomeDerivedClass))
169                .should_contain(typeof(SomeDerivedDerivedClass));
170
171            TheSpecClasses().Count().should_be(3);
172        }
173    }
174
175    public class when_finding_specs
176    {
177        protected void GivenDllContains(params Type[] types)
178        {
179            reflector = new Mock<IReflector>();
180
181            reflector.Setup(r => r.GetTypesFrom()).Returns(types);
182
183            someDLL = "an nspec project dll";
184
185            finder = new SpecFinder(reflector.Object);
186        }
187
188        protected void GivenFilter(string filter)
189        {
190            finder = new SpecFinder(reflector.Object, filter);
191        }
192        
193        protected IEnumerable<Type> TheSpecClasses()
194        {
195            return finder.SpecClasses();
196        }
197
198        protected ISpecFinder finder;
199        protected Mock<IReflector> reflector;
200        protected string someDLL;
201    }
202}
203
204namespace describe_SomeNameSpace
205{
206    class SomeClass : nspec
207    {
208        void context_method()
209        {
210            
211        }
212    }
213
214    class SomeDerivedClass : SomeClass
215    {
216        void context_method()
217        {
218
219        }
220    }
221
222    class SomeDerivedDerivedClass : SomeClass
223    {
224        void context_method()
225        {
226
227        }
228    }
229}
230
231namespace describe_OtherNameSpace
232{
233    class SomeClassInOtherNameSpace : nspec
234    {
235        void context_method()
236        {
237
238        }
239    }
240}
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used methods in SomeClass

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)