public void GetTests() { if (storageConnectionString.IsNotNullOrEmpty()) { var filePath = "/private/storage/fileitems/0001d4ce-7670-425b-b609-46bfdf4afb07-data.json"; var rest = new Rest(storageConnectionString); var stream = rest.Get <MemoryStream>(filePath); Assert.True(stream?.Length > 0); var jsonData = rest.Get <string>(filePath); Assert.True(jsonData?.ToLower()?.Contains("createdon")); } }
public DeviceManifest GetById(string id) { DeviceManifest manifest; try { if (ApiUrl == string.Empty) { throw new Exception(Errors.ERR_PROVISIONM_MISSING_APIURL); } var uriBuilder = new UriBuilder(ApiUrl + "/devicemanifests/id/" + id); if (DevKey != string.Empty) { uriBuilder.Query = "subscription-key=" + DevKey; } var json = Rest.Get(uriBuilder.Uri); manifest = ModelManager.JsonToModel <DeviceManifest>(json); } catch (Exception err) { var errString = Errors.ERR_PROVISIONM_NO_RESULTS + ", " + err.Message; if (err.InnerException != null) { errString += ", " + err.InnerException.Message; } throw new Exception(errString); } return(manifest); }
public void WhenBlankShouldFailAssertion() { Rest.Get("/product/apple", _configuration) .Response() .Execute() .Assert(); }
public List <Entity> GetByCodeValue(string codevalue) { List <Entity> entityList; try { if (ApiUrl == string.Empty) { throw new Exception(Errors.ERR_REFM_MISSING_APIURL); } var uriBuilder = new UriBuilder(ApiUrl + "/entities/codevalue/" + codevalue); if (DevKey != string.Empty) { uriBuilder.Query = "subscription-key=" + DevKey; } var json = Rest.Get(uriBuilder.Uri); entityList = ModelManager.JsonToModel <List <Entity> >(json); } catch (Exception err) { var errString = Errors.ERR_REFM_NO_RESULTS + ", " + err.Message; if (err.InnerException != null) { errString += ", " + err.InnerException.Message; } throw new Exception(errString); } return(entityList); }
public Entities GetAll(string id) { Entities entities; try { if (ApiUrl == string.Empty) { throw new Exception(Errors.ERR_REFM_MISSING_APIURL); } var uriBuilder = new UriBuilder(ApiUrl + "/entities/id/" + id); if (DevKey != string.Empty) { uriBuilder.Query = "subscription-key=" + DevKey; } var json = Rest.Get(uriBuilder.Uri); entities = ModelManager.JsonToModel <Entities>(json); } catch (Exception err) { var errString = Errors.ERR_REFM_NO_RESULTS + ", " + err.Message; if (err.InnerException != null) { errString += ", " + err.InnerException.Message; } throw new Exception(errString); } return(entities); }
public UserProfiles GetAll() { UserProfiles users; try { if (ApiUrl == string.Empty) { throw new Exception(Errors.ERR_PROFILEM_MISSING_APIURL); } var uriBuilder = new UriBuilder(ApiUrl + "/users"); if (DevKey != string.Empty) { uriBuilder.Query = "subscription-key=" + DevKey; } var json = Rest.Get(uriBuilder.Uri); users = ModelManager.JsonToModel <UserProfiles>(json); } catch (Exception err) { var errString = Errors.ERR_PROFILEM_NO_RESULTS + ", " + err.Message; if (err.InnerException != null) { errString += ", " + err.InnerException.Message; } throw new Exception(errString); } return(users); }
public Manifest GetByName(string name) { Manifest manifest; try { if (ApiUrl == string.Empty) { throw new Exception(Errors.ERR_CONFIGM_MISSING_APIURL); } var uriBuilder = new UriBuilder(ApiUrl + "/manifests/name/" + name); if (DevKey != string.Empty) { uriBuilder.Query = "subscription-key=" + DevKey; } var json = Rest.Get(uriBuilder.Uri); manifest = ModelManager.JsonToModel <Manifest>(json); } catch (Exception err) { var errString = string.Format(Errors.ERR_CONFIGM_MODEL_NOT_FOUND_NAME, name) + ", " + err.Message; if (err.InnerException != null) { errString += ", " + err.InnerException.Message; } throw new Exception(errString); } return(manifest); }
public Registrations GetByModel(string model) { Registrations devices; try { if (ApiUrl == string.Empty) { throw new Exception(Errors.ERR_DEVICEM_MISSING_APIURL); } var uriBuilder = new UriBuilder(ApiUrl + "/registrations/model/" + model); if (DevKey != string.Empty) { uriBuilder.Query = "subscription-key=" + DevKey; } var json = Rest.Get(uriBuilder.Uri); devices = ModelManager.JsonToModel <Registrations>(json); } catch (Exception err) { var errString = string.Format(Errors.ERR_DEVICEM_MODEL_NOT_FOUND_NAME, model) + ", " + err.Message; if (err.InnerException != null) { errString += ", " + err.InnerException.Message; } throw new Exception(errString); } return(devices); }
public async Task <List <OratorActivitiesModel> > GetOratorActivitesList() { var list = new List <OratorActivitiesModel>(); var restapi = new Rest(); try { var json = await restapi.Get(restapi.events, ""); if (string.IsNullOrEmpty(json)) { return(null); } else { var result = JsonConvert.DeserializeObject <List <OratorActivitiesModel> >(json); list = result; } } catch (Exception) { throw new Exception("Service Failed, try again later"); } return(list); }
public Manifests GetAll() { Manifests manifests; try { if (ApiUrl == string.Empty) { throw new Exception(Errors.ERR_CONFIGM_MISSING_APIURL); } var uriBuilder = new UriBuilder(ApiUrl + "/manifests"); if (DevKey != string.Empty) { uriBuilder.Query = "subscription-key=" + DevKey; } var json = Rest.Get(uriBuilder.Uri); manifests = ModelManager.JsonToModel <Manifests>(json); } catch (Exception err) { var errString = Errors.ERR_CONFIGM_NO_RESULTS + ", " + err.Message; if (err.InnerException != null) { errString += ", " + err.InnerException.Message; } throw new Exception(errString); } return(manifests); }
public Registration GetByParticipantId(string id) { Registration device; try { if (ApiUrl == string.Empty) { throw new Exception(Errors.ERR_DEVICEM_MISSING_APIURL); } var uriBuilder = new UriBuilder(ApiUrl + "/registrations/participant/" + id); if (DevKey != string.Empty) { uriBuilder.Query = "subscription-key=" + DevKey; } var json = Rest.Get(uriBuilder.Uri); device = ModelManager.JsonToModel <Registration>(json); } catch (Exception err) { var errString = string.Format(Errors.ERR_DEVICEM_MODEL_NOT_FOUND_PARTICIPANT, id) + ", " + err.Message; if (err.InnerException != null) { errString += ", " + err.InnerException.Message; } throw new Exception(errString); } return(device); }
public void NotBlankShouldPass() { Rest.Get("/product/apple", _configuration) .Response() .ReturnsContent() .Execute() .ShouldPass(); }
public void FailOnDifferentModelNotArray() { Rest.Get("/product", _configuration) .Response() .HasJsonSchema <Product>() .Execute() .ShouldFailForRule <JsonModelSchemaAssertionRule <Product> >(); }
public void FailOnManyItemsButExpectingDifferentModel() { Rest.Get("/promo", _configuration) .Response() .HasJsonSchema <IList <Product> >() .Execute() .ShouldFailForRule <JsonModelSchemaAssertionRule <IList <Product> > >(); }
public void FailOnSingleItemExpectingList() { Rest.Get("/product/apple", _configuration) .Response() .HasJsonSchema <IList <Product> >() .Execute() .ShouldFailForRule <JsonModelSchemaAssertionRule <IList <Product> > >(); }
public void SuccessEmptyListModel() { Rest.Get("/product/empty", _configuration) .Response() .HasJsonSchema <IList <Product> >() .Execute() .ShouldPass(); }
public void SuccessPromoModel() { Rest.Get("/promo/apple", _configuration) .Response() .HasJsonSchema <Promo>() .Execute() .ShouldPass(); }
private void FetchGames() { StartCoroutine(Rest.Get(API.userGames, "userId=" + app.User.id, new Action <GameCollection>(delegate(GameCollection games) { UpdateGamesList(games.games); }), new Action <RestError>(delegate(RestError err) { Debug.Log(err.message); }))); }
dynamic CreateTodo() { var json = Rest.Get(TodosLink()); var todo = Rest.Get(json.New); return(Rest.Post(todo.Create, todo)); }
public void BlankShouldFail() { Rest.Get("/null", _configuration) .Response() .ReturnsContent() .Execute() .ShouldFail(); }
public void WhenDynamicProperty_Equals_ShouldPass() { Rest.Get("/product/apple", _configuration) .Response() .Returns <Product>(x => x.Name == "Apple") .Execute() .ShouldPass(); }
public void WhenProperty_NotEquals_ShouldFail() { Rest.Get("/product/apple", _configuration) .Response() .Returns <Product>(x => x.Name == "Fail test") .Execute() .ShouldFail(); }
public void WhenType_DoesNotMatch_ShouldFail() { Rest.Get("/product/apple", _configuration) .Response() .Returns <Promo>(x => x.Discount > 0) .Execute() .ShouldFail(); }
public void WhenDynamicProperty_Equals_ShouldPass() { Rest.Get("/product/apple", _configuration) .Response() .ReturnsDynamic(expression: x => x.Name == "Apple", "Name does not match") .Execute() .ShouldPass(); }
public void WhenDynamicProperty_NotEquals_ShouldFail() { Rest.Get("/product/apple", _configuration) .Response() .ReturnsDynamic(x => x.Name == "NotApple", "Name does not match") .Execute() .ShouldFail(); }
public void WhenAutoAssert_AndNoFailures_ThenShouldNotCallTheAssertion() { Rest.Get("/product/apple", _configuration) .Response(true) .ReturnsStatus(HttpStatusCode.OK); _assertion.Verify(m => m.Assert(It.IsAny <ExecutionResult>()), Times.Never); }
private void getUserLogged() { Rest restx = new Rest(); userlogged = restx.Get <usuario>("usuarios", App.Current.Properties["ID"].ToString()).Result; Task.Delay(1000); txtNombre.Text = userlogged.nombre; txtUsername.Text = userlogged.C_User; }
public void WhenAssert_AndFailures_ThenShouldCallTheAssertion() { Rest.Get("/product/apple", _configuration) .Response() .ReturnsStatus(HttpStatusCode.Accepted) .Assert(); _assertion.Verify(m => m.Assert(It.IsAny <ExecutionResult>()), Times.Once); }
public async Task <PostBin> GetBin(string binId) { var url = $"https://postb.in/api/bin/{binId}"; var result = await Rest.Get <PostBin>(url) .WithTrackingIndicator("RB1002a") .ExecuteAsync(); return(result.ResultObject); }
public void WhenAutoAssert_ThenAssert_AndFailures_ThenShouldCallTheAssertionTwice() { //note : should call twice because it is an auto assert and also a manual assert Rest.Get("/product/apple", _configuration) .Response(true) .ReturnsStatus(HttpStatusCode.Accepted) // call 1 .Assert(); // call 2 _assertion.Verify(m => m.Assert(It.IsAny <ExecutionResult>()), Times.Exactly(2)); }