Exemplo n.º 1
0
        public StorytellerRunner(ISystem system, string specDirectory = null)
        {
            Debug.WriteLine("StorytellerRunner is starting up for system " + system);

            SpecDirectory = specDirectory ?? GuessSpecDirectory(system);

            _system   = system;
            _library  = FixtureLibrary.CreateForAppDomain(_system.Start());
            Hierarchy = HierarchyLoader.ReadHierarchy(SpecDirectory).ToHierarchy();

            _warmup = _system.Warmup();
        }
Exemplo n.º 2
0
        public SpecRunner(string specDirectory = null)
        {
            Debug.WriteLine("SpecRunner is starting up for system " + typeof(T).FullName);
            Debug.WriteLine("using {0} as the configuration file", AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);

            SpecDirectory = specDirectory ?? GuessSpecDirectory();

            _system    = new T();
            _library   = FixtureLibrary.CreateForAppDomain(_system.Start());
            _hierarchy = HierarchyLoader.ReadHierarchy(SpecDirectory).ToHierarchy();

            _warmup = _system.Warmup();
        }
Exemplo n.º 3
0
        public void builds_for_all_the_non_hidden_fixtures()
        {
            var library = FixtureLibrary.CreateForAppDomain(CellHandling.Basic());


            library.Fixtures["Open"].ShouldBeOfType <OpenFixture>();

            // aliased fixture

            library.Fixtures["HanSolo"].ShouldBeOfType <AliasedFixture>();

            library.Fixtures.Has(new SecretFixture().Key).ShouldBe(false);
        }
Exemplo n.º 4
0
        private RunningSystem(ISystem system)
        {
            CellHandling cellHandling = null;

            System = system;

            try
            {
                cellHandling = system.Start() ?? CellHandling.Basic();

                System = cellHandling.Extensions.Any() ? new CompositeSystem(system, cellHandling) : system;
            }
            catch (Exception ex)
            {
                ConsoleWriter.Write(ConsoleColor.Red, ex.ToString());

                RecycledMessage = new SystemRecycled
                {
                    success          = false,
                    fixtures         = new FixtureModel[0],
                    system_name      = system.ToString(),
                    system_full_name = system.GetType().FullName,
#if NET46
                    name = Path.GetFileName(AppDomain.CurrentDomain.BaseDirectory),
#else
                    name = Path.GetFileName(AppContext.BaseDirectory),
#endif

                    error = ex.ToString()
                };

                return;
            }


            Fixtures = FixtureLibrary.CreateForAppDomain(cellHandling);

            RecycledMessage = new SystemRecycled
            {
                success     = true,
                fixtures    = Fixtures.Models.GetAll().ToArray(),
                system_name = system.ToString(),
#if NET46
                name = Path.GetFileName(AppDomain.CurrentDomain.BaseDirectory)
#else
                name = Path.GetFileName(AppContext.BaseDirectory)
#endif
            };
        }
Exemplo n.º 5
0
        public void serialize_fixtures()
        {
            var library = FixtureLibrary.CreateForAppDomain(CellHandling.Basic());

            // CreateLocation
            // AddressVerification

            var fixtureModels = library.Models.GetAll().ToArray();

            var json = JsonSerialization.ToJson(fixtureModels);

            var models = JsonSerialization.Deserialize <FixtureModel[]>(json);

            models.Each(x => Debug.WriteLine(x.key));
        }
 static TestingContext()
 {
     _library = new Lazy <FixtureLibrary>(() =>
     {
         try
         {
             var fixture = new SentenceFixture();
             return(FixtureLibrary.CreateForAppDomain(new GrammarSystem().Start()));
         }
         catch (Exception e)
         {
             Console.WriteLine(e.ToString());
             throw;
         }
     });
 }
Exemplo n.º 7
0
        public static SystemRecycled Initialize(this ISystem system, Action <FixtureLibrary> onStarted)
        {
            CellHandling cellHandling = null;

            try
            {
                cellHandling = system.Start() ?? CellHandling.Basic();
            }
            catch (Exception ex)
            {
                ConsoleWriter.Write(ConsoleColor.Red, ex.ToString());

                var message = new SystemRecycled
                {
                    success          = false,
                    fixtures         = new FixtureModel[0],
                    system_name      = system.ToString(),
                    system_full_name = system.GetType().FullName,
#if NET46
                    name = Path.GetFileName(AppDomain.CurrentDomain.BaseDirectory),
#else
                    name = Path.GetFileName(AppContext.BaseDirectory),
#endif

                    error = ex.ToString()
                };

                return(message);
            }


            var library = FixtureLibrary.CreateForAppDomain(cellHandling);

            onStarted(library);

            return(new SystemRecycled
            {
                success = true,
                fixtures = library.Models.GetAll().ToArray(),
                system_name = system.ToString(),
#if NET46
                name = Path.GetFileName(AppDomain.CurrentDomain.BaseDirectory)
#else
                name = Path.GetFileName(AppContext.BaseDirectory)
#endif
            });
Exemplo n.º 8
0
        private SystemRecycled tryToStart()
        {
            CellHandling cellHandling = null;

            try
            {
                cellHandling = _system.Start();
            }
            catch (Exception ex)
            {
                ConsoleWriter.Write(ConsoleColor.Red, ex.ToString());

                var message = new SystemRecycled
                {
                    success          = false,
                    fixtures         = new FixtureModel[0],
                    system_name      = _system.ToString(),
                    system_full_name = _system.GetType().FullName,
                    name             = Path.GetFileName(AppContext.BaseDirectory),
                    error            = ex.ToString()
                };

                return(message);
            }


            var library = FixtureLibrary.CreateForAppDomain(cellHandling);

            startTheConsumingQueues(library);

            return(new SystemRecycled
            {
                success = true,
                fixtures = library.Models.GetAll().ToArray(),
                system_name = _system.ToString(),
                name = Path.GetFileName(AppContext.BaseDirectory)
            });
        }
        static TestingContext()
        {
            _library = new Lazy <FixtureLibrary>(() =>
            {
                try
                {
                    var fixture = new SentenceFixture();
                    var library = FixtureLibrary.CreateForAppDomain(new GrammarSystem().Start());

                    // Need to force it to use this one instead of the FactFixture in the samples project
                    var factFixture          = new StoryTeller.Testing.EndToEndExecution.FactFixture();
                    library.Models["Fact"]   = factFixture.Compile(CellHandling.Basic());
                    library.Fixtures["Fact"] = factFixture;

                    return(library);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    throw;
                }
            });
        }
Exemplo n.º 10
0
        static TestingContext()
        {
            var fixture = new StoryTeller.Samples.Fixtures.SentenceFixture();

            Library = FixtureLibrary.CreateForAppDomain(new GrammarSystem().Start());
        }
Exemplo n.º 11
0
        public SpecRunner()
        {
            _system = new T();

            _library = FixtureLibrary.CreateForAppDomain(_system.Start());
        }