Beispiel #1
0
        /// <summary>
        /// Get example function
        /// </summary>
        /// <returns></returns>
        public object GetExamples()
        {
            SolarCalculatorInput example = new SolarCalculatorInput()
            {
                Model        = "year",
                LocalTime    = "12:00:00",
                DateTimeSpan = new DateTimeSpan()
                {
                    StartDate = new DateTime(2010, 01, 01),
                    EndDate   = new DateTime(2010, 12, 31)
                },
                Geometry = new TimeSeriesGeometry()
                {
                    Point = new PointCoordinate()
                    {
                        Latitude  = 40,
                        Longitude = -105
                    },
                    Timezone = new Timezone()
                    {
                        Offset = -7,
                    }
                }
            };

            return(example);
        }
Beispiel #2
0
        public async Task <IActionResult> POSTSolarCalculator([FromBody] SolarCalculatorInput i)
        {
            WSSolar solar = new WSSolar();

            Utilities.ErrorOutput error = new Utilities.ErrorOutput();
            ITimeSeriesOutput     result;

            if (i is null)
            {
                result = error.ReturnError("Input Error: No inputs found in the request or inputs contain invalid formatting.");
            }
            else
            {
                result = await solar.RunSolarCalculator(i);
            }
            return(new ObjectResult(result));
        }
Beispiel #3
0
        public async Task MeteorologyValidRequests(string inputString)
        {
            string endpoint            = "api/meteorology/solar";
            SolarCalculatorInput input = JsonConvert.DeserializeObject <SolarCalculatorInput>(inputString);

            Debug.WriteLine("Integration Test: Solar controller; Endpoint: " + endpoint + "; Data source: " + input.Model);
            var response = await _client.PostAsync(
                endpoint,
                new StringContent(JsonConvert.SerializeObject(input), Encoding.UTF8, "application/json"));

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

            Assert.NotNull(result);
            TimeSeriesOutput resultObj = JsonConvert.DeserializeObject <TimeSeriesOutput>(result);

            Assert.Equal(365, resultObj.Data.Count);
        }