Ejemplo n.º 1
0
        public async Task DeployLocally(FileInfo csdl, string portString, bool seedData)
        {
            if (csdl != null)
            {
                app.Out.WriteLine($"Schema Path: {csdl.FullName}");
            }

            Random r    = new Random();
            int    port = r.Next(4000, 9000);

            if (!string.IsNullOrEmpty(portString))
            {
                port = int.Parse(portString);
            }

            string Schema = File.ReadAllText(csdl.FullName);

            var args = new ProjectRunArgs()
            {
                SeedData = seedData
            };

            var image = await imageProvider.GetCredentials();

            app.Out.WriteLine("Updating core service...");
            var updater = new ServiceUpdater(image);

            updater.UpdateService();

            using (var serverRunner = new LocalRunner(csdl.FullName, port, args, image))
            {
                Console.CancelKeyPress += (sender, args) =>
                {
                    // dispose server if terminated with Ctrl+C
                    serverRunner.Stop();
                    Environment.Exit(0);
                };

                serverRunner.OnError        = e => app.Error.WriteLine(e.Message);
                serverRunner.OnSchemaChange = () => app.Out.WriteLine($"Changes detected to {csdl.FullName}...");
                serverRunner.BeforeRestart  = (path, port) => app.Out.WriteLine("Restarting server...");
                serverRunner.AfterRestart   = (path, port) => app.Out.WriteLine($"Server running on http://localhost:{port}/odata");
                serverRunner.OnTerminate    = () => app.Out.WriteLine("Terminating server...");
                serverRunner.Start();

                app.Out.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
        }
Ejemplo n.º 2
0
        public void GetListOfEntries()
        {
            string  RawOutputString = null;
            JObject RawOutputJSON   = null;

            "Given raw output string by calling LocalRunner"
            .x(() => RawOutputString = new LocalRunner().FetchRawOutput());
            "And parse raw output string to raw output JSON"
            .x(() => RawOutputJSON = JObject.Parse(RawOutputString));
            "And select correct parser based on rawoutput"
            .x(() => Parser = new Functions().SelectCustomer(RawOutputString));
            "When I extract entires from raw output JSON"
            .x(() => this.ListOfEntries = new Functions().ExtractText(RawOutputJSON));
            "Then the list of entries should have more than one entry"
            .x(() => Assert.True(this.ListOfEntries.Count > 1));
        }