Beispiel #1
0
        public async Task RegisterPushToken_InvalidRequest_Fails()
        {
            var dto = await _client.AuthenticateUserAsync("mwilson", "password");

            _httpClient.AddAuthorization(dto);

            var pushTokenDto = new RegisterPushTokenDto
            {
                PushToken      = null,
                DeviceName     = "Test Device",
                InstallationId = "6eb6ef3e-e1b0-428f-832a-bbf6d36c9e9c",
                MobileOs       = MobileOS.Android
            };

            SuccessfulRequestDto dto2 = null;
            var exception2            = await Record.ExceptionAsync(async() =>
            {
                dto2 = await _client.Authentication_RegisterPushTokenAsync(pushTokenDto);
            });

            using (var context = _factory.GetKIOTContext())
            {
                Assert.False(context.PushTokens.Include(x => x.MobileDevice).Any(x => x.MobileDevice.DeviceName == pushTokenDto.DeviceName &&
                                                                                 x.Token == pushTokenDto.PushToken && x.MobileDevice.InstallationId ==
                                                                                 pushTokenDto.InstallationId && x.MobileDevice.MobileOS == Core.Models.Application.MobileOS.Android));
            }

            Assert.NotNull(exception2);
        }
 public async Task <IActionResult> RegisterPushToken(RegisterPushTokenDto dto, CancellationToken token)
 {
     return(new Presenter <CommandResponse>(await _mediator.Send(
                                                new RegisterPushTokenRequest(dto, User.ToClaimsIdentity()), token))
            .ToIActionResult());
 }
 public RegisterPushTokenRequest(RegisterPushTokenDto pushTokenDto, ClaimsIdentity identity) : base(identity)
 {
     PushTokenDto = pushTokenDto;
 }