Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing testcases for issue#15 #32

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -140,6 +140,7 @@
<Compile Include="Storage\IsolatedStorageFileStorageTests.cs" />
<Compile Include="Storage\PersistedDictionaryTests.cs" />
<Compile Include="Submission\DefaultSubmissionClientTests.cs" />
<Compile Include="ToErrorModel\ToErrorModelTests.cs" />
<Compile Include="Utility\CountDownLatch.cs" />
<Compile Include="Utility\InMemorySubmissionClient.cs" />
<Compile Include="Utility\PasswordGenerator.cs" />
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Exceptionless.Extras;
using Exceptionless.Logging;
using Xunit;

namespace Exceptionless.Tests.ToErrorModel
{
public class ToErrorModelTests
{
[Fact]
public void SimpleExceptionHasNoInner() {
var e = new Exception("Test exception");
var model = e.ToErrorModel(GetLog());

Assert.Equal(e.Message, model.Message);
Assert.Null(model.Inner);
}

[Fact]
public void SimpleNestedExceptionWithInner()
{
var e = new Exception("Outer", new Exception("Inner"));
var model = e.ToErrorModel(GetLog());

Assert.Equal("Outer", model.Message);
Assert.Equal("Inner", model.Inner.Message);
}

[Fact]
public void AggregateExceptionWithOneInner() {
var e = new AggregateException(new Exception("Exception 1"));

var model = e.ToErrorModel(GetLog());

Assert.Equal("Exception 1", model.Inner.Message);
}

[Fact]
public void AggregateExceptionWithMultipleInners() {
var e = new AggregateException(new Exception("Exception 1"), new Exception("Exception 2"));

var model = e.ToErrorModel(GetLog());

Assert.Equal("Exception 1", model.Inner.Message);

// no way to get at "Exception 2"
}

[Fact]
public void AggregateExceptionWithInnerAggregateException() {
var e = new AggregateException(new AggregateException(new Exception("Exception 1.1"), new Exception("Exception 1.2")), new Exception("Exception 2"));

var model = e.ToErrorModel(GetLog());

// now there's no way to find 1.1, 1.2 or 2 (Needs a .Flatten())
Assert.Equal("Exception 1.1", model.Inner.Message);
}


IExceptionlessLog GetLog() {
return new NullExceptionlessLog();
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.