public static async Task <HttpResponseMessage> Run(
     [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "v1/docs")]
     HttpRequestMessage req,
     TraceWriter log)
 {
     return(LaunchPad.ShowSwaggerHtmlResponse(req, new TraceLogger(log)));
 }
示例#2
0
        public async Task <LaunchPad> GetLaunchPadInfoByNameAsync(string padname)
        {
            LaunchPad lp;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(SpaceXUriString);
                var response = await client.GetAsync($"/v2/launchpads/{padname}");

                response.EnsureSuccessStatusCode();
                var stringResult = await response.Content.ReadAsStringAsync();

                lp = JsonConvert.DeserializeObject <LaunchPad>(stringResult);
                if (lp == null)
                {
                    lp = new LaunchPad()
                    {
                        Id = string.Empty, Name = "Launchpad not found", Status = string.Empty
                    }
                }
                ;
            }
            return(lp);
        }
    }
        public void SpaceXFormatDeserializesFromSnakeToPascalCasing()
        {
            ReusableHttpClient client = new ReusableHttpClient();

            LaunchPad result = client.DeserializeJson <LaunchPad>(sampleLaunchPadJson);

            Assert.IsNotNull(result);

            Assert.AreEqual(5, result.AttemptedLaunches);
            Assert.AreEqual(
                "SpaceX original launch site, where all of the Falcon 1 launches occured. Abandoned as SpaceX decided against upgrading the pad to support Falcon 9.",
                result.Details
                );
            Assert.AreEqual("Kwajalein Atoll Omelek Island", result.FullName);
            Assert.AreEqual("kwajalein_atoll", result.Id);
            Assert.AreEqual(1, result.PadId);
            Assert.AreEqual("retired", result.Status);
            Assert.AreEqual(2, result.SuccessfulLaunches);
            Assert.AreEqual("https://en.wikipedia.org/wiki/Omelek_Island", result.Wikipedia);

            Assert.IsNotNull(result.VehiclesLaunched);
            Assert.AreEqual(1, result.VehiclesLaunched.Count);
            Assert.AreEqual("Falcon 1", result.VehiclesLaunched[0]);

            Assert.IsNotNull(result.Location);
            Assert.AreEqual("Omelek Island", result.Location.Name);
            Assert.AreEqual(167.7431292M, result.Location.Longitude);
            Assert.AreEqual(9.0477206M, result.Location.Latitude);
            Assert.AreEqual("Marshall Islands", result.Location.Region);
        }
示例#4
0
        public async Task <IEnumerable <LaunchPad> > GetLaunchPadInfoAsync()
        {
            IList <LaunchPad> lpList;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(SpaceXUriString);
                var response = await client.GetAsync($"/v2/launchpads");

                response.EnsureSuccessStatusCode();
                var stringResult = await response.Content.ReadAsStringAsync();

                lpList = JsonConvert.DeserializeObject <IList <LaunchPad> >(stringResult);
                if (lpList == null)
                {
                    lpList = new List <LaunchPad>();
                    LaunchPad lp = new LaunchPad()
                    {
                        Id = string.Empty, Name = "Launchpad Info not found", Status = string.Empty
                    };
                    lpList.Add(lp);
                }
            }
            return(lpList);
        }
 // Use this for initialization
 void Start()
 {
     launchPad        = GameObject.FindObjectOfType <LaunchPad>();
     launchPosition   = launchPad.transform.position + new Vector3(launchPosition.x, 3, launchPosition.z);
     rocketController = GameObject.FindObjectOfType <RocketController>();
     levelManager     = GameObject.FindObjectOfType <LevelManager>();
 }
示例#6
0
        public async Task TestGetByLaunchNameFailure()
        {
            string           launchPadName = "area_51";
            SpaceXController spx           = new SpaceXController(_repo, _logger);
            LaunchPad        pad           = await spx.Get(launchPadName);

            Assert.IsFalse(pad.Id == launchPadName);
        }
示例#7
0
        public async Task TestGetByLaunchNameSuccess()
        {
            string           launchPadName = "ksc_lc_39a";
            SpaceXController spx           = new SpaceXController(_repo, _logger);
            LaunchPad        pad           = await spx.Get(launchPadName);

            Assert.IsTrue(pad.Id == launchPadName);
        }
