示例#1
0
        public ImagePage(SafeService safeService)
        {
            _image = new SafeImage(safeService)
            {
                IsVisible = false
            };

            Content = _image;
        }
示例#2
0
        public void IsRunning_ShouldBe_Origin_IsRunning(bool value)
        {
            // Arrange
            _origin.IsRunning().Returns(value);
            var subject = new SafeService(_origin);
            // Act
            var result = subject.IsRunning();

            // Assert
            result.Should().Be(value);
        }
示例#3
0
        public void IsRunning_ShouldPass_NotExpectedException()
        {
            // Arrange
            var exception = new Exception();

            _origin.IsRunning().Throws(exception);
            var subject = new SafeService(_origin);
            // Act
            Action action = () => subject.IsRunning();

            // Assert
            action.Should().ThrowExactly <Exception>();
        }
示例#4
0
        public void Name_ShouldBe_Origin_Name()
        {
            // Arrange
            const string name = "My service";

            _origin.Name.Returns(name);
            var subject = new SafeService(_origin);
            // Act
            var result = subject.Name;

            // Assert
            result.Should().Be(name);
        }
示例#5
0
        public void Stop_ShouldBeSuccess_WhenOriginThrows_ServiceNotRunning()
        {
            // Arrange
            var exception = new InvalidOperationException("", new Win32Exception(ServiceNotRunning));

            _origin.Stop().Throws(exception);
            var subject = new SafeService(_origin);
            // Act
            var result = subject.Stop();

            // Assert
            result.Success.Should().BeTrue();
        }
示例#6
0
        public void Stop_ShouldBe_Origin_Stop()
        {
            // Arrange
            var expected = Result.Ok();

            _origin.Stop().Returns(expected);
            var subject = new SafeService(_origin);
            // Act
            var result = subject.Stop();

            // Assert
            result.Should().BeSameAs(expected);
        }
示例#7
0
        public void IsRunning_ShouldBeFalse_WhenOriginThrows_ExpectedException(Type exceptionType)
        {
            // Arrange
            var exception = (Exception)Activator.CreateInstance(exceptionType);

            _origin.IsRunning().Throws(exception);
            var subject = new SafeService(_origin);
            // Act
            var result = subject.IsRunning();

            // Assert
            result.Should().BeFalse();
        }
示例#8
0
        public void Stop_ShouldBeFailure_WhenOriginThrows_ExpectedException(Type exceptionType)
        {
            // Arrange
            var exception = (Exception)Activator.CreateInstance(exceptionType);

            _origin.Stop().Throws(exception);
            var subject = new SafeService(_origin);
            // Act
            var result = subject.Stop();

            // Assert
            result.Failure.Should().BeTrue();
            result.Exception.Should().BeSameAs(exception);
        }
示例#9
0
        public ServiceAccess(Current.GetTicket getTicket, Current.GetUrl getUrl)
        {
            var repos = new Repos(getUrl);

            BaseMove = new BaseMoveSaverService(this, repos);

            Safe   = new SafeService(this, repos);
            Admin  = new AdminService(this, repos);
            Money  = new MoneyService(this, repos);
            Robot  = new RobotService(this, repos);
            Report = new ReportService(this, repos);

            Current = new Current(Safe, getTicket);
        }
示例#10
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            // Native verification, Change project properties to use correct implementation!
            //SafeService.HttpClient = new HttpClient(new Xamarin.SSLPinning.iOS.NSUrlSessionHandler());

            // Managed verification, Change project properties to use correct implementation!
            SafeService.HttpClient = SafeService.CreateClient();

            LoadApplication(new App());

            return(base.FinishedLaunching(app, options));
        }
示例#11
0
        public async Task StopAsync_ShouldBe_Origin_StopAsync()
        {
            // Arrange
            var expected          = Result.Ok();
            var cancellationToken = new CancellationToken();

            _origin.StopAsync(cancellationToken).Returns(expected);
            var subject = new SafeService(_origin);

            // Act
            var result = await subject.StopAsync(cancellationToken);

            // Assert
            result.Should().BeSameAs(expected);
        }
示例#12
0
        public async Task StopAsync_ShouldBeSuccess_WhenOriginThrows_ServiceNotRunning()
        {
            // Arrange
            var exception         = new InvalidOperationException("", new Win32Exception(ServiceNotRunning));
            var cancellationToken = CancellationToken.None;

            _origin.StopAsync(cancellationToken).Throws(exception);
            var subject = new SafeService(_origin);

            // Act
            var result = await subject.StopAsync(cancellationToken);

            // Assert
            result.Success.Should().BeTrue();
        }
示例#13
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            // Native verification using TrustManager, works with AndroidClientHandler!
            //SafeService.HttpClient = SafeService.CreateClient(new PublicKeyHandler());

            // Managed verification, works with Managed client handler!
            SafeService.HttpClient = SafeService.CreateClient();

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
        }
示例#14
0
        public async Task StopAsync_ShouldBeFailure_WhenOriginThrows_ExpectedException(Type exceptionType)
        {
            // Arrange
            var exception         = (Exception)Activator.CreateInstance(exceptionType);
            var cancellationToken = CancellationToken.None;

            _origin.StopAsync(cancellationToken).Throws(exception);
            var subject = new SafeService(_origin);

            // Act
            var result = await subject.StopAsync(cancellationToken);

            // Assert
            result.Failure.Should().BeTrue();
            result.Exception.Should().BeSameAs(exception);
        }
示例#15
0
        public bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
        {
            if (request.Url.Scheme.ToLower() == "https")
            {
                try
                {
                    var response = new SafeService().GetResponse(request.Url.ToString()).Result;

                    var conn = new NSUrlConnection(request, this, true);
                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }

            return(false);
        }
示例#16
0
        public override WebResourceResponse ShouldInterceptRequest(Android.Webkit.WebView view, IWebResourceRequest request)
        {
            var url = request.Url;

            try
            {
                var response = new SafeService().GetResponse(url.ToString()).Result;

                var contentType = response.Content.Headers.ContentType;
                if (contentType != null)
                {
                    return(new WebResourceResponse(contentType.MediaType, contentType.CharSet, response.Content.ReadAsStreamAsync().Result));
                }
            }
            catch (Exception ex)
            {
                return(new WebResourceResponse(null, null, null));
            }
            return(base.ShouldInterceptRequest(view, request));
        }
示例#17
0
 public SafeImage(SafeService safeService)
 {
     _safeService = safeService;
 }
示例#18
0
 public MainPage()
 {
     InitializeComponent();
     _service = new SafeService();
 }