How to use child class of NSpec.Tests package

Best NSpec code snippet using NSpec.Tests.child

Context.cs

Source:Context.cs Github

copy

Full Screen

...24 public IEnumerable<ExampleBase> Failures()25 {26 return AllExamples().Where(e => e.Exception != null);27 }28 public void AddContext(Context child)29 {30 child.Level = Level + 1;31 child.Parent = this;32 child.Tags.AddRange(Tags);33 Contexts.Add(child);34 }35 /// <summary>36 /// Test execution happens in three phases: this is the first phase.37 /// </summary>38 /// <remarks>39 /// Here all contexts and all their examples are run, collecting distinct exceptions40 /// from context itself (befores/ acts/ it/ afters), beforeAll, afterAll.41 /// </remarks>42 public virtual void Run(bool failFast, nspec instance = null, bool recurse = true)43 {44 if (failFast && Parent.HasAnyFailures()) return;45 var runningInstance = builtInstance ?? instance;46 using (new ConsoleCatcher(output => this.CapturedOutput = output))47 {...

Full Screen

Full Screen

describe_Context.cs

Source:describe_Context.cs Github

copy

Full Screen

...21 [Category("Context")]22 public class when_counting_failures23 {24 [Test]25 public void given_nested_contexts_and_the_child_has_a_failure()26 {27 var child = new Context("child");28 child.AddExample(new ExampleBaseWrap { Exception = new KnownException() });29 var parent = new Context("parent");30 parent.AddContext(child);31 parent.Failures().Count().Should().Be(1);32 }33 }34 [TestFixture]35 [Category("Context")]36 public class when_creating_act_contexts_for_derived_class37 {38 public class child_act : parent_act39 {40 void act_each()41 {42 actResult += "child";43 }44 }45 public class parent_act : nspec46 {47 public string actResult;48 void act_each()49 {50 actResult = "parent";51 }52 }53 [SetUp]54 public void setup()55 {56 parentContext = new ClassContext(typeof(parent_act));57 childContext = new ClassContext(typeof(child_act));58 parentContext.AddContext(childContext);59 instance = new child_act();60 parentContext.Build();61 }62 [Test]63 public void should_run_the_acts_in_the_right_order()64 {65 childContext.ActChain.Run(instance);66 instance.actResult.Should().Be("parentchild");67 }68 ClassContext childContext, parentContext;69 child_act instance;70 }71 [TestFixture]72 [Category("Context")]73 public class when_creating_contexts_for_derived_classes74 {75 public class child_before : parent_before76 {77 void before_each()78 {79 beforeResult += "child";80 }81 }82 public class parent_before : nspec83 {84 public string beforeResult;85 void before_each()86 {87 beforeResult = "parent";88 }89 }90 [SetUp]91 public void setup()92 {93 conventions = new DefaultConventions();94 conventions.Initialize();95 parentContext = new ClassContext(typeof(parent_before), conventions);96 childContext = new ClassContext(typeof(child_before), conventions);97 parentContext.AddContext(childContext);98 }99 [Test]100 public void the_root_context_should_be_the_parent()101 {102 parentContext.Name.Should().Be(typeof(parent_before).Name.Replace("_", " "));103 }104 [Test]105 public void it_should_have_the_child_as_a_context()106 {107 parentContext.Contexts.First().Name.Should().Be(typeof(child_before).Name.Replace("_", " "));108 }109 private ClassContext childContext;110 private DefaultConventions conventions;111 private ClassContext parentContext;112 }113 [TestFixture]114 [Category("Context")]115 public class when_creating_before_contexts_for_derived_class116 {117 public class child_before : parent_before118 {119 void before_each()120 {121 beforeResult += "child";122 }123 }124 public class parent_before : nspec125 {126 public string beforeResult;127 void before_each()128 {129 beforeResult = "parent";130 }131 }132 [SetUp]133 public void setup()134 {135 parentContext = new ClassContext(typeof(parent_before));136 childContext = new ClassContext(typeof(child_before));137 parentContext.AddContext(childContext);138 instance = new child_before();139 parentContext.Build();140 }141 [Test]142 public void should_run_the_befores_in_the_proper_order()143 {144 childContext.BeforeChain.Run(instance);145 instance.beforeResult.Should().Be("parentchild");146 }147 ClassContext childContext, parentContext;148 child_before instance;149 }150 public abstract class trimming_contexts151 {152 protected Context rootContext;153 [SetUp]154 public void SetupBase()155 {156 rootContext = new Context("root context");157 }158 public Context GivenContextWithNoExamples()159 {160 return new Context("context with no example");161 }162 public Context GivenContextWithExecutedExample()163 {164 var context = new Context("context with example");165 context.AddExample(new ExampleBaseWrap("example"));166 context.Examples[0].HasRun = true;167 return context;168 }169 }170 [TestFixture]171 [Category("Context")]172 public class trimming_unexecuted_contexts_one_level_deep : trimming_contexts173 {174 Context contextWithExample;175 Context contextWithoutExample;176 [SetUp]177 public void given_nested_contexts_with_and_without_executed_examples()178 {179 contextWithoutExample = GivenContextWithNoExamples();180 rootContext.AddContext(contextWithoutExample);181 contextWithExample = GivenContextWithExecutedExample();182 rootContext.AddContext(contextWithExample);183 rootContext.Contexts.Count().Should().Be(2);184 rootContext.TrimSkippedDescendants();185 }186 [Test]187 public void it_contains_context_with_example()188 {189 rootContext.AllContexts().Should().Contain(contextWithExample);190 }191 [Test]192 public void it_doesnt_contain_empty_context()193 {194 rootContext.AllContexts().Should().NotContain(contextWithoutExample);195 }196 }197 [TestFixture]198 [Category("Context")]199 public class trimming_unexecuted_contexts_two_levels_deep : trimming_contexts200 {201 Context childContext;202 Context parentContext;203 public void GivenContextWithAChildContextThatHasExample()204 {205 parentContext = GivenContextWithNoExamples();206 childContext = GivenContextWithExecutedExample();207 parentContext.AddContext(childContext);208 rootContext.AddContext(parentContext);209 rootContext.AllContexts().Should().Contain(parentContext);210 }211 public void GivenContextWithAChildContextThatHasNoExample()212 {213 parentContext = GivenContextWithNoExamples();214 childContext = GivenContextWithNoExamples();215 parentContext.AddContext(childContext);216 rootContext.AddContext(parentContext);217 rootContext.AllContexts().Should().Contain(parentContext);218 }219 [Test]220 public void it_keeps_all_contexts_if_examples_exists_at_level_2()221 {222 GivenContextWithAChildContextThatHasExample();223 rootContext.TrimSkippedDescendants();224 rootContext.AllContexts().Should().Contain(parentContext);225 rootContext.AllContexts().Should().Contain(childContext);226 }227 [Test]228 public void it_removes_all_contexts_if_no_child_context_has_examples()229 {230 GivenContextWithAChildContextThatHasNoExample();231 rootContext.TrimSkippedDescendants();232 rootContext.AllContexts().Should().NotContain(parentContext);233 rootContext.AllContexts().Should().NotContain(childContext);234 }235 }236 [TestFixture]237 [Category("Context")]238 [Category("BareCode")]239 public class when_bare_code_throws_in_class_context240 {241 public class CtorThrowsSpecClass : nspec242 {243 readonly object someTestObject = DoSomethingThatThrows();244 public void method_level_context()245 {246 before = () => { };247 it["should pass"] = () => { };...

Full Screen

Full Screen

ApiTestData.cs

Source:ApiTestData.cs Github

copy

Full Screen

...92 },93 },94 new DiscoveredExample()95 {96 FullName = "nspec. ParentSpec. ChildSpec. method context 3. child example 3A skipped.",97 // No source code info available for pending tests98 SourceLineNumber = 0,99 Tags = new[]100 {101 "Tag-Child-example-skipped",102 "Tag-Child",103 "ChildSpec",104 "ParentSpec",105 },106 },107 new DiscoveredExample()108 {109 FullName = "nspec. ParentSpec. ChildSpec. method context 4. child example 4A.",110 SourceLineNumber = 47,111 Tags = new[]112 {113 "Tag with underscores",114 "Tag-Child",115 "ChildSpec",116 "ParentSpec",117 },118 },119 new DiscoveredExample()120 {121 FullName = "nspec. ParentSpec. ChildSpec. method context 5. sub context 5-1. child example 5-1A failing.",122 SourceLineNumber = 54,123 Tags = new[]124 {125 "Tag-Child",126 "ChildSpec",127 "ParentSpec",128 },129 },130 new DiscoveredExample()131 {132 FullName = "nspec. ParentSpec. ChildSpec. method context 5. sub context 5-1. child example 5-1B.",133 SourceLineNumber = 56,134 Tags = new[]135 {136 "Tag-Child",137 "ChildSpec",138 "ParentSpec",139 },140 },141 new DiscoveredExample()142 {143 FullName = "nspec. ParentSpec. ChildSpec. method context 5. child example 5A.",144 SourceLineNumber = 59,145 Tags = new[]146 {147 "Tag-Child",148 "ChildSpec",149 "ParentSpec",150 },151 },152 new DiscoveredExample()153 {154 FullName = "nspec. ParentSpec. ChildSpec. it child method example A.",155#if DEBUG156 SourceLineNumber = 63,157#endif158#if RELEASE159 SourceLineNumber = 64,160#endif161 Tags = new[]162 {163 "Tag-Child",164 "ChildSpec",165 "ParentSpec",166 },167 },168 };169 static readonly DiscoveredExample[] descAsyncSystemUnderTestDiscoveredExamples =170 {171 new DiscoveredExample()172 {173 FullName = "nspec. AsyncSpec. it async method example.",174#if DEBUG175 SourceLineNumber = 22,176#endif177#if RELEASE178 SourceLineNumber = 23,179#endif180 Tags = new[]181 {182 "AsyncSpec",183 },184 },185 new DiscoveredExample()186 {187 FullName = "nspec. AsyncSpec. method context. async context example.",188#if DEBUG189 SourceLineNumber = 31,190#endif191#if RELEASE192 SourceLineNumber = 32,193#endif194 Tags = new[]195 {196 "AsyncSpec",197 },198 },199 };200 public static readonly ExecutedExample[] allExecutedExamples =201 {202 // desc_SystemUnderTest.cs203 new ExecutedExample()204 {205 FullName = "nspec. ParentSpec. method context 1. parent example 1A.",206 Failed = false,207 Pending = false,208 },209 new ExecutedExample()210 {211 FullName = "nspec. ParentSpec. method context 1. parent example 1B.",212 Failed = false,213 Pending = false,214 },215 new ExecutedExample()216 {217 FullName = "nspec. ParentSpec. method context 2. parent example 2A.",218 Failed = false,219 Pending = false,220 },221 new ExecutedExample()222 {223 FullName = "nspec. ParentSpec. ChildSpec. method context 3. child example 3A skipped.",224 Failed = false,225 Pending = true,226 },227 new ExecutedExample()228 {229 FullName = "nspec. ParentSpec. ChildSpec. method context 4. child example 4A.",230 Failed = false,231 Pending = false,232 },233 new ExecutedExample()234 {235 FullName = "nspec. ParentSpec. ChildSpec. method context 5. sub context 5-1. child example 5-1A failing.",236 Failed = true,237 Pending = false,238 ExceptionMessage = "Expected false, but was $True.",239 ExceptionStackTrace = "NSpec.Assertions.AssertionExtensions.ShouldBeFalse(Boolean actual)",240 },241 new ExecutedExample()242 {243 FullName = "nspec. ParentSpec. ChildSpec. method context 5. sub context 5-1. child example 5-1B.",244 Failed = false,245 Pending = false,246 },247 new ExecutedExample()248 {249 FullName = "nspec. ParentSpec. ChildSpec. method context 5. child example 5A.",250 Failed = false,251 Pending = false,252 },253 new ExecutedExample()254 {255 FullName = "nspec. ParentSpec. ChildSpec. it child method example A.",256 Failed = false,257 Pending = false,258 },259 // desc_AsyncSystemUnderTest.cs260 new ExecutedExample()261 {262 FullName = "nspec. AsyncSpec. it async method example.",263 Failed = false,264 Pending = false,265 },266 new ExecutedExample()267 {268 FullName = "nspec. AsyncSpec. method context. async context example.",269 Failed = false,...

Full Screen

Full Screen

describe_ContextBuilder.cs

Source:describe_ContextBuilder.cs Github

copy

Full Screen

...36 }37 [TestFixture]38 public class when_building_contexts : describe_ContextBuilder39 {40 public class child : parent { }41 public class sibling : parent { }42 public class parent : nspec { }43 [SetUp]44 public void setup()45 {46 GivenTypes(typeof(child), typeof(sibling), typeof(parent));47 TheContexts();48 }49 [Test]50 public void should_get_specs_from_specFinder()51 {52 finder.Verify(f => f.SpecClasses());53 }54 [Test]55 public void the_primary_context_should_be_parent()56 {57 TheContexts().First().ShouldBeNamedAfter(typeof(parent));58 }59 [Test]60 public void the_parent_should_have_the_child_context()61 {62 TheContexts().First().Contexts.First().ShouldBeNamedAfter(typeof(child));63 }64 [Test]65 public void it_should_only_have_the_parent_once()66 {67 TheContexts().Count().Should().Be(1);68 }69 [Test]70 public void it_should_have_the_sibling()71 {72 TheContexts().First().Contexts.Should().Contain(c => c.Name == typeof(sibling).Name);73 }74 }75 [TestFixture]76 public class when_finding_method_level_examples : describe_ContextBuilder77 {78 class class_with_method_level_example : nspec79 {80 void it_should_be_considered_an_example() { }81 void specify_should_be_considered_as_an_example() { }82 // -----83 async Task it_should_be_considered_an_example_with_async() { await Task.Delay(0); }84 async Task<long> it_should_be_considered_an_example_with_async_result() { await Task.Delay(0); return 0L; }85 async void it_should_be_considered_an_example_with_async_void() { await Task.Delay(0); }86 async Task specify_should_be_considered_as_an_example_with_async() { await Task.Delay(0); }87 }88 [SetUp]89 public void setup()90 {91 GivenTypes(typeof(class_with_method_level_example));92 }93 [Test]94 public void should_find_method_level_example_if_the_method_name_starts_with_the_word_IT()95 {96 ShouldContainExample("it should be considered an example");97 }98 [Test]99 public void should_find_async_method_level_example_if_the_method_name_starts_with_the_word_IT()100 {101 ShouldContainExample("it should be considered an example with async");102 }103 [Test]104 public void should_find_async_method_level_example_if_the_method_name_starts_with_the_word_IT_and_it_returns_result()105 {106 ShouldContainExample("it should be considered an example with async result");107 }108 [Test]109 public void should_find_async_method_level_example_if_the_method_name_starts_with_the_word_IT_and_it_returns_void()110 {111 ShouldContainExample("it should be considered an example with async void");112 }113 [Test]114 public void should_find_method_level_example_if_the_method_starts_with_SPECIFY()115 {116 ShouldContainExample("specify should be considered as an example");117 }118 [Test]119 public void should_find_async_method_level_example_if_the_method_starts_with_SPECIFY()120 {121 ShouldContainExample("specify should be considered as an example with async");122 }123 [Test]124 public void should_exclude_methods_that_start_with_ITs_from_child_context()125 {126 TheContexts().First().Contexts.Count.Should().Be(0);127 }128 private void ShouldContainExample(string exampleName)129 {130 TheContexts().First().Examples.Any(s => s.Spec == exampleName);131 }132 }133 [TestFixture]134 public class when_building_method_contexts135 {136 private Context classContext;137 private class SpecClass : nspec138 {139 public void public_method() { }140 void private_method() { }141 void before_each() { }142 void act_each() { }143 }144 [SetUp]145 public void setup()146 {147 var finder = new Mock<ISpecFinder>();148 DefaultConventions defaultConvention = new DefaultConventions();149 defaultConvention.Initialize();150 var builder = new ContextBuilder(finder.Object, defaultConvention);151 classContext = new Context("class");152 builder.BuildMethodContexts(classContext, typeof(SpecClass));153 }154 [Test]155 public void it_should_add_the_public_method_as_a_sub_context()156 {157 classContext.Contexts.Should().Contain(c => c.Name == "public method");158 }159 [Test]160 public void it_should_not_create_a_sub_context_for_the_private_method()161 {162 classContext.Contexts.Should().Contain(c => c.Name == "private method");163 }164 [Test]165 public void it_should_disregard_method_called_before_each()166 {167 classContext.Contexts.Should().NotContain(c => c.Name == "before each");168 }169 [Test]170 public void it_should_disregard_method_called_act_each()171 {172 classContext.Contexts.Should().NotContain(c => c.Name == "act each");173 }174 }175 [TestFixture]176 public class when_building_class_and_method_contexts_with_tag_attributes : describe_ContextBuilder177 {178 [Tag("@class-tag")]179 class SpecClass : nspec180 {181 [Tag("@method-tag")]182 void public_method() { }183 }184 [SetUp]185 public void setup()186 {187 GivenTypes(typeof(SpecClass));188 }189 [Test]190 public void it_should_tag_class_context()191 {192 var classContext = TheContexts()[0];193 classContext.Tags.Should().Contain("@class-tag");194 }195 [Test]196 public void it_should_tag_method_context()197 {198 var methodContext = TheContexts()[0].Contexts[0];199 methodContext.Tags.Should().Contain("@method-tag");200 }201 }202 [TestFixture]203 [Category("ContextBuilder")]204 public class describe_second_order_inheritance : describe_ContextBuilder205 {206 class base_spec : nspec { }207 class child_spec : base_spec { }208 class grand_child_spec : child_spec { }209 [SetUp]210 public void setup()211 {212 GivenTypes(typeof(base_spec),213 typeof(child_spec),214 typeof(grand_child_spec));215 }216 [Test]217 public void the_root_context_should_be_base_spec()218 {219 TheContexts().First().ShouldBeNamedAfter(typeof(base_spec));220 }221 [Test]222 public void the_next_context_should_be_derived_spec()223 {224 TheContexts().First().Contexts.First().ShouldBeNamedAfter(typeof(child_spec));225 }226 [Test]227 public void the_next_next_context_should_be_derived_spec()228 {229 TheContexts().First().Contexts.First().Contexts.First().ShouldBeNamedAfter(typeof(grand_child_spec));230 }231 }232 public static class InheritanceExtentions233 {234 public static void ShouldBeNamedAfter(this Context context, Type expectedType)235 {236 string actual = context.Name;237 string expected = expectedType.Name.Replace("_", " ");238 actual.Should().Be(expected);239 }240 }241}...

Full Screen

Full Screen

when_method_level_before_all_contains_exception.cs

Source:when_method_level_before_all_contains_exception.cs Github

copy

Full Screen

1using System.Linq;2using NSpec.Domain;3using NUnit.Framework;4using FluentAssertions;5using System.Collections.Generic;6namespace NSpec.Tests.WhenRunningSpecs.Exceptions7{8 static class MethodBeforeAllThrows9 {10 public class SpecClass : nspec11 {12 void before_all()13 {14 throw new BeforeAllException();15 }16 void should_fail_this_example()17 {18 it["should fail"] = () =>19 {20 ExamplesRun.Add("should fail");21 Assert.That(true, Is.True);22 };23 }24 void should_also_fail_this_example()25 {26 it["should also fail"] = () =>27 {28 ExamplesRun.Add("should also fail");29 Assert.That(true, Is.True);30 };31 }32 public static List<string> ExamplesRun = new List<string>();33 }34 public class ChildSpecClass : SpecClass35 {36 void it_should_fail_because_of_parent()37 {38 ExamplesRun.Add("it_should_fail_because_of_parent");39 Assert.That(true, Is.True);40 }41 }42 }43 [TestFixture]44 [Category("RunningSpecs")]45 public class when_method_level_before_all_contains_exception : when_running_specs46 {47 [SetUp]48 public void setup()49 {50 MethodBeforeAllThrows.SpecClass.ExamplesRun.Clear();51 Run(typeof(MethodBeforeAllThrows.SpecClass));52 }53 [Test]54 public void examples_should_fail_with_framework_exception()55 {56 classContext.AllExamples().Should().OnlyContain(e => e.Exception is ExampleFailureException);57 }58 [Test]59 public void examples_with_only_before_all_failure_should_fail_because_of_that()60 {61 classContext.AllExamples().Should().OnlyContain(e => e.Exception.InnerException is BeforeAllException);62 }63 [Test]64 public void examples_should_fail_for_formatter()65 {66 formatter.WrittenExamples.Should().OnlyContain(e => e.Failed);67 }68 [Test]69 public void examples_body_should_not_run()70 {71 MethodBeforeAllThrows.SpecClass.ExamplesRun.Should().BeEmpty();72 }73 }74 [TestFixture]75 [Category("RunningSpecs")]76 public class when_parent_method_level_before_all_contains_exception : when_running_specs77 {78 [SetUp]79 public void setup()80 {81 MethodBeforeAllThrows.ChildSpecClass.ExamplesRun.Clear();82 83 Run(typeof(MethodBeforeAllThrows.ChildSpecClass));84 }85 [Test]86 public void examples_should_fail_with_framework_exception()87 {88 var example = TheExample("it should fail because of parent");89 example.Exception.Should().BeOfType<ExampleFailureException>();90 }91 [Test]92 public void examples_with_only_before_all_failure_should_fail_because_of_before_all()93 {94 var example = TheExample("it should fail because of parent");95 example.Exception.InnerException.Should().BeOfType<BeforeAllException>();96 }97 [Test]98 public void examples_should_fail_for_formatter()99 {100 formatter.WrittenExamples.Should().OnlyContain(e => e.Failed);101 }102 [Test]103 public void examples_body_should_not_run()104 {105 MethodBeforeAllThrows.ChildSpecClass.ExamplesRun.Should().BeEmpty();106 }107 }108}...

Full Screen

Full Screen

NestContextsTests.cs

Source:NestContextsTests.cs Github

copy

Full Screen

...37 Assert.That(parent.Contexts[1].Name, Is.EqualTo("Child"));38 Assert.That(parent.Contexts[0].Examples[0].Spec, Is.EqualTo("TestValue should be \"Grand Parent.Parent!!!@@@\""));39 Assert.That(parent.Contexts[0].Examples[0].Exception, Is.Null);40 Assert.That(parent.Contexts[0].Examples[0].Pending, Is.False);41 Context child = formatter.Contexts[0].Contexts[1].Contexts[1];42 Assert.That(child.Name, Is.EqualTo("Child"));43 Assert.That(child.Contexts.Count, Is.EqualTo(1));44 Assert.That(child.Contexts[0].Name, Is.EqualTo("Child Context"));45 Assert.That(child.Contexts[0].Examples[0].Spec, Is.EqualTo("TestValue should be \"Grand Parent.Parent.Child!!!@@@###\""));46 Assert.That(child.Contexts[0].Examples[0].Exception, Is.Null);47 Assert.That(child.Contexts[0].Examples[0].Pending, Is.False);48 }49 }50 public class TestFormatter : IFormatter51 {52 public ContextCollection Contexts { get; set; }53 public void Write(ContextCollection contexts)54 {55 this.Contexts = contexts;56 }57 public IDictionary<string, string> Options { get; set; }58 }59}...

