From 20d99d26a7f9ee32f86979c560cd9f3495ab2f07 Mon Sep 17 00:00:00 2001 From: Isaac Levin <8878502+isaac2004@users.noreply.github.com> Date: Fri, 24 May 2019 12:15:18 -0400 Subject: [PATCH] test updates --- .../Controllers/WeatherController.fs | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Controllers/WeatherController.fs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Controllers/WeatherController.fs index a87e5fdf33..d82bbc47f9 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Controllers/WeatherController.fs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Controllers/WeatherController.fs @@ -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 +} + [] [] type WeatherController () = inherit ControllerBase() [] - member this.Get(location:string, unit:TemperatureUnit) = + [] + 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,unit) + :?> TemperatureUnit + } ActionResult(result) [] + [] 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(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