public WeatherAlertViewModel(WeatherAlert WeatherAlert) { AlertType = WeatherAlert.Type; AlertSeverity = WeatherAlert.Severity; Title = WeatherAlert.Title; Message = WeatherAlert.Message; TimeSpan sincePost = (DateTimeOffset.Now - WeatherAlert.Date); if (sincePost.TotalDays >= 1) #if WINDOWS_UWP { PostDate = string.Format(App.ResLoader.GetString("DateTime_DayAgo"), #elif __ANDROID__ PostDate = Application.Context.GetString(Resource.String.datetime_day_ago, #endif (int)Math.Floor(sincePost.TotalDays)); } else if (sincePost.TotalHours >= 1) #if WINDOWS_UWP { PostDate = string.Format(UWP.App.ResLoader.GetString("DateTime_HrAgo"), #elif __ANDROID__ { PostDate = Application.Context.GetString(Resource.String.datetime_hr_ago, #endif (int)Math.Floor(sincePost.TotalHours)); } else if (sincePost.TotalMinutes >= 1) #if WINDOWS_UWP PostDate = string.Format(UWP.App.ResLoader.GetString("DateTime_MinAgo"), #elif __ANDROID__ PostDate = Application.Context.GetString(Resource.String.datetime_min_ago, #endif (int)Math.Floor(sincePost.TotalMinutes)); }
public async Task ThrowsExceptionWithoutReference() { var client = new ProactiveEventsClient(ProactiveEventsClient.EuropeEndpoint, "token"); var alert = new WeatherAlert(WeatherAlertType.Tornado); var request = new BroadcastEventRequest(alert) { ExpiryTime = DateTimeOffset.Now.AddMinutes(5), TimeStamp = DateTimeOffset.Now }; await Assert.ThrowsAsync <ArgumentNullException>(() => client.Send(request)); }
public async Task SendsExpectedRequest() { var http = new HttpClient(new ActionHandler(req => { Assert.Equal(HttpMethod.Post, req.Method); Assert.Equal("application/json", req.Content.Headers.ContentType.MediaType); return(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK))); })); var client = new ProactiveEventsClient(ProactiveEventsClient.EuropeEndpoint, "token", http); var alert = new WeatherAlert(WeatherAlertType.Tornado); var request = new BroadcastEventRequest(alert) { ReferenceId = "broadcastTest", ExpiryTime = DateTimeOffset.Now.AddMinutes(5), TimeStamp = DateTimeOffset.Now }; await client.Send(request); }
public void WeatherAlert() { var weatherAlert = new WeatherAlert(WeatherAlertType.Tornado, new LocaleAttributes("en-GB", "Steve Stuff")); Assert.True(Utility.CompareJson(weatherAlert, "WeatherAlert.json")); }