50 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Linq;
 | |
| using GerstITS.Examples.WebClients.Examples.Api;
 | |
| using GerstITS.IoC.DotNetCore;
 | |
| using GerstITS.Web.WebClients;
 | |
| 
 | |
| namespace GerstITS.Examples.WebClient.Console.Tests;
 | |
| 
 | |
| internal sealed class TestRunner : IApplicationStart
 | |
| {
 | |
|     #region Fields
 | |
| 
 | |
|     private readonly IWebClient _webClient;
 | |
| 
 | |
|     #endregion
 | |
| 
 | |
|     #region Construtors
 | |
| 
 | |
|     public TestRunner(IWebClient webClient)
 | |
|     {
 | |
|         _webClient = webClient;
 | |
|     } 
 | |
|         
 | |
|     #endregion
 | |
| 
 | |
|     #region ITestRunner
 | |
| 
 | |
|     public void Run()
 | |
|     {
 | |
|         var result1 = _webClient.Request<ICountry>()
 | |
|             .Execute(c => c.Search(new SearchCriteria
 | |
|                 { SortBy = nameof(Country.Name), SortDirection = SortingDirections.Descending, Skip = 5, Take = 5}));
 | |
| 
 | |
|         var result2 = _webClient.Request<ICountry>()
 | |
|             .Execute(c => c.Get(result1.Value.Result.First().Id));
 | |
| 
 | |
|         var test3 = _webClient.Request<ICountry>()
 | |
|             .Execute(c => c.Create(new Country {Name = $"Country-{Guid.NewGuid()}"}));
 | |
| 
 | |
|         test3.Value.Name += "_Renamed";
 | |
| 
 | |
|         var test4 = _webClient.Request<ICountry>()
 | |
|             .Execute(c => c.Update(test3.Value));
 | |
| 
 | |
|         var test5 = _webClient.Request<ICountry>()
 | |
|             .Execute(c => c.Delete(test3.Value.Id));
 | |
|     } 
 | |
|         
 | |
|     #endregion
 | |
| } |