Exemplo n.º 1
0
        public void CanBindSpecificSeverities()
        {
            IBinder binder = new SeverityBinder(new MessageSeverity[]
                                                { MessageSeverity.CriticalError, MessageSeverity.Exception });

            Assert.IsTrue(binder.CanBind(new Message(MessageSeverity.CriticalError, string.Empty)));
            Assert.IsTrue(binder.CanBind(new Message(MessageSeverity.Exception, string.Empty)));

            Assert.IsFalse(binder.CanBind(new Message(MessageSeverity.Error, string.Empty)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a binder for the given binding.
        /// </summary>
        /// <param name="binding"></param>
        /// <returns></returns>
        private static IBinder CreateBinder(BindingElement binding)
        {
            IBinder rootBinder = new MessageTypeBinder(GetMessageTypeNames(binding));

            IBinder sourceBinder = new SourceBinder(GetSources(binding));

            rootBinder.NextBinder = sourceBinder;

            IBinder severityBinder = new SeverityBinder(GetSeverities(binding));

            sourceBinder.NextBinder = severityBinder;

            return(rootBinder);
        }
Exemplo n.º 3
0
        public void CanBind()
        {
            IBinder binder = new SeverityBinder(null);

            Assert.IsTrue(binder.CanBind(new TextMessage(MessageSeverity.Debug,
                                                         string.Empty, DateTime.Now, string.Empty)));
            Assert.IsTrue(binder.CanBind(new Message()));

            binder = new SeverityBinder(new MessageSeverity[] {});

            Assert.IsTrue(binder.CanBind(new TextMessage(MessageSeverity.Debug,
                                                         string.Empty, DateTime.Now, string.Empty)));
            Assert.IsTrue(binder.CanBind(new Message()));
        }
Exemplo n.º 4
0
        public void CanBindAllSeverities()
        {
            IBinder binder = new SeverityBinder(new MessageSeverity[] { MessageSeverity.Sink });

            Assert.IsTrue(binder.CanBind(new TextMessage(MessageSeverity.CriticalError,
                                                         string.Empty, DateTime.Now, string.Empty)));
            Assert.IsTrue(binder.CanBind(new TextMessage(MessageSeverity.Debug,
                                                         string.Empty, DateTime.Now, string.Empty)));
            Assert.IsTrue(binder.CanBind(new TextMessage(MessageSeverity.Error,
                                                         string.Empty, DateTime.Now, string.Empty)));
            Assert.IsTrue(binder.CanBind(new TextMessage(MessageSeverity.Exception,
                                                         string.Empty, DateTime.Now, string.Empty)));
            Assert.IsTrue(binder.CanBind(new TextMessage(MessageSeverity.Information,
                                                         string.Empty, DateTime.Now, string.Empty)));
            Assert.IsTrue(binder.CanBind(new TextMessage(MessageSeverity.Unknown,
                                                         string.Empty, DateTime.Now, string.Empty)));
            Assert.IsTrue(binder.CanBind(new TextMessage(MessageSeverity.Warning,
                                                         string.Empty, DateTime.Now, string.Empty)));
        }