コード例 #1
0
 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"));
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 public void WhenBlankShouldFailAssertion()
 {
     Rest.Get("/product/apple", _configuration)
     .Response()
     .Execute()
     .Assert();
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
 public void NotBlankShouldPass()
 {
     Rest.Get("/product/apple", _configuration)
     .Response()
     .ReturnsContent()
     .Execute()
     .ShouldPass();
 }
コード例 #13
0
 public void FailOnDifferentModelNotArray()
 {
     Rest.Get("/product", _configuration)
     .Response()
     .HasJsonSchema <Product>()
     .Execute()
     .ShouldFailForRule <JsonModelSchemaAssertionRule <Product> >();
 }
コード例 #14
0
 public void FailOnManyItemsButExpectingDifferentModel()
 {
     Rest.Get("/promo", _configuration)
     .Response()
     .HasJsonSchema <IList <Product> >()
     .Execute()
     .ShouldFailForRule <JsonModelSchemaAssertionRule <IList <Product> > >();
 }
コード例 #15
0
 public void FailOnSingleItemExpectingList()
 {
     Rest.Get("/product/apple", _configuration)
     .Response()
     .HasJsonSchema <IList <Product> >()
     .Execute()
     .ShouldFailForRule <JsonModelSchemaAssertionRule <IList <Product> > >();
 }
コード例 #16
0
 public void SuccessEmptyListModel()
 {
     Rest.Get("/product/empty", _configuration)
     .Response()
     .HasJsonSchema <IList <Product> >()
     .Execute()
     .ShouldPass();
 }
コード例 #17
0
 public void SuccessPromoModel()
 {
     Rest.Get("/promo/apple", _configuration)
     .Response()
     .HasJsonSchema <Promo>()
     .Execute()
     .ShouldPass();
 }
コード例 #18
0
ファイル: GameSelectUI.cs プロジェクト: pjrodrig/BasicRPG
 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);
     })));
 }
コード例 #19
0
        dynamic CreateTodo()
        {
            var json = Rest.Get(TodosLink());

            var todo = Rest.Get(json.New);

            return(Rest.Post(todo.Create, todo));
        }
コード例 #20
0
 public void BlankShouldFail()
 {
     Rest.Get("/null", _configuration)
     .Response()
     .ReturnsContent()
     .Execute()
     .ShouldFail();
 }
コード例 #21
0
 public void WhenDynamicProperty_Equals_ShouldPass()
 {
     Rest.Get("/product/apple", _configuration)
     .Response()
     .Returns <Product>(x => x.Name == "Apple")
     .Execute()
     .ShouldPass();
 }
コード例 #22
0
 public void WhenProperty_NotEquals_ShouldFail()
 {
     Rest.Get("/product/apple", _configuration)
     .Response()
     .Returns <Product>(x => x.Name == "Fail test")
     .Execute()
     .ShouldFail();
 }
コード例 #23
0
 public void WhenType_DoesNotMatch_ShouldFail()
 {
     Rest.Get("/product/apple", _configuration)
     .Response()
     .Returns <Promo>(x => x.Discount > 0)
     .Execute()
     .ShouldFail();
 }
コード例 #24
0
 public void WhenDynamicProperty_Equals_ShouldPass()
 {
     Rest.Get("/product/apple", _configuration)
     .Response()
     .ReturnsDynamic(expression: x => x.Name == "Apple", "Name does not match")
     .Execute()
     .ShouldPass();
 }
コード例 #25
0
 public void WhenDynamicProperty_NotEquals_ShouldFail()
 {
     Rest.Get("/product/apple", _configuration)
     .Response()
     .ReturnsDynamic(x => x.Name == "NotApple", "Name does not match")
     .Execute()
     .ShouldFail();
 }
コード例 #26
0
        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);
        }
コード例 #27
0
        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;
        }
コード例 #28
0
        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);
        }
コード例 #29
0
        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);
        }
コード例 #30
0
        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));
        }