Skip to content

Commit

Permalink
Fix deserializing of log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko committed Jun 19, 2017
1 parent 26a53df commit ae47298
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/ReportPortal.NUnitExtension/ReportPortalListener.Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace ReportPortal.NUnitExtension
public partial class ReportPortalListener
{
public delegate void TestStartedHandler(object sender, TestItemStartedEventArgs e);

public static event TestStartedHandler BeforeTestStarted;
public static event TestStartedHandler AfterTestStarted;

Expand All @@ -39,7 +40,8 @@ public void StartTest(XmlDocument xmlDoc)
}
catch (Exception exp)
{
Console.WriteLine("Exception was thrown in 'BeforeTestStarted' subscriber." + Environment.NewLine + exp);
Console.WriteLine("Exception was thrown in 'BeforeTestStarted' subscriber." + Environment.NewLine +
exp);
}
if (!beforeTestEventArg.Canceled)
{
Expand All @@ -51,11 +53,13 @@ public void StartTest(XmlDocument xmlDoc)

try
{
if (AfterTestStarted != null) AfterTestStarted(this, new TestItemStartedEventArgs(Bridge.Service, startTestRequest, test));
if (AfterTestStarted != null)
AfterTestStarted(this, new TestItemStartedEventArgs(Bridge.Service, startTestRequest, test));
}
catch (Exception exp)
{
Console.WriteLine("Exception was thrown in 'AfterTestStarted' subscriber." + Environment.NewLine + exp);
Console.WriteLine("Exception was thrown in 'AfterTestStarted' subscriber." + Environment.NewLine +
exp);
}
}
}
Expand All @@ -66,6 +70,7 @@ public void StartTest(XmlDocument xmlDoc)
}

public delegate void TestFinishedHandler(object sender, TestItemFinishedEventArgs e);

public static event TestFinishedHandler BeforeTestFinished;
public static event TestFinishedHandler AfterTestFinished;

Expand Down Expand Up @@ -148,18 +153,22 @@ public void FinishTest(XmlDocument xmlDoc)
}
catch (Exception exp)
{
Console.WriteLine("Exception was thrown in 'BeforeTestFinished' subscriber." + Environment.NewLine + exp);
Console.WriteLine("Exception was thrown in 'BeforeTestFinished' subscriber." +
Environment.NewLine + exp);
}

_testFlowIds[id].Finish(finishTestRequest);

try
{
if (AfterTestFinished != null) AfterTestFinished(this, new TestItemFinishedEventArgs(Bridge.Service, finishTestRequest, _testFlowIds[id]));
if (AfterTestFinished != null)
AfterTestFinished(this,
new TestItemFinishedEventArgs(Bridge.Service, finishTestRequest, _testFlowIds[id]));
}
catch (Exception exp)
{
Console.WriteLine("Exception was thrown in 'AfterTestFinished' subscriber." + Environment.NewLine + exp);
Console.WriteLine("Exception was thrown in 'AfterTestFinished' subscriber." +
Environment.NewLine + exp);
}
}

Expand All @@ -180,7 +189,16 @@ public void TestOutput(XmlDocument xmlDoc)
if (_testFlowNames.ContainsKey(fullTestName))
{
var serializer = new JavaScriptSerializer();
var logRequest = serializer.Deserialize<AddLogItemRequest>(message);
AddLogItemRequest logRequest = null;
try
{
logRequest = serializer.Deserialize<AddLogItemRequest>(message);
}
catch (Exception)
{

}

if (logRequest != null)
{
_testFlowNames[fullTestName].Log(logRequest);
Expand Down

0 comments on commit ae47298

Please sign in to comment.