示例#8
0
        public LaunchPad GetPad(int padId)
        {
            var pad1 = new LaunchPad();

            pad1.PadId = padId;
            pad1.Name  = "pad " + padId.ToString();
            return(pad1);
        }
 public static async Task <HttpResponseMessage> GetStuff(
     [HttpTrigger(AuthorizationLevel.Function, "get", Route = "v1/getstuff")]
     HttpRequestMessage req,
     TraceWriter log)
 {
     // Launchpad will automatically call Handler.GetStuff - it always looks
     // for a method on the handler with the same name as this one.
     return(await LaunchPad.ExecuteHttpTrigger(req, new TraceLogger(log)));
 }
示例#10
0
        private void button1_Click(object sender, EventArgs e)
        {
            string id = "";

            foreach (var emulator in emulators)
            {
                if (emulator.Value == comboBox1.Text)
                {
                    id = emulator.Key;
                }
            }

            if (id != "")
            {
                string[] toks = comboBox1.Text.Split(':');
                if (toks.Length == 2)
                {
                    string platformFileName = Path.Combine(Path.GetDirectoryName(textBox1.Text), "Data", "Platforms", toks[0] + ".xml");
                    if (File.Exists(platformFileName))
                    {
                        if (File.Exists(platformFileName + ".bak"))
                        {
                            File.Delete(platformFileName + ".bak");
                        }
                        File.Move(platformFileName, platformFileName + ".bak");
                    }

                    using (StreamWriter sw = new StreamWriter(platformFileName))
                    {
                        sw.WriteLine("<?xml version=\"1.0\" standalone=\"yes\"?>");
                        sw.WriteLine("<LaunchBox>");
                        int count = 0;
                        foreach (var game in model.GameData)
                        {
                            if (games == null || games.Contains(game.Value.Name))
                            {
                                if (LaunchPad.GetId(game.Value.Name) != "")
                                {
                                    count++;
                                    sw.WriteLine("<Game>");
                                    sw.WriteLine("  <ApplicationPath>" + Xml.XmlEscape(game.Value.LaunchFile) + "</ApplicationPath>");
                                    sw.WriteLine("  <Emulator>" + id + "</Emulator>");
                                    sw.WriteLine("  <Platform>" + toks[0] + "</Platform>");
                                    sw.WriteLine("  <Title>" + Xml.XmlEscape(game.Value.Name) + "</Title>");
                                    sw.WriteLine("  <Id>" + LaunchPad.GetId(game.Value.Name) + "</Id>");
                                    sw.WriteLine("  <PlayCount>" + game.Value.PlayCount + "</PlayCount>");
                                    sw.WriteLine("</Game>");
                                }
                            }
                        }
                        sw.WriteLine("</LaunchBox>");
                        MessageBox.Show(Resources.FormLaunchboxExporter_button1_Click_Successfully_exported_ + count + Resources.FormLaunchboxExporter_button1_Click__games_to_LaunchBox);
                    }
                }
            }
        }
示例#11
0
        public async Task Repo_GetListThenIndividualLaunchPad_ReturnsMatchingLaunchpad()
        {
            LaunchpadApiRepository repo          = new LaunchpadApiRepository(_configuration, _logger);
            List <LaunchPad>       launchPadList = await repo.GetAllAsync();

            LaunchPad launchpad = await repo.GetAsync(launchPadList[0].Id);

            Assert.NotNull(launchpad);
            Assert.True(launchPadList[0].Equals(launchpad));
        }
示例#12
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Interior Resource")
     {
         overResources.Add(collision.gameObject);
     }
     else if (collision.tag == "Launch Pad")
     {
         overPad = collision.gameObject.GetComponent <LaunchPad>();
     }
 }
        public LaunchPadProfile_Should()
        {
            var fixture = new Fixture();

            spaceXResponse = fixture.Create <SpaceXLaunchPadResponse>();

            var config = new MapperConfiguration(cfg => cfg.AddProfile <LaunchPadProfile>());
            var mapper = config.CreateMapper();

            launchPad = mapper.Map <LaunchPad>(spaceXResponse);
        }
示例#14
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.tag == "Interior Resource")
     {
         overResources.Remove(collision.gameObject);
     }
     else if (collision.tag == "Launch Pad")
     {
         overPad = null;
     }
 }
示例#15
0
        public void Ok_ConvertsOutput_ToJson()
        {
            // valuetypes are serialized as one element value array
            var target = new LaunchPad();
            var result = LaunchPad.Ok("A string");

            AssertEx.AreEqual(HttpStatusCode.OK, result.StatusCode);

            var expectedResult = new ServiceResponse("A string");

            AssertEx.AreEqual(JsonConvert.SerializeObject(expectedResult, Formatting.Indented), result.Content.ReadAsStringAsync().Result);
        }
