public void record_data() { var spec = new Specification { name = "Some Name" }; var timings = new Timings(); timings.Start(spec); using (timings.Subject("Fixture.Setup", "Math")) { using (timings.Subject("Grammar", "Adding")) { using (timings.Subject("Fixture.Teardown", "Math")) { Thread.Sleep(100); } } } var records = timings.Finish(); records.Select(x => x.Subject).ShouldHaveTheSameElementsAs("Some Name", "Math", "Adding", "Math"); records.Each(x => x.Duration.ShouldBeGreaterThan(0)); }
public void apply_renumbering() { var spec = new Specification(); var c1 = new Comment(); spec.Children.Add(c1); var section1 = new Section("Foo"); var s1 = section1.AddStep("foo1"); var s2 = section1.AddStep("foo1"); var s3 = section1.AddStep("foo1"); var section2 = s3.AddCollection("rows"); var s4 = section2.AddStep("r1"); var s5 = section2.AddStep("r1"); var s6 = section2.AddStep("r1"); s4.id = s5.id = s6.id = Guid.NewGuid().ToString(); spec.Children.Add(section1); var c2 = new Comment(); spec.Children.Add(c2); spec.ApplyRenumbering(); s4.id.ShouldNotBe(s5.id); s5.id.ShouldNotBe(s6.id); s4.id.ShouldNotBe(s6.id); }
// TODO -- if an error bubbles up, the SpecificationEngine should mark its runner // as Invalid public static StepthroughExecutor Start(ISystem system, Specification specification, IResultObserver observer, IUserInterfaceObserver uiObserver, FixtureLibrary library) { var request = new SpecExecutionRequest(specification, observer); request.CreatePlan(library); // Got to watch because this can error out var execution = system.CreateContext(); return new StepthroughExecutor(execution, request, uiObserver); }
public bool IsExpired(Specification spec) { if (spec.ExpirationPeriod <= 0) { return false; } var currentDate = _systemTime.UtcNow(); var expiryDate = spec.LastUpdated.AddMonths(spec.ExpirationPeriod); return currentDate > expiryDate; }
public SpecExecutionCompleted(string id, SpecResults results, Specification data) : this() { if (results == null) throw new ArgumentNullException(nameof(results)); if (data == null) throw new ArgumentNullException(nameof(data)); Results = results; Id = id; Time = DateTime.Now.ToString("T"); Data = data; }
public when_replacing_a_specification() { theHierarchy = HierarchyLoader.ReadHierarchy(TestingContext.SpecFolder).ToHierarchy(); theOriginal = theHierarchy.Specifications["embeds"]; theNew = theOriginal.Clone(); theNew.path = null; theNew.id = theOriginal.id; // gets a new id by default theTime = DateTime.Now; theHierarchy.Replace(theNew, theTime); }
public void SetUp() { theHierarchy = HierarchyLoader.ReadHierarchy(TestingContext.SpecFolder).ToHierarchy(); theOriginal = theHierarchy.Specifications["embeds"]; theNew = theOriginal.Clone(); theNew.path = null; theNew.id = theOriginal.id; // gets a new id by default theHierarchy.Replace(theNew); }
private void roundTripCheck(Specification spec) { spec.ApplyRenumbering(); spec.path = null; // doesn't matter for the markdown persistence var markdown = MarkdownWriter.WriteToText(spec); var readCopy = MarkdownReader.ReadFromText(markdown); compare(spec, readCopy); }
public void clear_breakpoints() { var specification = new Specification(); var breakpoint1 = new Breakpoint("1", null); var breakpoint2 = new Breakpoint("2", null); specification.Breakpoints = new[] {breakpoint1, breakpoint2}; specification.ClearBreakpoints(); specification.Breakpoints.Any().ShouldBeFalse(); }
public bool ShouldRetry(SpecResults results, Specification specification, SpecRunnerStatus status) { if (results.Counts.WasSuccessful()) return false; if (status == SpecRunnerStatus.Invalid) return false; if (results.HadCriticalException) return false; if (specification.Lifecycle == Lifecycle.Acceptance) return false; return specification.MaxRetries > (results.Attempts - 1) || Project.CurrentMaxRetries > (results.Attempts); }
public Specification ToSampleSpecification() { var spec = new Specification { name = $"Sample Specification for {key}" }; var section = spec.AddSection(key); CreateSampleSteps(section); return spec; }
private void compare(Specification expected, Specification actual) { actual.LastUpdated.ShouldBe(expected.LastUpdated); actual.Breakpoints.ShouldBe(expected.Breakpoints); actual.Lifecycle.ShouldBe(expected.Lifecycle); actual.MaxRetries.ShouldBe(expected.MaxRetries); actual.id.ShouldBe(expected.id); actual.name.ShouldBe(expected.name); compare(expected.Children, actual.Children); }
public void SetUp() { original = new Specification(); _persisted = new Lazy<Specification>(() => { var document = XmlWriter.WriteToXml(original); var x = XmlReader.ReadFromXml(document); x.ShouldNotBeTheSameAs(original); return x; }); }
public void run_spec_by_id_only() { var theSpecRetrievedFromPersistence = new Specification(); app.Persistence.LoadSpecification("foo") .Returns(new SpecData { data = theSpecRetrievedFromPersistence }); var theMessage = new RunSpec{id = "foo"}; new RunSpecCommand().HandleMessage(theMessage, app); app.Engine.Received().SendMessage(theMessage); theMessage.spec.ShouldBeTheSameAs(theSpecRetrievedFromPersistence); }
public persisting_and_loading_specifications_with_markdown() { original = new Specification(); _persisted = new Lazy<Specification>(() => { var text = MarkdownWriter.WriteToText(original); var x = MarkdownReader.ReadFromText(text); x.ShouldNotBeTheSameAs(original); return x; }); }
public persisting_and_loading_specifications_with_xml() { original = new Specification(); _persisted = new Lazy<Specification>(() => { var document = XmlWriter.WriteToXml(original); var x = XmlReader.ReadFromXml(document); x.ShouldNotBeTheSameAs(original); return x; }); }
public void SetUp() { original = new Specification(); _persisted = new Lazy<Specification>(() => { var json = original.ToJson(); var serializer = new JsonSerializer(); var x = serializer.Deserialize<Specification>(new JsonTextReader(new StringReader(json))); x.ShouldNotBeTheSameAs(original); return x; }); }
public void run_spec_with_body_but_no_revision() { var theSpecSentFromTheClient = new Specification(); var theMessage = new RunSpec { revision = null, spec = theSpecSentFromTheClient, id = "foo" }; new RunSpecCommand().HandleMessage(theMessage, app); app.Engine.Received().SendMessage(theMessage); // do not auto-save app.Persistence.DidNotReceive().SaveSpecification("foo", theSpecSentFromTheClient); }
public void run_spec_with_body_and_revision_denoting_auto_save() { var theSpecSentFromTheClient = new Specification(); var theMessage = new RunSpec { revision = Guid.NewGuid().ToString(), spec = theSpecSentFromTheClient, id = "foo" }; new RunSpecCommand().HandleMessage(theMessage, app); app.Engine.Received().SendMessage(theMessage); // *do* auto-save app.Persistence.Received().SaveSpecification("foo", theSpecSentFromTheClient); }
public void can_find_all_children() { var spec = new Specification(); var c1 = new Comment(); spec.Children.Add(c1); var section1 = new Section("Foo"); var s1 = section1.AddStep("foo1"); var s2 = section1.AddStep("foo1"); var s3 = section1.AddStep("foo1"); var section2 = s3.AddCollection("rows"); var s4 = section2.AddStep("r1"); var s5 = section2.AddStep("r1"); var s6 = section2.AddStep("r1"); spec.Children.Add(section1); var c2 = new Comment(); spec.Children.Add(c2); var nodes = spec.AllNodes(); // All comments, steps, sections, and the spec itself nodes.Count().ShouldBe(11); nodes.ShouldContain(spec); nodes.ShouldContain(section1); nodes.ShouldContain(section2); nodes.ShouldContain(c1); nodes.ShouldContain(c2); nodes.ShouldContain(s1); nodes.ShouldContain(s2); nodes.ShouldContain(s3); nodes.ShouldContain(s4); nodes.ShouldContain(s5); nodes.ShouldContain(s6); }
public void serializes_fine() { var spec = new Specification(); var c1 = new Comment(); spec.Children.Add(c1); var section1 = new Section("Foo"); var s1 = section1.AddStep("foo1"); var s2 = section1.AddStep("foo1"); var s3 = section1.AddStep("foo1"); var section2 = s3.AddCollection("rows"); var s4 = section2.AddStep("r1"); var s5 = section2.AddStep("r1"); var s6 = section2.AddStep("r1"); spec.Children.Add(section1); var c2 = new Comment(); spec.Children.Add(c2); var json = JsonSerialization.ToJson(spec, true); Debug.WriteLine(json); }
public void PostProcess(Specification spec) { var combined = FixtureLibrary.From(CombinedFixtures()); new SpecificationPostProcessor(combined, spec).Validate(); }
protected bool Equals(Specification other) { return string.Equals(id, other.id); }
public static SpecExecutionRequest For(Specification spec) { return new SpecExecutionRequest(spec, new NulloResultObserver()); }
public SpecExecutionRequest(Specification specification, IResultObserver observer) { Observer = observer; Specification = specification; }
public SpecAdded(Suite hierarchy, Specification data) : base("spec-added") { this.hierarchy = hierarchy; this.data = data; }
public void Start(Specification spec) { _main = new PerfRecord("Specification", spec.name, 0); _records.Add(_main); _stopwatch.Start(); }
public SpecRecord(Specification data, ResultsCache cache) { this.data = data; LastResults = cache.LastResultFor(data.id); }
public void needs_renumbering_is_true_because_there_are_duplicate_ids() { var spec = new Specification(); var c1 = new Comment(); spec.Children.Add(c1); var section1 = new Section("Foo"); var s1 = section1.AddStep("foo1"); var s2 = section1.AddStep("foo1"); var s3 = section1.AddStep("foo1"); var section2 = s3.AddCollection("rows"); var s4 = section2.AddStep("r1"); var s5 = section2.AddStep("r1"); var s6 = section2.AddStep("r1"); s4.id = s5.id = s6.id = Guid.NewGuid().ToString(); spec.Children.Add(section1); var c2 = new Comment(); spec.Children.Add(c2); spec.NeedsToBeRenumbered().ShouldBeTrue(); }
public void needs_renumbering_negative() { var spec = new Specification(); var c1 = new Comment(); spec.Children.Add(c1); var section1 = new Section("Foo"); var s1 = section1.AddStep("foo1"); var s2 = section1.AddStep("foo1"); var s3 = section1.AddStep("foo1"); var section2 = s3.AddCollection("rows"); var s4 = section2.AddStep("r1"); var s5 = section2.AddStep("r1"); var s6 = section2.AddStep("r1"); spec.Children.Add(section1); var c2 = new Comment(); spec.Children.Add(c2); spec.NeedsToBeRenumbered().ShouldBeFalse(); }
protected bool Equals(Specification other) { return(string.Equals(id, other.id)); }