How to use subsequent_derived_concrete_class_do_not_contain_the_examples_from_the_abtract_class method of NSpec.Tests.WhenRunningSpecs.ConcreteClass class

Best NSpec code snippet using NSpec.Tests.WhenRunningSpecs.ConcreteClass.subsequent_derived_concrete_class_do_not_contain_the_examples_from_the_abtract_class

Run NSpec automation tests on LambdaTest cloud grid

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

describe_abstract_class_examples.cs

Source: describe_abstract_class_examples.cs Github

copy
1using System.Linq;
2using NSpec.Domain;
3using NUnit.Framework;
4using FluentAssertions;
5
6namespace NSpec.Tests.WhenRunningSpecs
7{
8    [TestFixture]
9    public class describe_abstract_class_examples : when_running_specs
10    {
11        abstract class AbstractClass : nspec
12        {
13            void specify_an_example_in_abstract_class()
14            {
15                Assert.That(true, Is.True);
16            }
17        }
18
19        abstract class AnotherAbstractClassInChain : AbstractClass
20        {
21            void specify_an_example_in_another_abstract_class()
22            {
23                Assert.That(true, Is.True);
24            }
25        }
26
27        class ConcreteClass : AnotherAbstractClassInChain
28        {
29            void specify_an_example()
30            {
31                Assert.That(true, Is.True);
32            }
33        }
34
35        class DerivedConcreteClass : ConcreteClass
36        {
37            void specify_an_example_in_derived_concrete_class()
38            {
39                Assert.That(true, Is.True);
40            }
41        }
42
43        [SetUp]
44        public void Setup()
45        {
46            Run(new[] { typeof(DerivedConcreteClass), typeof(ConcreteClass), typeof(AbstractClass), typeof(AnotherAbstractClassInChain) });
47        }
48
49        [Test]
50        public void abstracts_should_not_be_added_as_class_contexts()
51        {
52            var allClassContexts =
53                contextCollection[0].AllContexts().Where(c => c is ClassContext).ToList();
54
55            allClassContexts.Should().Contain(c => c.Name == "ConcreteClass");
56
57            allClassContexts.Should().NotContain(c => c.Name == "AbstractClass");
58
59            allClassContexts.Should().NotContain(c => c.Name == "AnotherAbstractClassInChain");
60        }
61
62        //TODO: specify that concrete classes must have an example of their own or they won't host
63        //abstract superclass's examples or do away with abstract classes altogether .
64        //I'm not sure this complexity is warranted.
65
66        [Test]
67        public void examples_of_abtract_classes_are_included_in_the_first_derived_concrete_class()
68        {
69            TheContext("ConcreteClass").Examples.Count().Should().Be(3);
70
71            TheExample("specify an example in abstract class").ShouldHavePassed();
72
73            TheExample("specify an example in another abstract class").ShouldHavePassed();
74        }
75
76        [Test]
77        public void subsequent_derived_concrete_class_do_not_contain_the_examples_from_the_abtract_class()
78        {
79            TheContext("DerivedConcreteClass").Examples.Count().Should().Be(1);
80        }
81    }
82}
83
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

Trigger subsequent_derived_concrete_class_do_not_contain_the_examples_from_the_abtract_class code on LambdaTest Cloud Grid

Execute automation tests with subsequent_derived_concrete_class_do_not_contain_the_examples_from_the_abtract_class on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

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)