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); }
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); }
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)); }
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); }
public static void Ctor_Empty() { var exception = new DuplicateWaitObjectException(); Assert.NotEmpty(exception.Message); Assert.Equal(COR_E_DUPLICATEWAITOBJECT, exception.HResult); }
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))); }
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))); }