Ejemplo n.º 1
0
        private SpecResults runSpec(string id)
        {
            var node          = _hierarchy.ToHierarchy().Specifications[id];
            var specification = MarkdownReader.ReadFromFile(node.Filename);

            return(_runner.Execute(specification));
        }
Ejemplo n.º 2
0
        public void change_a_file()
        {
            var file = ClassUnderTest.Hierarchy.Specifications["general1"].Filename;
            var old  = MarkdownReader.ReadFromFile(file);

            old.Lifecycle = Lifecycle.Regression;
            MarkdownWriter.WriteToFile(old, file);

            ClassUnderTest.Changed(file);

            var newNode = ClassUnderTest.Hierarchy.Specifications["general1"];

            newNode.ShouldNotBeTheSameAs(old);
            newNode.Lifecycle.ShouldBe(Lifecycle.Regression);

            ClassUnderTest.Hierarchy.Suites["General"]
            .Specifications.ShouldContain(newNode);


            var sent = MockFor <IClientConnector>().ReceivedCalls().First().GetArguments().First().As <SpecData>();

            sent.ShouldNotBeNull();

            sent.data.ShouldBe(newNode);
            sent.id.ShouldBe("general1");
        }
Ejemplo n.º 3
0
        public void clone_a_specification()
        {
            // This *should* be broken up into its own fixture, but I'm feeling lazy
            // today


            // sentence2 is marked as regression, but the newly cloned one
            // should be acceptance

            var added = ClassUnderTest.CloneSpecification("sentence2", "New Sentence");

            var expectedPath = thePath.AppendPath("Sentences", "New_Sentence.md");

            added.hierarchy.ShouldBeTheSameAs(ClassUnderTest.Hierarchy.Top);
            added.data.Lifecycle.ShouldBe(Lifecycle.Acceptance);
            added.data.id.ShouldNotBe("sentence2");
            added.data.name.ShouldBe("New Sentence");

            added.data.Filename.ShouldBe(expectedPath);

            ClassUnderTest.Hierarchy.Specifications[added.data.id].ShouldBeTheSameAs(added.data);

            var specification = MarkdownReader.ReadFromFile(expectedPath);

            specification.name.ShouldBe("New Sentence");
            specification.Children.Any().ShouldBe(true);

            // Adds the spec to the node
            var suite = ClassUnderTest.Hierarchy.Suites["Sentences"];

            suite.Specifications.ShouldContain(added.data);
        }
Ejemplo n.º 4
0
        public void setting_the_lifecycle_when_the_new_lifecycle_is_different()
        {
            var spec         = ClassUnderTest.Hierarchy.Specifications["general1"];
            var newLifecycle = spec.Lifecycle == Lifecycle.Acceptance ? Lifecycle.Regression : Lifecycle.Acceptance;

            var completed1 = new SpecExecutionCompleted {
                Id = spec.id
            };
            var completed2 = new SpecExecutionCompleted {
                Id = spec.id
            };
            var completed3 = new SpecExecutionCompleted {
                Id = spec.id
            };

            ClassUnderTest.Results.Store(completed1);
            ClassUnderTest.Results.Store(completed2);
            ClassUnderTest.Results.Store(completed3);

            ClassUnderTest.SetLifecycle("general1", newLifecycle);

            // Did save
            MarkdownReader.ReadFromFile(spec.Filename).Lifecycle
            .ShouldBe(newLifecycle);



            var message = MockFor <IClientConnector>().ReceivedCalls().First().GetArguments().First().As <SpecData>();

            message.data.ShouldBeSameAs(spec);
            message.data.id.ShouldBe(spec.id);
            message.results.Any(x => ReferenceEquals(x, completed1)).ShouldBeTrue();
            message.results.Any(x => ReferenceEquals(x, completed2)).ShouldBeTrue();
            message.results.Any(x => ReferenceEquals(x, completed3)).ShouldBeTrue();
        }
Ejemplo n.º 5
0
        public void add_spec_with_illegal_chars()
        {
            var c = Path.GetInvalidFileNameChars().First();

            var added = ClassUnderTest.AddSpec("Sentences", $"The Third Sentence{c}{c}");

            var expectedPath = thePath.AppendPath("Sentences", "The_Third_Sentence.md");

            added.data.name.ShouldBe($"The Third Sentence{c}{c}");
            added.data.Filename.ShouldBe(expectedPath);
            added.data.Lifecycle.ShouldBe(Lifecycle.Acceptance);

            added.data.Filename.ShouldBe(expectedPath);

            ClassUnderTest.Hierarchy.Specifications[added.data.id].ShouldBeTheSameAs(added.data);

            var specification = MarkdownReader.ReadFromFile(expectedPath);

            specification.name.ShouldBe($"The Third Sentence{c}{c}");

            // Adds the spec to the node
            var suite = ClassUnderTest.Hierarchy.Suites["Sentences"];

            suite.Specifications.ShouldContain(added.data);
        }
        public void can_read_max_retries()
        {
            var path = TestingContext.FindParallelDirectory("Storyteller.Samples").AppendPath("Specs", "General", "Check properties.md");

            var spec = MarkdownReader.ReadFromFile(path);

            spec.MaxRetries.ShouldBe(3);
        }
        public SpecExecutionRequestTester()
        {
            var path = TestingContext.FindParallelDirectory("Storyteller.Samples")
                       .AppendPath("Specs", "General", "Check properties.md");

            theSpec = MarkdownReader.ReadFromFile(path);

            listener = new RuntimeErrorListener();
        }
