Beispiel #1
0
        public View NewSafeView(View unsafeView)
        {
            SafeViewImpl safeView = new SafeViewImpl();

            safeView.UnsafeView = unsafeView;
            return(safeView);
        }
Beispiel #2
0
        public void TestNewSafeView()
        {
            View unsafeView = new MockViewImpl();
            View safeView   = MvcFactory.NewSafeView(unsafeView);

            Assert.That(safeView, Is.Not.Null);
            Assert.That(safeView, Is.InstanceOf(typeof(SafeViewImpl)));
            SafeViewImpl safeViewImpl = safeView as SafeViewImpl;

            Assert.That(safeViewImpl.UnsafeView, Is.EqualTo(unsafeView));
        }
Beispiel #3
0
        public void TestRender_ForAThrownException()
        {
            MockUnsafeViewImpl unsafeView = new MockUnsafeViewImpl();

            unsafeView.Exception = new Exception("A mock exception");

            SafeViewImpl safeView = new SafeViewImpl();

            safeView.UnsafeView = unsafeView;

            IDictionary <string, object> model = new Dictionary <string, object>();
            string str = null;

            Assert.That(() => {
                str = safeView.Render(model);
            }, Throws.Nothing);
            Assert.That(str, Is.StringStarting("A mock exception"));
        }
Beispiel #4
0
        public void TestRender_ForAThrownInternalErrorException()
        {
            MockUnsafeViewImpl unsafeView = new MockUnsafeViewImpl();

            unsafeView.Exception = new InternalErrorException("A mock internal error");

            SafeViewImpl safeView = new SafeViewImpl();

            safeView.UnsafeView = unsafeView;

            IDictionary <string, object> model = new Dictionary <string, object>();
            string str = null;

            Assert.That(() => {
                str = safeView.Render(model);
            }, Throws.Nothing);
            Assert.That(str, Is.EqualTo("A mock internal error - An internal error has occurred.  Please contact system maintainer."));
        }