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(); }
public void get_all_results() { var result1 = new SpecExecutionCompleted("foo", new SpecResults(), new Specification()); theCache.Store(result1); var result2 = new SpecExecutionCompleted("bar", new SpecResults(), new Specification()); theCache.Store(result2); var result3 = new SpecExecutionCompleted("foo", new SpecResults(), new Specification()); theCache.Store(result3); var result4 = new SpecExecutionCompleted("bar", new SpecResults(), new Specification()); theCache.Store(result4); var result5 = new SpecExecutionCompleted("foo", new SpecResults(), new Specification()); theCache.Store(result5); var result6 = new SpecExecutionCompleted("bar", new SpecResults(), new Specification()); theCache.Store(result6); var all = theCache.AllResults().ToArray(); all.Count().ShouldBe(6); all.ShouldContain(result1); all.ShouldContain(result2); all.ShouldContain(result3); all.ShouldContain(result4); all.ShouldContain(result5); all.ShouldContain(result6); }
public void caches_the_last_execution_for_a_suite() { var completed = new SpecExecutionCompleted("sentence4", new SpecResults(), new Specification()); ClassUnderTest.Receive(completed); ClassUnderTest.AllCachedResults().ShouldContain(completed); }
public void Store(SpecExecutionCompleted result) { var queue = _results[result.Id]; queue.Enqueue(result); while (queue.Count > 5) { queue.Dequeue(); } }
public void load_specification_returns_the_specifiction_and_result_if_it_exists() { var theResults = new SpecResults(); var completed = new SpecExecutionCompleted("sentence4", theResults, new Specification()); ClassUnderTest.Receive(completed); var message = ClassUnderTest.LoadSpecification("sentence4"); message.id.ShouldBe("sentence4"); message.data.ShouldBeOfType <Specification>().id.ShouldBe("sentence4"); message.results.ShouldContain(completed); }
public void write_initial_model() { // You need to compile everything before trying to use this var input = new ProjectInput { Path = AppDomain.CurrentDomain.BaseDirectory.ParentDirectory() .ParentDirectory() .ParentDirectory() .AppendPath("Storyteller.Samples"), ProfileFlag = "Safari" }; using (var controller = input.BuildRemoteController()) { controller.Start(EngineMode.Batch).Wait(30.Seconds()); var hierarchy = HierarchyLoader.ReadHierarchy(input.Path.AppendPath("Specs")); var request = new BatchRunRequest { SpecPath = input.SpecPath }; var response = controller.Send(request).AndWaitFor <BatchRunResponse>(); var cache = new ResultsCache(); response.Result.records.Each( x => { var completed = new SpecExecutionCompleted(x.specification.id, x.results, x.specification); cache.Store(completed); }); response.Result.fixtures = controller.LatestSystemRecycled.fixtures; var hierarchyLoaded = new HierarchyLoaded(hierarchy, cache); var initialization = new InitialModel(controller.LatestSystemRecycled, hierarchyLoaded) { wsAddress = "ws://localhost:" + 8200 }; writeResponse(response.Result); //writeInitialization(initialization); } }
public void last_counts() { var c = new ResultsCache(); var result1 = new SpecExecutionCompleted("foo", new SpecResults(), new Specification()); c.Store(result1); var result2 = new SpecExecutionCompleted("bar", new SpecResults(), new Specification()); c.Store(result2); var result3 = new SpecExecutionCompleted("foo", new SpecResults { Counts = new Counts() }, new Specification()); c.Store(result3); c.LastResultFor("foo") .ShouldBe(result3); }
//[Fact] public void write_initial_model() { // You need to compile everything before trying to use this var input = new ProjectInput(EngineMode.Batch) { Path = samplesFolder, ProfileFlag = "Safari" }; using (var controller = input.BuildEngine()) { controller.Start().Wait(30.Seconds()); var hierarchy = HierarchyLoader.ReadHierarchy(input.Path.AppendPath("Specs")); var request = new BatchRunRequest { SpecPath = input.SpecPath }; var response = controller.Send(request).AndWaitFor <BatchRunResponse>(); var cache = new ResultsCache(); response.Result.records.Each( x => { var completed = new SpecExecutionCompleted(x.specification.id, x.results, x.specification); cache.Store(completed); }); response.Result.fixtures = controller.LatestSystemRecycled.fixtures; var hierarchyLoaded = new HierarchyLoaded(hierarchy, cache); writeResponse(response.Result); //writeInitialization(initialization); } }
public void retrieve_results_for_a_spec() { var result1 = new SpecExecutionCompleted("foo", new SpecResults(), new Specification()); theCache.Store(result1); var result2 = new SpecExecutionCompleted("bar", new SpecResults(), new Specification()); theCache.Store(result2); var result3 = new SpecExecutionCompleted("foo", new SpecResults(), new Specification()); theCache.Store(result3); var result4 = new SpecExecutionCompleted("bar", new SpecResults(), new Specification()); theCache.Store(result4); var result5 = new SpecExecutionCompleted("foo", new SpecResults(), new Specification()); theCache.Store(result5); var result6 = new SpecExecutionCompleted("bar", new SpecResults(), new Specification()); theCache.Store(result6); theCache.ResultsFor("foo").ShouldHaveTheSameElementsAs(result5, result3, result1); theCache.ResultsFor("bar").ShouldHaveTheSameElementsAs(result6, result4, result2); }
public void SetUp() { var controller = controllerForProject("Storyteller.Samples"); theListener = new PassthroughListener(); var task = controller.Start(EngineMode.Interactive).ContinueWith(t => { controller.Messaging.AddListener(theListener); return(controller.Send(new RunSpec { id = "embeds", spec = TestingContext.FindSpecification("embeds") }).AndWaitFor <SpecExecutionCompleted>()); }); task.Wait(); task.Result.Wait(1.Seconds()); theResults = task.Result.Result; controller.Messaging.RemoveListener(theListener); }
public void SpecExecutionFinished(Specification specification, SpecResults results) { var completed = new SpecExecutionCompleted(specification.id, results, specification); _completed.Add(specification.id, completed); }