Ejemplo n.º 8
0
        public void can_read_max_retries()
        {
            var path = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory()
                       .AppendPath("Storyteller.Samples", "Specs", "General", "Check properties.md");

            var spec = MarkdownReader.ReadFromFile(path);

            spec.MaxRetries.ShouldBe(3);
        }
        //[Fact]
        public void write_the_table5_spec()
        {
            var hierarchy     = TestingContext.Hierarchy;
            var spec          = hierarchy.ToHierarchy().Specifications["table5"];
            var specification = MarkdownReader.ReadFromFile(spec.Filename);

            var json = JsonSerialization.ToIndentedJson(specification);

            Debug.WriteLine(json);
        }
        private Counts running(string name)
        {
            var node = _allSpecs.FirstOrDefault(x => x.name == name);
            var spec = MarkdownReader.ReadFromFile(node.Filename);

            executeSpec(spec);

            theContext.Results.Each(x => Debug.WriteLine(x));

            return(theContext.Counts);
        }
Ejemplo n.º 11
0
        public void save_specification_updates_expiration_period()
        {
            var node          = ClassUnderTest.Hierarchy.Specifications["embeds"];
            var specification = MarkdownReader.ReadFromFile(node.Filename);

            specification.ExpirationPeriod = 5;

            ClassUnderTest.SaveSpecification(node.id, specification);
            var written = MarkdownReader.ReadFromFile(node.Filename);

            written.ExpirationPeriod.ShouldBe(5);
        }
        public void read_a_spec_node()
        {
            var path = TestingContext.FindParallelDirectory("Storyteller.Samples").AppendPath("Specs", "General", "Check properties.md");

            var spec = MarkdownReader.ReadFromFile(path);

            spec.name.ShouldBe("Check properties");
            spec.Lifecycle.ShouldBe(Lifecycle.Acceptance);
            spec.id.ShouldBe("general1");
            spec.Filename.ShouldBe(path);


            spec.MaxRetries.ShouldBe(3);
        }
        //[Fact]
        public void record_specification_json()
        {
            var hierarchy  = TestingContext.Hierarchy;
            var dictionary = new Dictionary <string, Specification>();

            hierarchy.GetAllSpecs().Each(x =>
            {
                var spec = MarkdownReader.ReadFromFile(x.Filename);
                dictionary.Add(x.id, spec);
            });

            var json = JsonSerialization.ToIndentedJson(dictionary);

            new FileSystem().WriteStringToFile("Specifications.js", "module.exports = " + json);
        }
Ejemplo n.º 14
0
        public void save_specification_body()
        {
            var node          = ClassUnderTest.Hierarchy.Specifications["embeds"];
            var specification = MarkdownReader.ReadFromFile(node.Filename);

            specification.Children.Add(new Comment {
                Text = "a new comment"
            });

            ClassUnderTest.SaveSpecification(node.id, specification);

            var written = MarkdownReader.ReadFromFile(node.Filename);

            written.Children.Last().ShouldBeOfType <Comment>()
            .Text.ShouldBe("a new comment");
        }
Ejemplo n.º 15
0
        public void Changed(string file)
        {
            try
            {
                _lock.Read(() =>
                {
                    var node = MarkdownReader.ReadFromFile(file);

                    _fixtures.PostProcess(node);

                    if (_hierarchy.Specifications.Has(node.id))
                    {
                        var old   = _hierarchy.Specifications[node.id];
                        var suite = _hierarchy.Suites[old.SuitePath()];

                        suite.ReplaceSpecification(node);
                        _hierarchy.Specifications[node.id] = node;

                        node.WritePath(suite.path);



                        _client.SendMessageToClient(new SpecData
                        {
                            data    = node,
                            id      = node.id,
                            results = Results.ResultsFor(node.id).ToArray()
                        });
                    }

                    return(true);
                });
            }
            catch (IOException)
            {
                ConsoleWriter.Write(ConsoleColor.Yellow, $"Unable to reload {file}, file may be locked by your editor");
            }
            catch (Exception e)
            {
                Logger.Error("Failed to handle a changed file: " + file, e);
            }
        }
Ejemplo n.º 16
0
        public SpecAdded CloneSpecification(string id, string name)
        {
            return(_lock.Read(() =>
            {
                if (!_hierarchy.Specifications.Has(id))
                {
                    return null;
                }

                var spec = _hierarchy.Specifications[id];

                // Keep things isolated!
                var template = MarkdownReader.ReadFromFile(spec.Filename);
                template.id = Guid.NewGuid().ToString();
                template.name = name;
                template.Lifecycle = Lifecycle.Acceptance;

                var suitePath = spec.SuitePath();

                var filename = Specification.DetermineFilename(name);
                var suite = _hierarchy.Suites[suitePath];
                var file = suite.Folder.AppendPath(filename);

                _watcher.WriteFiles(() =>
                {
                    MarkdownWriter.WriteToFile(template, file);
                });

                template.Filename = file;
                _hierarchy.Specifications[template.id] = template;

                suite.AddSpec(template);

                _fixtures.PostProcess(template);

                return new SpecAdded(_hierarchy.Top, template);
            }));
        }
 public static Specification FindSpecification(string id)
 {
     return(MarkdownReader.ReadFromFile(Hierarchy.ToHierarchy().Specifications[id].Filename));
 }