コード例 #1
0
        public void ShouldDetectIfCanWriteToPrivate(string file)
        {
            using (var gel = new GlobalLock())
            {
                var jbd = new Cryoprison.iOS.JailbreakDetector(gel.Env, simulatorFriendly: false);

                gel.Env.System.IO.File.Open = (path, mode, access, share) =>
                {
                    if (path != file)
                    {
                        throw new System.IO.IOException();
                    }

                    var writables = new FileMode[] { FileMode.Append, FileMode.Create, FileMode.CreateNew, FileMode.OpenOrCreate, FileMode.Truncate };
                    if (!writables.Any(x => x == mode))
                    {
                        throw new System.IO.IOException();
                    }

                    if (access != FileAccess.Read)
                    {
                        throw new System.IO.IOException();
                    }

                    return(new MemoryStream());
                };

                Assert.True(jbd.IsJailbroken);
            }
        }