public void It_should_authorize_all_operations()
 {
     var context = new Mock<IContext>().Object;
     var provider = new NoSecurityProvider();
     var result = provider.GetAuthorizationResult(context, "foo");
     result.Result.Should().Be(true);
     result.Operation.Should().Be("foo");
     result.User.Should().Be(AnonymousUser.Instance);
     result.ToString().Should().Contain("No security provider");
 }
        private async Task InitTargetDevice(DeviceInfo device)
        {
            Console.WriteLine("InitTargetDevice - started... ");
            Logger instance = Logger.Instance;

            object[] encryptionEnabled = new object[] { this.devicePairing.EncryptionEnabled };
            instance.LogMessageFormat("InitTargetDevice - EncryptionEnabled : {0}", encryptionEnabled);
            ISecondTvSecurityProvider noSecurityProvider = null;

            if (!this.devicePairing.EncryptionEnabled)
            {
                noSecurityProvider = new NoSecurityProvider();
            }
            else
            {
                noSecurityProvider = new AesSecurityProvider(this.devicePairing.SpcApi.GetKey(), this.devicePairing.SessionId);
            }
            Console.WriteLine("InitTargetDevice - Created Tv device.");

            ITargetDevice targetDevice = SmartTVRemoteControl.DeviceFactory.CreateTvDevice(device, this.notificationProvider, new DispatcherWrapper(Dispatcher.CurrentDispatcher), noSecurityProvider);

            Console.WriteLine("InitTargetDevice - Set current device.");
            this.SetCurrentDevice(targetDevice);
            try
            {
                Console.WriteLine("InitTargetDevice - Initialize Tv device.");
                AsyncContext.Run(() => targetDevice.InitializeAsync());
                //await targetDevice.InitializeAsync();
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                Console.WriteLine("[ERROR]Catch exception when initialize TV.");
                Logger logger = Logger.Instance;
                logger.LogMessageFormat("Exception message: {0}", new object[] { exception.Message });
                Logger instance1 = Logger.Instance;
                instance1.LogMessageFormat("Exception stacktrace: {0}", new object[] { exception.StackTrace });
            }
            finally
            {
                Console.WriteLine("InitTargetDevice is complete");
            }
        }
Example #3
0
        private async Task InitTargetDevice(DeviceInfo device)
        {
            Logger.Instance.LogMessageFormat("[SmartView2][DeviceController]InitTargetDevice - started... ", new object[0]);
            Logger instance = Logger.Instance;

            object[] encryptionEnabled = new object[] { this.devicePairing.EncryptionEnabled };
            instance.LogMessageFormat("[SmartView2][DeviceController]InitTargetDevice - EncryptionEnabled : {0}", encryptionEnabled);
            ISecondTvSecurityProvider noSecurityProvider = null;

            if (!this.devicePairing.EncryptionEnabled)
            {
                noSecurityProvider = new NoSecurityProvider();
            }
            else
            {
                noSecurityProvider = new AesSecurityProvider(this.devicePairing.SpcApi.GetKey(), this.devicePairing.SessionId);
            }
            Logger.Instance.LogMessageFormat("[SmartView2][DeviceController]InitTargetDevice - Created Tv device.", new object[0]);
            ITargetDevice targetDevice = SmartView2.DeviceFactory.CreateTvDevice(device, this.notificationProvider, this.dispatcher, noSecurityProvider);

            Logger.Instance.LogMessageFormat("[SmartView2][DeviceController]InitTargetDevice - Set current device.", new object[0]);
            this.SetCurrentDevice(targetDevice);
            try
            {
                Logger.Instance.LogMessageFormat("[SmartView2][DeviceController]InitTargetDevice - Initialize Tv device.", new object[0]);
                await targetDevice.InitializeAsync();
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                Logger.Instance.LogMessageFormat("[SmartView2][DeviceController][ERROR]Catch exception when initialize TV.", new object[0]);
                Logger logger = Logger.Instance;
                logger.LogMessageFormat("[SmartView2][DeviceController]Exception message: {0}", new object[] { exception.Message });
                Logger instance1 = Logger.Instance;
                instance1.LogMessageFormat("[SmartView2][DeviceController]Exception stacktrace: {0}", new object[] { exception.StackTrace });
            }
        }
 public void It_should_return_AnonymousUser()
 {
     var context = new Mock<IContext>().Object;
     var provider = new NoSecurityProvider();
     provider.GetCurrentUser(context).Should().Be(AnonymousUser.Instance);
 }