public HierarchyLoaded(Suite top, ResultsCache results)
            : base("hierarchy-loaded")
        {
            hierarchy = top;

            specs = top.GetAllSpecs().Select(x => new SpecRecord(x, results)).ToArray();
        }
        // The time comparison is off from using DateTime.UtcNow [Fact]
        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 SpecRecord(Specification data, ResultsCache cache)
 {
     this.data = data;
     LastResults = cache.LastResultFor(data.id);
 }
 public SpecRecord(Specification data, ResultsCache cache)
 {
     this.data   = data;
     LastResults = cache.LastResultFor(data.id);
 }
        public HierarchyLoaded(Suite top, ResultsCache results) : base("hierarchy-loaded")
        {
            hierarchy = top;

            specs = top.GetAllSpecs().Select(x => new SpecRecord(x, results)).ToArray();
        }
 public void SetUp()
 {
     theCache = new ResultsCache();
 }