コード例 #1
0
        public void ExistingTempDataIsntModified() {
            var sink = new Notifier();
            var filter = new NotifyFilter(sink);

            var executedContext = BuildContext();
            executedContext.Controller.TempData.Add("messages", "dont-destroy");
            filter.OnActionExecuted(executedContext);
            Assert.That(executedContext.Controller.TempData["messages"], Is.EqualTo("dont-destroy"));
        }
コード例 #2
0
        public void NewMessagesAreConcatinated() {
            var sink = new Notifier();
            var filter = new NotifyFilter(sink);
            sink.Error("Boom");

            var executedContext = BuildContext();
            executedContext.Controller.TempData.Add("messages", "dont-destroy");
            filter.OnActionExecuted(executedContext);
            Assert.That(executedContext.Controller.TempData["messages"], Is.StringContaining("dont-destroy"));
            Assert.That(executedContext.Controller.TempData["messages"], Is.StringContaining("dont-destroy"));
        }
コード例 #3
0
        public void AfterActionExecutedMessagesShouldAppearInTempData() {
            var sink = new Notifier();
            var filter = new NotifyFilter(sink);
            sink.Information("Hello world");

            var executedContext = BuildContext();
            filter.OnActionExecuted(executedContext);

            Assert.That(executedContext.Controller.TempData.ContainsKey("messages"));
            Assert.That(executedContext.Controller.TempData["messages"], Is.StringContaining("Hello world"));
        }
コード例 #4
0
ファイル: NotifierTests.cs プロジェクト: anycall/Orchard
        public void MessageServiceCanAccumulateWarningsAndErrorsToReturn() {
            INotifier notifier = new Notifier();
            Localizer T = NullLocalizer.Instance;

            notifier.Warning(T("Hello world"));
            notifier.Information(T("More Info"));
            notifier.Error(T("Boom"));

            Assert.That(notifier.List(), Has.Count.EqualTo(3));
            Assert.That(notifier.List(), Has.Some.Property("Message").EqualTo(T("Hello world")));
            Assert.That(notifier.List(), Has.Some.Property("Message").EqualTo(T("More Info")));
            Assert.That(notifier.List(), Has.Some.Property("Message").EqualTo(T("Boom")));
        }
コード例 #5
0
        public void TempDataBuildsMessagesWhenResultExecutingIsBaseViewModel() {
            var sink = new Notifier();
            var filter = new NotifyFilter(sink);
            sink.Information("Working");

            var model = new BaseViewModel();

            var context = BuildContext();
            context.Controller.TempData.Add("messages", "dont-destroy" + System.Environment.NewLine + "-" + System.Environment.NewLine);
            context.Result = new ViewResult {
                ViewData = new ViewDataDictionary<BaseViewModel>(model),
                TempData = context.Controller.TempData
            };

            filter.OnActionExecuted(context);
            filter.OnResultExecuting(new ResultExecutingContext(context, context.Result));

            var T = NullLocalizer.Instance;

            Assert.That(model.Messages, Is.Not.Null);
            Assert.That(model.Messages, Has.Count.EqualTo(2));
            Assert.That(model.Messages, Has.Some.Property("Message").EqualTo(T("dont-destroy")));
            Assert.That(model.Messages, Has.Some.Property("Message").EqualTo(T("Working")));
        }