Exemplo n.º 1
0
        protected override Task SaveAsync(Task toAwait, CancellationToken cancellationToken)
        {
            Task platformHookTask = null;

            if (CurrentInstallationController.IsCurrent(this))
            {
                var configuration = ParseClient.CurrentConfiguration;

                // 'this' is required in order for the extension method to be used.
                this.SetIfDifferent("deviceType", DeviceInfoController.DeviceType);
                this.SetIfDifferent("timeZone", DeviceInfoController.DeviceTimeZone);
                this.SetIfDifferent("localeIdentifier", GetLocaleIdentifier());
                this.SetIfDifferent("parseVersion", GetParseVersion().ToString());
                this.SetIfDifferent("appVersion", configuration.VersionInfo.BuildVersion ?? DeviceInfoController.AppBuildVersion);
                this.SetIfDifferent("appIdentifier", DeviceInfoController.AppIdentifier);
                this.SetIfDifferent("appName", DeviceInfoController.AppName);

                platformHookTask = DeviceInfoController.ExecuteParseInstallationSaveHookAsync(this);
            }

            return(platformHookTask.Safe().OnSuccess(_ =>
            {
                return base.SaveAsync(toAwait, cancellationToken);
            }).Unwrap().OnSuccess(_ =>
            {
                if (CurrentInstallationController.IsCurrent(this))
                {
                    return Task.FromResult(0);
                }
                return CurrentInstallationController.SetAsync(this, cancellationToken);
            }).Unwrap());
        }
Exemplo n.º 2
0
        public void GetAllDevices_CountOfDevicesIsCorrect(int aMinDeviceCount)
        {
            // Arrange
            DeviceInfoController controller = new DeviceInfoController();

            // Act
            ICollection <DeviceViewModel> devices = controller.GetAllDevices();

            // Assert
            Assert.That(devices.Count >= aMinDeviceCount);
        }
Exemplo n.º 3
0
        public void GetDevice_IncorrectIndex()
        {
            // Arrange
            int id = -1;
            DeviceInfoController controller = new DeviceInfoController();

            // Act
            NotFoundResult result = controller.GetDevice(id) as NotFoundResult;

            // Assert
            Assert.NotNull(result);
        }
Exemplo n.º 4
0
        public void GetDevice_CorrectIndex()
        {
            // Arrange
            int id = 1;
            DeviceInfoController controller = new DeviceInfoController();

            // Act
            OkNegotiatedContentResult <DeviceViewModel> result = controller.GetDevice(id) as OkNegotiatedContentResult <DeviceViewModel>;

            // Assert
            Assert.NotNull(result);
            Assert.That(result.Content.Id == id);
        }