Exemplo n.º 1
0
 public void TestEquals()
 {
     var logEvent1 = new LogEventInfo(LogLevel.Debug, "logger1", "message1");
     AsyncContinuation cont1 = new AsyncContinuation(exception => { });
     var async1 = new AsyncLogEventInfo(logEvent1, cont1);
     var async2 = new AsyncLogEventInfo(logEvent1, cont1);
     Assert.True(async1.Equals(async2));
     Assert.True(async1 == async2);
     Assert.False(async1 != async2);
     Assert.Equal(async1.GetHashCode(), async2.GetHashCode());
 }
Exemplo n.º 2
0
        public void TestNotEquals()
        {
            var logEvent1 = new LogEventInfo(LogLevel.Debug, "logger1", "message1");
            AsyncContinuation cont1 = new AsyncContinuation(exception => { });
            AsyncContinuation cont2 = new AsyncContinuation(exception => { InternalLogger.Debug("test"); });
            var async1 = new AsyncLogEventInfo(logEvent1, cont1);
            var async2 = new AsyncLogEventInfo(logEvent1, cont2);
            Assert.False(async1.Equals(async2));
            Assert.False(async1 == async2);
            Assert.True(async1 != async2);

            //2 delegates will return the same hashcode, http://stackoverflow.com/questions/6624151/why-do-2-delegate-instances-return-the-same-hashcode
            //and that isn't really bad, so ignore this
            //   Assert.NotEqual(async1.GetHashCode(), async2.GetHashCode());
        }