public void ShouldDetectIfRootAppsAreInstalled(string package)
        {
            using (var gel = new GlobalLock())
            {
                var jbd = new Cryoprison.Android.JailbreakDetector(gel.Env, simulatorFriendly: false);

                A.App.Application.Context.PackageManager.MockPackages = new System.Collections.Generic.Dictionary <string, A.Content.PM.PackageInfo>
                {
                    { package, new A.Content.PM.PackageInfo() }
                };

                Assert.True(jbd.IsJailbroken);
            }
        }
        public void ShouldDetectIfExecutableCanBeLocated(string executable)
        {
            var locations = Cryoprison.Android.JailbreakDetector.CommonExecutableRootDirectories;

            var index    = randomizer.Next(locations.Length);
            var location = locations[index];

            using (var gel = new GlobalLock())
            {
                gel.Env.System.IO.File.Exists = (path) => {
                    return(path == location + executable);
                };

                var jbd = new Cryoprison.Android.JailbreakDetector(gel.Env, simulatorFriendly: false);

                Assert.True(jbd.IsJailbroken);
            }
        }
        public void ShouldDetectIfSuHasBeenInstalled(string executable)
        {
            using (var gel = new GlobalLock())
            {
                var jbd = new Cryoprison.Android.JailbreakDetector(gel.Env, simulatorFriendly: false);

                Java.Lang.Runtime.MockRuntime.MockExec = (parms) => {
                    if (parms.Count() == 2 && parms[0] == "which" && parms[1] == executable)
                    {
                        var process = new Process();
                        process.MockExecArgs  = parms;
                        process.MockStdOutput = new[] {
                            "/asdf/" + executable
                        };
                        return(process);
                    }
                    return(null);
                };

                Assert.True(jbd.IsJailbroken);
            }
        }
        public void ShouldDetectIfPropertyHasSpecificValue(string stdout)
        {
            using (var gel = new GlobalLock())
            {
                var jbd = new Cryoprison.Android.JailbreakDetector(gel.Env, simulatorFriendly: false);

                Java.Lang.Runtime.MockRuntime.MockExec = (parms) => {
                    if (parms.Count() == 1 && parms[0] == "getprop")
                    {
                        var process = new Process();
                        process.MockExecArgs  = parms;
                        process.MockStdOutput = new[] {
                            stdout
                        };
                        return(process);
                    }
                    return(null);
                };

                Assert.True(jbd.IsJailbroken, $"Did not detect a jailbreak via: {stdout}");
            }
        }