public TestRun CreateTestRun(xb.TestRun testRun)
 {
     return new TestRun()
     {
         Name = testRun.Name
     };
 }
 public TestRun BuildTestRun(xb.TestRun testRun)
 {
     var testRunDb = factory.CreateTestRun(testRun);
     dbContext.TestRuns.Add(testRunDb);
     BuildScenarios(testRun, testRunDb);
     return testRunDb;
 }
 private void BuildSteps(xb.Scenario scenario, Scenario scenarioDb)
 {
     foreach(var step in scenario.Steps)
     {
         Step stepDb = factory.CreateStep(step, scenarioDb);
         stepDb.Scenario = scenarioDb;
         dbContext.Steps.Add(stepDb);
     }
 }
        public int SaveTestRun(xb.TestRun testRun)
        {
            DatabaseContext dbContext = factory.CreatexBDDDbContext(connectionName);
            DatabaseObjectBuilder dbObjectBuilder = factory.CreateDatabaseObjectBuilder(dbContext);
            TestRun testRunDb = dbObjectBuilder.BuildTestRun(testRun);
            dbContext.EnsureDatabase();
            var count = dbContext.SaveChanges();
            Console.WriteLine("There were " + count + " entries written to the " + dbContext.DatabaseName + " on the " + dbContext.ServerName);
            return count;

        }
 public Scenario CreateScenario(xb.Scenario scenario, TestRun testRun)
 {
     return new Scenario()
     {
         AreaPath = scenario.Feature.Area.Name,
         FeatureName = scenario.Feature.Name,
         Name = scenario.Name,
         Outcome = scenario.Outcome,
         Reason = scenario.Reason,
         EndTime = scenario.EndTime,
         TestRun = testRun,
         StartTime = scenario.StartTime
     };
 }
 public Step CreateStep(xb.Step step, Scenario scenario)
 {
     return new Step()
     {
         EndTime = step.EndTime,
         Exception = step.Exception == null ? null : step.Exception.Message + "\n" + step.Exception.StackTrace,
         Name = step.Name,
         Outcome = step.Outcome,
         Reason = step.Reason,
         Scenario = scenario,
         StartTime = step.StartTime,
         MultilineParameter = step.MultilineParameter
     };
 }
 private void BuildScenarios(xb.TestRun testRun, TestRun testRunDb)
 {
     var scenarios = from area in testRun.Areas
                     from feature in area.Features
                     from scenario in feature.Scenarios
                     select scenario; 
     foreach(xb.Scenario scenario in scenarios)
     {
         Scenario scenarioDb = factory.CreateScenario(scenario, testRunDb);
         scenarioDb.TestRun = testRunDb;
         dbContext.Scenarios.Add(scenarioDb);
         BuildSteps(scenario, scenarioDb);
     }
 }