Beispiel #1
0
            public void Execute_enumerates_results()
            {
                var handler = new OperationResultHandler();

                new MockOperation <string>(handler, () => YieldResults());

                Assert.IsType <string[]>(handler.Result);
                Assert.Equal(new[] { "Twilight Sparkle", "Princess Celestia" }, handler.Result);
            }
Beispiel #2
0
            public void Execute_sets_results()
            {
                var handler = new OperationResultHandler();
                var result  = "Twilight Sparkle";

                new MockOperation <string>(handler, () => result);

                Assert.Equal(result, handler.Result);
            }
        public void OnResult_works()
        {
            var handler = new OperationResultHandler();
            var result  = "Twilight Sparkle";

            handler.OnResult(result);

            Assert.True(handler.HasResult);
            Assert.Equal(result, handler.Result);
        }
            public void Execute_enumerates_results()
            {
                var handler = new OperationResultHandler();
                var operation = new Mock<OperationExecutor.OperationBase>(handler) { CallBase = true };

                operation.Object.Execute(() => YieldResults());

                Assert.IsType<string[]>(handler.Result);
                Assert.Equal(new[] { "Twilight Sparkle", "Princess Celestia" }, handler.Result);
            }
Beispiel #5
0
            public void Execute_sets_results()
            {
                var handler   = new OperationResultHandler();
                var operation = new MockOperation(handler);
                var result    = "Twilight Sparkle";

                operation.Execute(() => result);

                Assert.Equal(result, handler.Result);
            }
            public void Execute_sets_results()
            {
                var handler = new OperationResultHandler();
                var operation = new Mock<OperationExecutor.OperationBase>(handler) { CallBase = true };
                var result = "Twilight Sparkle";

                operation.Object.Execute(() => result);

                Assert.Equal(result, handler.Result);
            }
        public void OnResult_works()
        {
            var handler = new OperationResultHandler();
            var result = "Twilight Sparkle";

            handler.OnResult(result);

            Assert.True(handler.HasResult);
            Assert.Equal(result, handler.Result);
        }
Beispiel #8
0
            public void Execute_catches_exceptions()
            {
                var handler = new OperationResultHandler();
                var error   = new ArgumentOutOfRangeException("Needs to be about 20% more cool.");

                new MockOperation <string>(handler, (Action)(() => throw error));

                Assert.Equal(error.GetType().FullName, handler.ErrorType);
                Assert.Equal(error.Message, handler.ErrorMessage);
                Assert.NotEmpty(handler.ErrorStackTrace);
            }
            public void Execute_catches_exceptions()
            {
                var handler = new OperationResultHandler();
                var operation = new Mock<OperationExecutor.OperationBase>(handler) { CallBase = true };
                var error = new ArgumentOutOfRangeException("Needs to be about 20% more cool.");

                operation.Object.Execute(() => { throw error; });

                Assert.Equal(error.GetType().FullName, handler.ErrorType);
                Assert.Equal(error.Message, handler.ErrorMessage);
                Assert.NotEmpty(handler.ErrorStackTrace);
            }
        public void OnError_works()
        {
            var handler    = new OperationResultHandler();
            var type       = "System.ArgumentOutOfRangeException";
            var message    = "Needs to be about 20% more cool.";
            var stackTrace = "The Coolest Trace Yet";

            handler.OnError(type, message, stackTrace);

            Assert.Equal(type, handler.ErrorType);
            Assert.Equal(message, handler.ErrorMessage);
            Assert.Equal(stackTrace, handler.ErrorStackTrace);
        }
            public void Execute_enumerates_results()
            {
                var handler   = new OperationResultHandler();
                var operation = new Mock <OperationExecutor.OperationBase>(handler)
                {
                    CallBase = true
                };

                operation.Object.Execute(() => YieldResults());

                Assert.IsType <string[]>(handler.Result);
                Assert.Equal(new[] { "Twilight Sparkle", "Princess Celestia" }, handler.Result);
            }
            public void Execute_sets_results()
            {
                var handler   = new OperationResultHandler();
                var operation = new Mock <OperationExecutor.OperationBase>(handler)
                {
                    CallBase = true
                };
                var result = "Twilight Sparkle";

                operation.Object.Execute(() => result);

                Assert.Equal(result, handler.Result);
            }
        public void OnError_works()
        {
            var handler = new OperationResultHandler();
            var type = "System.ArgumentOutOfRangeException";
            var message = "Needs to be about 20% more cool.";
            var stackTrace = "The Coolest Trace Yet";

            handler.OnError(type, message, stackTrace);

            Assert.Equal(type, handler.ErrorType);
            Assert.Equal(message, handler.ErrorMessage);
            Assert.Equal(stackTrace, handler.ErrorStackTrace);
        }
            public void Execute_catches_exceptions()
            {
                var handler   = new OperationResultHandler();
                var operation = new Mock <OperationExecutor.OperationBase>(handler)
                {
                    CallBase = true
                };
                var error = new ArgumentOutOfRangeException("Needs to be about 20% more cool.");

                operation.Object.Execute(() => { throw error; });

                Assert.Equal(error.GetType().FullName, handler.ErrorType);
                Assert.Equal(error.Message, handler.ErrorMessage);
                Assert.NotEmpty(handler.ErrorStackTrace);
            }