コード例 #1
0
 public static void Ctor_String()
 {
     string parameterName = "THISISAPARAMETERNAME";
     var exception = new DuplicateWaitObjectException(parameterName);
     Assert.True(exception.Message.Contains(parameterName));
     Assert.Equal(COR_E_DUPLICATEWAITOBJECT, exception.HResult);
 }
コード例 #2
0
 public void GeneralExceptionTest()
 {
     DuplicateWaitObjectException ex = new DuplicateWaitObjectException("dog");
     this.FakeLogger.WithLogLevel(LogLevel.Error).WriteGeneralException(ex);
     Assert.Equal(ex, logger.LastLogEntry.Exception);
     Assert.Equal(LogLevel.Error, logger.LastLogEntry.LogLevel);
 }
コード例 #3
0
 public static void Ctor_String_String()
 {
     string parameterName = "THISISAPARAMETERNAME";
     string message = "CreatedDuplicateWaitObjectException";
     var exception = new DuplicateWaitObjectException(parameterName, message);
     Assert.True(exception.Message.Contains(parameterName));
     Assert.True(exception.Message.Contains(message));
 }
コード例 #4
0
 public static void Ctor_String_Exception()
 {
     string message = "CreatedDuplicateWaitObjectException";
     var innerException = new Exception("Created inner exception");
     var exception = new DuplicateWaitObjectException(message, innerException);
     Assert.Equal(message, exception.Message);
     Assert.Equal(COR_E_DUPLICATEWAITOBJECT, exception.HResult);
     Assert.Same(innerException, exception.InnerException);
     Assert.Equal(innerException.HResult, exception.InnerException.HResult);
 }
コード例 #5
0
 public static void Ctor_Empty()
 {
     var exception = new DuplicateWaitObjectException();
     Assert.NotEmpty(exception.Message);
     Assert.Equal(COR_E_DUPLICATEWAITOBJECT, exception.HResult);
 }
コード例 #6
0
        public void WithAllSetters()
        {
            var logEntryBuilder = new LogEntryBuilder(_logger);

            var exception = new DuplicateWaitObjectException("foo");
            logEntryBuilder.WithMessage("foo {0}", "bar")
                           .AsFatal()
                           .WithEventId(42)
                           .WithCause("cause")
                           .WithResolution("resolution")
                           .WithException(exception)
                           .Write();

            _logger.AssertWasCalled(logger => logger.Write(Arg<LogEntry>.Matches(logEntry =>
                                                                                 logEntry.Message == "foo bar" &&
                                                                                 logEntry.Level == LogLevel.Fatal &&
                                                                                 logEntry.EventId == 42 &&
                                                                                 logEntry.Cause == "cause" &&
                                                                                 logEntry.Resolution == "resolution" &&
                                                                                 logEntry.Exception == exception)));
        }
コード例 #7
0
        public void WithException()
        {
            var logEntryBuilder = new LogEntryBuilder(_logger);

            var exception = new DuplicateWaitObjectException("foo");
            logEntryBuilder.WithException(exception).Write();

            _logger.AssertWasCalled(logger => logger.Write(Arg<LogEntry>.Matches(logEntry => logEntry.Exception == exception)));
        }