示例#16
0
        public async Task GetSingleLaunchPad_RequestIdMatchesResponseId()
        {
            HttpResponseMessage listResponse = await _client.GetAsync("api/launchpad");

            List <LaunchPad>    launchPadList           = JsonConvert.DeserializeObject <List <LaunchPad> >(await listResponse.Content.ReadAsStringAsync());
            LaunchPad           firstLaunchPad          = launchPadList[0];
            HttpResponseMessage singleLaunchPadResponse = await _client.GetAsync("api/launchpad/" + firstLaunchPad.Id);

            LaunchPad singleLaunchPad = JsonConvert.DeserializeObject <LaunchPad>(await singleLaunchPadResponse.Content.ReadAsStringAsync());

            Assert.False(singleLaunchPad == null);
            Assert.True(firstLaunchPad.Equals(singleLaunchPad));
        }
示例#17
0
        private void OnEnable()
        {
            vectorAProperty       = serializedObject.FindProperty("launchVelocityA");
            vectorBProperty       = serializedObject.FindProperty("launchVelocityB");
            seconRotationProperty = serializedObject.FindProperty("secondaryRotation");
            primRotationProperty  = serializedObject.FindProperty("primaryRotation");

            pad         = target as LaunchPad;
            transform   = pad.transform;
            pivot       = pad.Pivot;
            g           = Mathf.Abs(Physics.gravity.y);
            recalculate = true;
        }
示例#18
0
        /// <summary>
        /// Runs light.exe on the compiled wixobj files to generate the final MSI file.
        /// </summary>
        /// <param name="outputPane">The window to which to output build messages.</param>
        /// <returns><see langword="true"/> if successful; otherwise, <see langword="false"/>.</returns>
        private bool Link(IVsOutputWindowPane outputPane)
        {
            Tracer.VerifyNonNullArgument(outputPane, "outputPane");

            string projectRootDirectory = this.Project.RootDirectory;

            string[] sourceFiles       = this.GetSourceFiles();
            string[] objectFiles       = this.Candle.GetOutputFiles(sourceFiles);
            string[] localizationFiles = this.GetLocalizationFiles();
            string[] referenceFiles    = this.GetReferenceFiles();
            string   lightParams       = this.Light.ConstructCommandLineParameters(projectRootDirectory, objectFiles, localizationFiles, referenceFiles);
            string   toolsPath         = WixPackage.Instance.Context.Settings.ToolsDirectory;

            // Do not quote the path here. It will be quoted in the LaunchPad
            string lightExePath = PackageUtility.CanonicalizeFilePath(Path.Combine(toolsPath, "light.exe"));

            // See if light.exe exists.
            if (!File.Exists(lightExePath))
            {
                this.WriteLineToOutputWindow("Error: Cannot find light.exe at '{0}'.", lightExePath);
                this.WriteLineToOutputWindow();
                return(false);
            }

            // Create the launch pad used for linking.
            LaunchPad lightLaunchPad = new LaunchPad(lightExePath, lightParams);

            lightLaunchPad.WorkingDirectory = projectRootDirectory;

            // Output the light command line to the build output window.
            Tracer.WriteLineInformation(classType, "Link", "Linking...");
            this.WriteLineToOutputWindow();
            this.WriteLineToOutputWindow("Linking...");
            this.WriteLineToOutputWindow(lightLaunchPad.CommandLine);
            this.WriteLineToOutputWindow();

            // Tick once and see if we should continue.
            if (!this.TickBuild())
            {
                return(false);
            }

            // Delete the existing .msi file if it exists.
            this.CleanLinkOutput();

            // Execute light.exe piping the output to the output build window and the task pane.
            bool successful = (lightLaunchPad.ExecuteCommand(outputPane, this) == 0);

            return(successful);
        }
示例#19
0
        public void SafelyTry_ReturnsError_OnException()
        {
            // valuetypes are serialized as one element value array
            var target     = new LaunchPad();
            var mockLogger = new MockLogger();


            var result = target.SafelyTry(mockLogger, () => throw new Exception("bob wins"));

            AssertEx.AreEqual(HttpStatusCode.InternalServerError, result.StatusCode);

            var stuff = JsonConvert.DeserializeObject <TestResponse>(
                result.Content.ReadAsStringAsync().Result);

            AssertEx.StartsWith("There was a fatal service error.", stuff.ErrorMessage);
        }