Full Screen

Full Screen

NestedContexts.cs

Source:NestedContexts.cs Github

copy

Full Screen

1using NUnit.Framework;2namespace NSpec.Tests.ClassContextBug3{4 class Grand_Parent : nspec5 {6 public string TestValue;7 void before_each()8 {9 this.TestValue = "Grand Parent";10 }11 void act_each()12 {13 this.TestValue = this.TestValue + "!!!";14 }15 void Grand_Parent_Context()16 {17 it["TestValue should be \"Grand Parent!!!\""] = () => Assert.That(TestValue, Is.EqualTo("Grand Parent!!!"));18 }19 }20 class Parent : Grand_Parent21 {22 void before_each()23 {24 this.TestValue += "." + "Parent";25 }26 void act_each()27 {28 this.TestValue = this.TestValue + "@@@";29 }30 void Parent_Context()31 {32 it["TestValue should be \"Grand Parent.Parent!!!@@@\""] = () => Assert.That(TestValue, Is.EqualTo("Grand Parent.Parent!!!@@@"));33 }34 }35 class Child : Parent36 {37 void before_each()38 {39 this.TestValue += "." + "Child";40 }41 void act_each()42 {43 this.TestValue = this.TestValue + "###";44 }45 void Child_Context()46 {47 it["TestValue should be \"Grand Parent.Parent.Child!!!@@@###\""] = () => Assert.That(TestValue, Is.EqualTo("Grand Parent.Parent.Child!!!@@@###"));48 }49 }50}...

