Пример #1
0
 public void agent_executes()
 {
     var i = new AllHookDouble();
     var agent = new Agent();
     agent.RunSuite(i);
     //agent.RunSuite(i.Registry.CurrentSuite);
 }
Пример #2
0
        public void agent_executesASpecAnd()
        {
            var i = 0;
            _suite.describe("new", () =>
            {
                i = 0;
                _suite.it("spec1", () => { i++; });

                _suite.it("spec2");
            });

            var agent = new Agent();
            _suite.Registry.ExecutableLookupTable.Count.Should().Be(2);
            agent.RunSuite(_suite);
            i.Should().Be(1);
        }
Пример #3
0
        public void agent_executesASpecAndRunsSuccesfully()
        {
            var i = 0;
            _suite.describe("new", () =>
            {
                i = 0;
                _suite.beforeAll(() => { i++; });

                _suite.beforeEach(() => { i++; });

                _suite.it("spec1", () => { i++; });

                _suite.it("spec2", () => { i++; });

                _suite.afterEach(() => { i++; });

                _suite.afterAll(() => { i++; });
            });

            var agent = new Agent();
            agent.RunSuite(_suite);
            i.Should().Be(8);
        }
Пример #4
0
        public List<DefinitionSource> Execute(IEnumerable<DefinitionSource> typesSources)
        {
            var availableTypes = SandboxedAssembly.GetTypes();
            var targetTypesToRun = TypeIndex.TargetTypesToRun(typesSources, availableTypes);

            var agent = new Agent();
            var specSummary = new List<DefinitionSource>();

            var stdConsole = Console.Out;

            using (var writer = new StringWriter())
            {
                Console.SetOut(writer);
                foreach (var specTypes in targetTypesToRun)
                {
                    var currentRunninType = SandboxedAssembly.CreateInstance(specTypes.FullName) as Spec;
                    agent.RunSuite(currentRunninType);
                    specSummary.AddRange(currentRunninType.Registry.ExecutableLookupTable.Select(DefinitionSource.CreateSource).ToList());
                }
            }
            //Console.SetOut(stdConsole);
            return specSummary;
        }
Пример #5
0
        //[TestMethod] - Nested describes
        public void spec_shouldNotAllowAddingNestedSuites()
        {
            _suite = new spec_double();
            _suite.describe("new Describe",
                () => { _suite.it("spec", () => { _suite.describe("invalid", () => { }); }); });

            Agent agent = new Agent();
            agent.RunSuite(_suite);
            _suite.Registry.ExecutableLookupTable.Any(x => x.RanSuccesfully)
                .Should()
                .BeFalse("describes should not be in specs");
        }
Пример #6
0
        public void agent_executesASpecHooksEvenAfterErrors()
        {
            int i = 0,
                j = 0;
            _suite.describe("new", () =>
            {
                i = 0;
                _suite.beforeAll(() => { i++; });

                _suite.beforeEach(() =>
                {
                    i++;
                    j++;
                });

                _suite.it("spec1", () => { throw new Exception("im breaking the flow"); });

                _suite.afterEach(() =>
                {
                    i++;
                    ;
                    j++;
                });

                _suite.afterAll(() => { i++; });
            });

            var agent = new Agent();
            agent.RunSuite(_suite);
            i.Should().Be(4);
            j.Should().Be(2);
        }
Пример #7
0
        public void agent_executesASpecAndRunsSuccesfullyWithHooksSiblingDescribes()
        {
            var i = 0;
            _suite.describe("new", () =>
            {
                _suite.beforeAll(() => { i++; });

                _suite.beforeEach(() => { i++; });

                _suite.it("spec1", () =>
                {
                    //
                });

                _suite.afterEach(() => { i--; });

                _suite.afterAll(() => { i--; });
            });
            _suite.describe("new1", () =>
            {
                _suite.beforeAll(() => { i++; });

                _suite.beforeEach(() => { i++; });

                _suite.it("spec1", () =>
                {
                    //
                });

                _suite.afterEach(() => { i--; });

                _suite.afterAll(() => { i--; });
            });

            var agent = new Agent();
            agent.RunSuite(_suite);
            i.Should().Be(0);
        }