示例#20
0
        public void SafelyTry_ReturnsRawValue_WhenHttpResponseMessage()
        {
            // valuetypes are serialized as one element value array
            var target     = new LaunchPad();
            var mockLogger = new MockLogger();
            var output     = new HttpResponseMessage(HttpStatusCode.PartialContent)
            {
                Content = new StringContent("Gubmy")
            };

            var result = target.SafelyTry(mockLogger, () => output);

            AssertEx.AreEqual(HttpStatusCode.PartialContent, result.StatusCode);

            AssertEx.AreEqual("Gubmy", result.Content.ReadAsStringAsync().Result);
        }
示例#21
0
        public void SafelyTry_ReturnsStandardResponseObject_OnSuccess()
        {
            // valuetypes are serialized as one element value array
            var target     = new LaunchPad();
            var mockLogger = new MockLogger();
            var result     = target.SafelyTry(mockLogger, () => "Hi");

            AssertEx.AreEqual(HttpStatusCode.OK, result.StatusCode);

            var stuff = JsonConvert.DeserializeObject <TestResponse>(
                result.Content.ReadAsStringAsync().Result);

            AssertEx.AreEqual(null, stuff.ErrorMessage);
            AssertEx.AreEqual(1, stuff.Count);
            AssertEx.AreEqual(new string[] { "Hi" }, stuff.Values);
        }
示例#22
0
    public void PadReady(LaunchPad pad)
    {
        readyPads.Add(pad);

        if (readyPads.Count == 2)
        {
            if (readyPads[0].SceneID == readyPads[1].SceneID)
            {
                Debug.Log("Role Strings = " + readyPads[0].Role.ToString() + " and " + readyPads[1].Role.ToString());
                PlayerPrefs.SetInt(readyPads[0].Role.ToString(), (int)readyPads[0].ReadyID); // TODO read this on mission scenes
                PlayerPrefs.SetInt(readyPads[1].Role.ToString(), (int)readyPads[1].ReadyID);

                sceneID = readyPads[0].SceneID;
                GetComponent <SceneTransitionAnimator>().PlayLeaveStationTransition(LoadScene);
            }
        }
    }
示例#23
0
        public void Error_ReturnsNonFatal_OnServiceException()
        {
            var target     = new LaunchPad();
            var mockLogger = new MockLogger();
            var output     = new ServiceOperationException(ServiceOperationError.BadParameter, "Yuba bears");
            var result     = LaunchPad.Error(output, mockLogger);

            AssertEx.AreEqual(HttpStatusCode.BadRequest, result.StatusCode);
            AssertEx.AreEqual(1, mockLogger.Logs.Count);

            var stuff = JsonConvert.DeserializeObject <TestResponse>(
                result.Content.ReadAsStringAsync().Result);

            AssertEx.AreEqual(0, stuff.Count);
            AssertEx.AreEqual(new string[0], stuff.Values);
            AssertEx.AreEqual(ServiceOperationError.BadParameter.ToString(), stuff.ErrorCode);
            AssertEx.StartsWith("Yuba bears\r\nThe Log Key for this error is", stuff.ErrorMessage);
        }
        public void Ok_ConvertsOutput_ToJson()
        {
            // valuetypes are serialized as one element value array
            var target = new LaunchPad();
            var result = target.Ok("A string");

            AssertEx.AreEqual(HttpStatusCode.OK, result.StatusCode);
            AssertEx.AreEqual(
                @"{
  ""Count"": 1,
  ""ErrorCode"": null,
  ""Values"": [
    ""A string""
  ],
  ""ErrorMessage"": null
}"
                , result.Content.ReadAsStringAsync().Result);
        }
