コード例 #1
0
        public void Single2()
        {
            var registration = new AddRegistrationRequest
            {
                Alias     = "alias",
                Badge     = 2,
                QuietTime = new QuietTime
                {
                    Start = "22:00",
                    End   = "8:00"
                },
                Tags = new List <string> {
                    "tag1", "tag2"
                },
                TimeZone = "America/Los_Angeles"
            };
            var text     = registration.Serialize().FormatAsJson();
            var expected = @"
{
  'quiettime': {
    'start': '22:00',
    'end': '8:00'
  },
  'alias': 'alias',
  'badge': 2,
  'tz': 'America/Los_Angeles',
  'tags': [
    'tag1',
    'tag2'
  ]
}".Replace("\r\n", "\n");

            Assert.AreEqual(expected, text);
        }
コード例 #2
0
        public void Simple()
        {
            var service = new AddRegistrationService
            {
                RequestBuilder = ServerRequestBuilder.Instance
            };
            var registration = new AddRegistrationRequest
            {
                PushId = "AndroidPushId",
                Tags   = new List <string> {
                    "MyTag"
                },
                Alias = "MyAlias"
            };

            service.Execute(registration, response => Debug.WriteLine("Success"), ExceptionHandler.Handle);
        }
コード例 #3
0
        public HttpResponseMessage AddRegistration(AddRegistrationRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (RegistrationService.CheckUsername(0, model.Username))
            {
                string message = "This username is already being used.";
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, message));
            }

            ItemResponse <int> response = new ItemResponse <int>();

            response.Item = RegistrationService.UpdateRegistration(model);
            return(Request.CreateResponse(response));
        }
コード例 #4
0
        public void Tags()
        {
            var service = new AddRegistrationService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };
            var registration = new AddRegistrationRequest
            {
                PushId = RemoteSettings.AndroidPushId,
                Tags   = new List <string> {
                    "bangladesh"
                }
            };

            var asyncTestHelper = new AsyncTestHelper();

            service.Execute(registration, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #5
0
        public void Single2()
        {
            var registration = new AddRegistrationRequest
            {
                Alias = "alias",
                Tags  = new List <string> {
                    "tag1", "tag2"
                },
            };
            var text     = registration.Serialize().FormatAsJson();
            var expected = @"
{
  'alias': 'alias',
  'tags': [
    'tag1',
    'tag2'
  ]
}".Replace("\r\n", "\n");

            Assert.AreEqual(expected, text);
        }