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);
        }
        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);
        }
        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));
        }
        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();
        }
Exemplo n.º 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);
        }