示例#25
0
        public void Error_ReturnsFatal_OnNormalException()
        {
            var target     = new LaunchPad();
            var mockLogger = new MockLogger();
            var output     = new RandomException("Bumper Boats", "Abba\\Dabba\\foobar:line 232\r\nShoe\\Lollipop\\gumby:line 444");
            var result     = LaunchPad.Error(output, mockLogger);

            AssertEx.AreEqual(HttpStatusCode.InternalServerError, result.StatusCode);
            AssertEx.AreEqual(1, mockLogger.Logs.Count);

            var stuff = JsonConvert.DeserializeObject <TestResponse>(
                result.Content.ReadAsStringAsync().Result);

            AssertEx.AreEqual(0, stuff.Count);
            AssertEx.AreEqual(new string[0], stuff.Values);
            AssertEx.AreEqual(ServiceOperationError.FatalError.ToString(), stuff.ErrorCode);
            AssertEx.StartsWith("There was a fatal service error.\r\nThe Log Key for this error is", stuff.ErrorMessage);
            AssertEx.EndsWith("Debug hint: Bumper Boats (foobar:line 232)", stuff.ErrorMessage);
        }
        public async Task <IActionResult> Get(string id)
        {
            try
            {
                LaunchPad launchPad = await _launchPadRepository.GetAsync(id);

                if (launchPad == null)
                {
                    return(StatusCode(204, "No results found"));
                }
                else
                {
                    return(Ok(launchPad));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.ToString()));
            }
        }
示例#27
0
        public async Task <List <LaunchPad> > GetAllPads()
        {
            var padList = new List <LaunchPad>();
            // this needs to come from config object
            var path = "https://api.spacexdata.com/v2/launchpads";

            HttpResponseMessage response = await _client.GetAsync(path);

            var pads = await response.Content.ReadAsStringAsync();

            var pad1 = new LaunchPad();

            pad1.PadId = 1;
            pad1.Name  = "pad one";
            padList.Add(pad1);

            var pad2 = new LaunchPad();

            pad2.PadId = 2;
            pad2.Name  = "pad two";
            padList.Add(pad2);

            return(padList);
        }
示例#28
0
 public void PadUnready(LaunchPad pad)
 {
     readyPads.Remove(pad);
 }
示例#29
0
        public LaunchPadFilter_FilterProperties_Should()
        {
            var fixture = new Fixture();

            launchPad = fixture.Create <LaunchPad>();
        }
示例#30
0
        /// <summary>
        /// Runs candle.exe on the source files to generate a list of wixobj intermediate files.
        /// </summary>
        /// <param name="outputPane">The window to which to output build messages.</param>
        /// <returns><see langword="true"/> if successful; otherwise, <see langword="false"/>.</returns>
        private bool Compile(IVsOutputWindowPane outputPane)
        {
            Tracer.VerifyNonNullArgument(outputPane, "outputPane");

            string projectRootDirectory = this.Project.RootDirectory;

            // Get the list of source files that should be built
            string[] sourceFiles = this.GetOutOfDateSourceFiles();

            // If we don't have anything to compile, then just show a message indicating that
            if (sourceFiles.Length == 0)
            {
                this.WriteLineToOutputWindow("Compile targets are up to date.");
                this.WriteLineToOutputWindow();
                return(true);
            }

            string[] objectFiles  = this.Candle.GetOutputFiles(sourceFiles);
            string   candleParams = this.Candle.ConstructCommandLineParameters(projectRootDirectory, sourceFiles);
            string   toolsPath    = WixPackage.Instance.Context.Settings.ToolsDirectory;

            // Do not quote the path here. It will be quoted in the LaunchPad
            string candleExePath = PackageUtility.CanonicalizeFilePath(Path.Combine(toolsPath, "candle.exe"));

            // See if candle exists
            if (!File.Exists(candleExePath))
            {
                this.WriteLineToOutputWindow("Error: Cannot find candle.exe at '{0}'.", candleExePath);
                this.WriteLineToOutputWindow();
                return(false);
            }

            // Create the launch pad used for compilation.
            LaunchPad candleLaunchPad = new LaunchPad(candleExePath, candleParams);

            candleLaunchPad.WorkingDirectory = projectRootDirectory;

            // Output the candle command line to the build output window.
            Tracer.WriteLineInformation(classType, "Compile", "Performing main compilation...");
            this.WriteLineToOutputWindow("Performing main compilation...");
            this.WriteLineToOutputWindow(candleLaunchPad.CommandLine);
            this.WriteLineToOutputWindow();

            // Tick once and see if we should continue.
            if (!this.TickBuild())
            {
                return(false);
            }

            // Make sure the output directory exists.
            string outputDir = this.Candle.AbsoluteOutputDirectory;

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            // Delete the existing .wixobj files if they exist.
            this.CleanCompileOutput(sourceFiles);

            // Execute candle.exe piping the output to the output build window and the task pane.
            bool successful = (candleLaunchPad.ExecuteCommand(outputPane, this) == 0);

            // Clean up the temporary candle files after the compile has completed.
            this.Candle.CleanTemporaryFiles();

            return(successful);
        }