コード例 #1
0
        public void DetectsFileNotLocatable()
        {
            using (var gel = new GlobalLock())
            {
                var env = new Ex.Env();

                var runtime = Java.Lang.Runtime.GetRuntime();

                Java.Lang.Process process = null;
                runtime.MockExec = (p) =>
                {
                    if (p.Count() == 2 && p[0] == "which" && p[1] == "file")
                    {
                        process = new Java.Lang.Process();
                        process.MockExecArgs  = p;
                        process.MockStdOutput = new[] { "" };
                        return(process);
                    }
                    throw new Exception($"Could not execute: {p}");
                };

                var i = new ShouldNotBeAbleToLocateFile().Init(env, "TEST", "file");

                Assert.True(i.Ok);
            }
        }
コード例 #2
0
        public void IsRobust()
        {
            using (var gel = new GlobalLock())
            {
                var env = new Ex.Env();

                string    message   = null;
                Exception exception = null;
                env.Reporter.OnExceptionReported = (msg, ex) =>
                {
                    message   = msg;
                    exception = ex;
                };

                var runtime = Java.Lang.Runtime.GetRuntime();

                runtime.MockExec = (p) =>
                {
                    throw new Exception("BOOM!");
                };

                var i = new ShouldNotBeAbleToLocateFile().Init(env, "TEST", "file");

                Assert.True(i.Ok);
                Assert.Equal("CanLocateFile bombed for file", message);
                Assert.Equal("BOOM!", exception.Message);
            }
        }
コード例 #3
0
        public void HasCorrectId()
        {
            using (var gel = new GlobalLock())
            {
                var env = new Ex.Env();

                var i = new ShouldNotBeAbleToLocateFile().Init(env, "TEST", "file");

                Assert.Equal("SHOULD_NOT_LOCATE_TEST", i.Id);
            }
        }