public async Task will_return_last_known_good() { var firstCall = true; var handler = new MockMessageHandler(req => { if (firstCall) { firstCall = false; var resp = new HttpResponseMessage(HttpStatusCode.OK); resp.Content = new StringContent("[\"testval\"]"); return(resp); } return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); }); var client = new HttpClient(handler); client.BaseAddress = new Uri("http://test.local"); var cache = new MemoryCache(Options.Create(new MemoryCacheOptions())); var service = new ValuesService(client, cache, _logger.Object); await service.GetValues(); var values = await service.GetValues(); Assert.False(firstCall); Assert.Equal("testval", values.First()); }
public void GetValues_Returns_Three_Values() { var valuesService = new ValuesService(); var values = valuesService.GetValues().ToArray(); Assert.Equal(3, values.Length); }
// POST api/values public IEnumerable <string> Post([FromBody] Request request) { var valuesService = new ValuesService(); var values = valuesService.GetValues(); var compilationService = new CompilationService(); return(compilationService.ExecuteRequest(request, values)); }
public void Should_Return_A_List_Of_Values() { // arrange var target = new ValuesService(); // act var values = target.GetValues(); // assert Assert.Equal(new[] { "value1", "value2" }, values); }
public ActionResult Index() { var viewmodel = new HomeViewModel { Values = _valuesService.GetValues(), SortBy = _valuesService.GetCurrentSortDirection(), ChangeLog = _valuesService.GetChangeLog().Versions }; return(View(viewmodel)); }
public void ValuesControllerReturnStringArray() { //Arrange var service = new ValuesService(new neueimplemntierungOfUltra(), new neuerimplemntierungOfUltra()); //Act var values = service.GetValues(); //Assert Assert.IsType <string[]>(values); Assert.Equal(5, values.Length); Assert.Equal("test2", values[3]); Assert.Equal("test3", values[4]); }
public IEnumerable <string> Get() { _logger.LogInformation("Inside controller, outside scope"); using (_logger.BeginScope("Some scope value")) using (_logger.BeginScope(123)) using (_logger.BeginScope(new Dictionary <string, object> { { "ScopeValue1", "outer scope" } })) { _logger.LogInformation("Inside controller, inside scope"); return(_service.GetValues()); } }
async partial void GetValuesTapped(NSObject sender) { try { SetButtonEnabled(false); ValuesService service = new ValuesService(); IEnumerable <string> values = await service.GetValues(_accessToken); StringBuilder sb = new StringBuilder(); bool first = true; foreach (string value in values) { if (first) { first = false; } else { sb.Append(", "); } sb.Append(value); } UIAlertView alert = new UIAlertView("Success", String.Format("Get values complete: {0}", sb), null, "OK", null); alert.Show(); } catch { UIAlertView alert = new UIAlertView("Error", "Get values failed", null, "OK", null); alert.Show(); } finally { SetButtonEnabled(true); } }
public ActionResult <IEnumerable <string> > Get() { return(ValuesService.GetValues()); }
public async Task <IActionResult> GetValues() { var values = await _service.GetValues(); return(Ok(values)); }
public async Task OnGet() { Values = await _valuesService.GetValues(); }
public ActionResult <IEnumerable <string> > Get() => Ok(_valuesService.GetValues());