Exemplo n.º 1
0
        public async Task Register_ByDefault_ReturnsNoContent()
        {
            var userControllerStub     = CreateUserControllerStub();
            var hostingEnvironmentStub = new Mock <IHostingEnvironment>();
            var pushServiceMock        = new Mock <IPushService>();

            pushServiceMock.Setup(m => m.Register(It.IsAny <PushSubscription>())).Returns(Task.CompletedTask);
            var controller = new PushController(userControllerStub.Object, hostingEnvironmentStub.Object, pushServiceMock.Object);
            var model      = new PushSubscriptionViewModel
            {
                Subscription = new Subscription
                {
                    Endpoint       = "https://db5p.notify.windows.com/w/?token=BQYAAACt1jdFc8Z7mH6fQOhqwzfh...",
                    ExpirationTime = 1551728506000,
                    Keys           = new Keys
                    {
                        Auth   = "_PhChqC4oDiArJ-DpkfNrQ",
                        P256Dh = "BNyBjPuc30Akf7lvT7OtZUimZOgI...",
                    },
                },
            };

            var result = await controller.Register(model);

            Assert.IsType <NoContentResult>(result);
            pushServiceMock.Verify(m => m.Register(It.IsAny <PushSubscription>()), Times.Once());
        }
Exemplo n.º 2
0
    public void PushTarget(Vector2 pushForce)
    {
        PushController closestTarget = GetClosestTarget();

        if (closestTarget != null)
        {
            closestTarget.GetPushed(pushForce, GetComponentInParent <Player>());
        }
    }
 private void GetReferences()
 {
     controller         = GetComponent <AssignedController>();
     pushController     = GetComponentInChildren <PushController>();
     rotationController = GetComponent <RotationController>();
     player             = GetComponent <Player>();
     animator           = GetComponent <Animator>();
     rb2d        = GetComponent <Rigidbody2D>();
     playerAudio = GetComponent <PlayerAudio>();
 }
Exemplo n.º 4
0
 private void GetReferences()
 {
     deathController         = GetComponent <DeathController>();
     movementController      = GetComponent <MovementController>();
     playerActionsController = GetComponent <PlayerActionsController>();
     respawnController       = GetComponent <RespawnController>();
     pushController          = GetComponentInChildren <PushController>();
     rotationController      = GetComponent <RotationController>();
     afterImageController    = GetComponent <AfterImageController>();
     animator = GetComponent <Animator>();
 }
        public async Task UnitTest_PostAsync()
        {
            var setup = mockHttpPushService.Setup(h => h.SendAsync(It.IsAny <Message>()))
                        .ReturnsAsync(new Mock <Response>().Object);

            PushController controller = new PushController(mockHttpPushService.Object);


            var response = await controller.PostAsync(GetValidMessage());

            mockHttpPushService.Verify(x => x.SendAsync(It.IsAny <Message>()), Times.Once());

            Assert.NotNull(response);
        }
Exemplo n.º 6
0
        public void GetVapidPublicKey_ByDefault_ReturnsVapidPublicKey()
        {
            var          userControllerStub     = new Mock <IUsersController>();
            var          hostingEnvironmentStub = new Mock <IHostingEnvironment>();
            var          pushServiceMock        = new Mock <IPushService>();
            const string PUBLIC_KEY             = "test public key";

            pushServiceMock.Setup(m => m.GetVapidPublicKey()).Returns(PUBLIC_KEY);
            var controller = new PushController(userControllerStub.Object, hostingEnvironmentStub.Object, pushServiceMock.Object);

            var result = controller.GetVapidPublicKey();

            Assert.IsType <ActionResult <string> >(result);
            Assert.IsType <OkObjectResult>(result.Result);
            var ok = (OkObjectResult)result.Result;

            Assert.IsType <string>(ok.Value);
            var publicKey = (string)ok.Value;

            Assert.Equal(PUBLIC_KEY, publicKey);
            pushServiceMock.Verify(m => m.GetVapidPublicKey(), Times.Once());
        }
Exemplo n.º 7
0
 /// <summary>
 /// Request a push to be sent. When this task completes, LeanCloud has successfully acknowledged a request
 /// to send push notifications but has not necessarily finished sending all notifications
 /// requested. The current status of recent push notifications can be seen in your Push Notifications
 /// console on http://parse.com
 /// </summary>
 /// <param name="cancellationToken">CancellationToken to cancel the current operation.</param>
 public Task SendAsync(CancellationToken cancellationToken)
 {
     return(PushController.SendPushNotificationAsync(state, cancellationToken));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Request a push to be sent. When this task completes, LeanCloud has successfully acknowledged a request
 /// to send push notifications but has not necessarily finished sending all notifications
 /// requested. The current status of recent push notifications can be seen in your Push Notifications
 /// console on https://api.leancloud.cn
 /// </summary>
 /// <param name="cancellationToken">CancellationToken to cancel the current operation.</param>
 public Task SendAsync(CancellationToken cancellationToken)
 {
     return(PushController.SendPushNotificationAsync(state, AVUser.CurrentSessionToken, cancellationToken));
 }
Exemplo n.º 9
0
 private void doSave()
 {
     PushController.pushData();
 }