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

            Content = _image;
        }
Exemple #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);
        }
Exemple #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>();
        }
Exemple #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);
        }
Exemple #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();
        }
Exemple #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);
        }
Exemple #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();
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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));
        }
Exemple #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);
        }
Exemple #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();
        }
Exemple #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());
        }
Exemple #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);
        }
Exemple #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);
        }
        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));
        }
Exemple #17
0
 public SafeImage(SafeService safeService)
 {
     _safeService = safeService;
 }
Exemple #18
0
 public MainPage()
 {
     InitializeComponent();
     _service = new SafeService();
 }