test updates

This commit is contained in:
Isaac Levin 2019-05-24 12:15:18 -04:00 committed by GitHub
parent 2a5f10488b
commit 20d99d26a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 25 deletions

View File

@ -1,4 +1,4 @@
namespace Company.WebApplication1.Controllers
namespace WebApplication1.Controllers
open System
open System.Collections.Generic
@ -6,40 +6,41 @@ open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore.Mvc
type public TemperatureUnit =
| Celsius=0
| Fahrenheit=1
type WeatherResult = {
Location: string
TemperatureUnit: TemperatureUnit
Temperature: int
}
[<Route("api/SampleData/[controller]")>]
[<ApiController>]
type WeatherController () =
inherit ControllerBase()
[<HttpGet>]
member this.Get(location:string, unit:TemperatureUnit) =
[<Route("GetWeatherByLocationWithUnit")>]
member this.Get(location:string, unit: string) =
let rnd = System.Random()
let result = new WeatherResult (Location = location, Temperature = rnd.Next(-20, 55), TemperatureUnit = unit)
let result:WeatherResult = {
Location = location;
Temperature = rnd.Next(-20,55);
TemperatureUnit = System.Enum.Parse(typeof<TemperatureUnit>,unit)
:?> TemperatureUnit
}
ActionResult<WeatherResult>(result)
[<HttpGet>]
[<Route("GetWeatherByLocation")>]
member this.Get(location:string) =
let rnd = System.Random()
let result = new WeatherResult (Location = location, Temperature = rnd.Next(-20, 55), TemperatureUnit = TemperatureUnit.Celsius)
let result:WeatherResult = {
Location = location;
Temperature = rnd.Next(-20,55);
TemperatureUnit = TemperatureUnit.Celsius
}
ActionResult<WeatherResult>(result)
type TemperatureUnit =
| Celsius
| Fahrenheit
type WeatherResult =
let mutable _temperature : int = 0;
let mutable _temperatureUnit : TemperatureUnit = null;
let mutable _location : string = null;
member x.Temperature
with public get() : int = _temperature
and public set(value) = _temperature <- value
member x.TemperatureUnit
with public get() : TemperatureUnit = _temperatureUnit
and public set(value) = _temperatureUnit <- value
member x.Location
with public get() : string = _location
and public set(value) = _location <- value