Full Screen

Full Screen

describe_levels_inheritance.cs

Source:describe_levels_inheritance.cs Github

copy

Full Screen

...4{5 public class describe_levels_inheritance : when_running_specs6 {7 class parent_context : nspec { }8 class child_context : parent_context9 {10 void it_is()11 {12 Assert.That("is", Is.EqualTo("is"));13 }14 }15 [SetUp]16 public void Setup()17 {18 Run(new[] { typeof(parent_context), typeof(child_context) });19 }20 [Test]21 public void parent_class_is_level_1()22 {23 TheContext("parent context").Level.Should().Be(1);24 }25 [Test]26 public void child_class_is_level_2()27 {28 TheContext("child context").Level.Should().Be(2);29 }30 }31}...

Full Screen

Full Screen

child

Using AI Code Generation

copy

Full Screen

1using NSpec;2using NSpec.Tests;3using System;4using System.Collections.Generic;5using System.Linq;6using System.Text;7using System.Threading.Tasks;8{9 {10 static void Main(string[] args)11 {12 var testRunner = new TestRunner();13 testRunner.Run(typeof(SpecClass));14 }15 }16}17using NSpec;18using System;19using System.Collections.Generic;20using System.Linq;21using System.Text;22using System.Threading.Tasks;23{24 {25 public void method_level_context()26 {27 describe["when testing something"] = () =>28 {29 it["should work"] = () => true.should_be_true();30 };31 }32 }33}

Full Screen

Full Screen

child

Using AI Code Generation

copy

Full Screen

1using NSpec.Tests;2using NSpec.Domain;3using NSpec.Domain.Formatters;4using System;5using System.Collections.Generic;6using System.Linq;7using System.Text;8using System.Threading.Tasks;9{10 {11 public void when_running_specs()12 {13 it["should run this spec"] = () => "hello".should_be("hello");14 }15 }16}17using NSpec;18using NSpec.Domain;19using NSpec.Domain.Formatters;20using System;21using System.Collections.Generic;22using System.Linq;23using System.Text;24using System.Threading.Tasks;25{26 {27 public void when_running_specs()28 {29 it["should run this spec"] = () => "hello".should_be("hello");30 }31 }32}33The type or namespace name 'nspec' could not be found (are you missing a using directive or an assembly reference?)34The type or namespace name 'nspec' could not be found (are you missing a using directive or an assembly reference?)

Full Screen

Full Screen

child

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6{7 {8 public Class1() { }9 public Class1(int id)10 {11 this.id = id;12 }13 public int id { get; set; }14 }15}16using System;17using System.Collections.Generic;18using System.Linq;19using System.Text;20using System.Threading.Tasks;21{22 {23 public Class2() { }24 public Class2(int id)25 {26 this.id = id;27 }28 public int id { get; set; }29 }30}31using System;32using System.Collections.Generic;33using System.Linq;34using System.Text;35using System.Threading.Tasks;36{37 {38 public Class3() { }39 public Class3(int id)40 {41 this.id = id;42 }43 public int id { get; set; }44 }45}46using System;47using System.Collections.Generic;48using System.Linq;49using System.Text;50using System.Threading.Tasks;51{52 {53 public Class4() { }54 public Class4(int id)55 {56 this.id = id;57 }58 public int id { get; set; }59 }60}61using System;62using System.Collections.Generic;63using System.Linq;64using System.Text;65using System.Threading.Tasks;66{67 {68 public Class5() { }69 public Class5(int id)70 {71 this.id = id;72 }73 public int id { get; set; }74 }75}76using System;77using System.Collections.Generic;78using System.Linq;79using System.Text;80using System.Threading.Tasks;81{

Full Screen

Full Screen

child

Using AI Code Generation

copy

Full Screen

1using NSpec.Tests;2{3 {4 public void before_each()5 {6 Console.WriteLine("before_each");7 }8 public void after_each()9 {10 Console.WriteLine("after_each");11 }12 public void before_all()13 {14 Console.WriteLine("before_all");15 }16 public void after_all()17 {18 Console.WriteLine("after_all");19 }20 public void describe_test1()21 {22 it["test1"] = () => { Console.WriteLine("test1"); };23 it["test2"] = () => { Console.WriteLine("test2"); };24 }25 }26}27using NSpec;28{29 {30 public abstract void before_each();31 public abstract void after_each();32 public abstract void before_all();33 public abstract void after_all();34 }35}

Full Screen

Full Screen

child

Using AI Code Generation

copy

Full Screen

1using NSpec;2{3 {4 void when_checking_2()5 {6 it["should be true"] = () => true.should_be_true();7 }8 }9}

Full Screen

Full Screen

child

Using AI Code Generation

copy

Full Screen

1using NSpec.Tests;2using NSpec;3{4 void when_child_class()5 {6 it["should be able to use the child class"] = () => "child".should_be("child");7 }8}9using NSpec;10using NSpec.Tests;11{12 void when_base_class()13 {14 it["should be able to use the base class"] = () => "base".should_be("base");15 }16}17using NSpec;18{19 void when_nspec_class()20 {21 it["should be able to use the nspec class"] = () => "nspec".should_be("nspec");22 }23}24using NSpec.Tests;25{26 void when_nspec_tests_class()27 {28 it["should be able to use the nspec_tests class"] = () => "nspec_tests".should_be("nspec_tests");29 }30}31using NSpec.Domain;32{33 void when_nspec_domain_class()34 {35 it["should be able to use the nspec_domain class"] = () => "nspec_domain".should_be("nspec_domain");36 }37}38using NSpec.Domain.Formatters;39{40 void when_nspec_domain_formatters_class()41 {42 it["should be able to use the nspec_domain_formatters class"] = () => "nspec_domain_formatters".should_be("nspec_domain_formatters");43 }44}45using NSpec.Domain.Extensions;46{47 void when_nspec_domain_extensions_class()48 {49 it["should be able to use the nspec_domain_extensions class"] = () => "nspec_domain_extensions".should_be("nspec_domain_extensions");

Full Screen

Full Screen

child

Using AI Code Generation

copy

Full Screen

1using NSpec.Tests;2using NUnit.Framework;3{4 {5 public void it_should_run()6 {7 Assert.That(true, Is.True);8 }9 }10}11using NSpec.Tests;12using NUnit.Framework;13{14 {15 public void it_should_run()16 {17 Assert.That(true, Is.True);18 }19 }20}

Full Screen

Full Screen

child

Using AI Code Generation

copy

Full Screen

1using System;2using NSpec;3using NSpec.Tests;4{5 {6 void when_saying_hello()7 {8 it["says hello"] = () => "hello".should_be("hello");9 }10 }11}12using System;13using NSpec;14{15 {16 public void SayHello()17 {18 Console.WriteLine("Hello World");19 }20 }21}22using System;23using NSpec;24{25 {26 void when_saying_hello()27 {28 it["says hello"] = () => "hello".should_be("hello");29 }30 }31}32using System;33using NSpec;34{35 {36 public void SayHello()37 {38 Console.WriteLine("Hello World");39 }40 }41}42using NSpec.Tests;

Full Screen

Full Screen

child

Using AI Code Generation

copy

Full Screen

1{2 {3 public override void act_each()4 {5 it["should be able to run a single example"] = () => true.ShouldBeTrue();6 }7 }8}9{10 {11 public override void act_each()12 {13 it["should be able to run a single example"] = () => true.ShouldBeTrue();14 }15 }16}17{18 {19 public override void act_each()20 {21 it["should be able to run a single example"] = () => true.ShouldBeTrue();22 }23 }24}25{26 {27 public override void act_each()28 {29 it["should be able to run a single example"] = () => true.ShouldBeTrue();30 }31 }32}33{34 {35 public override void act_each()36 {37 it["should be able to run a single example"] = () => true.ShouldBeTrue();38 }39 }40}41{42 {43 public override void act_each()44 {45 it["should be able to run a single example"] = () => true.ShouldBeTrue();46 }47 }48}

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful