Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Commit

Permalink
unit test for request serviuces bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Kanzhelev committed May 18, 2015
1 parent 06fe58d commit cab7d6b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/FunctionalTestUtils/TelemetryTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public abstract class TelemetryTestsBase
{
protected const int TestTimeoutMs = 5000;
protected const int TestTimeoutMs = 10000;

public void ValidateBasicRequest(InProcessServer server, string requestPath, RequestTelemetry expected)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.ApplicationInsights;
using Microsoft.AspNet.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Mvc6Framework45.FunctionalTests.Controllers
{
public class UseRequestServicesController : Controller
{
public IActionResult Index()
{
TelemetryClient telemetryClient = (TelemetryClient)this.Resolver.GetService(typeof(TelemetryClient));

telemetryClient.TrackEvent("GetMethod");
telemetryClient.TrackMetric("GetMetric", 10);

return View();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,30 @@ public void TestMixedTelemetryItemsReceived()
Assert.NotNull(traceTelemetry);
}
}

[Fact]
public void TestMixedTelemetryItemsUseRequestServicesRecieved()
{
using (var server = new InProcessServer(assemblyName))
{
for (int i = 0; i < 2; i++)
{
var httpClient = new HttpClient();
var task = httpClient.GetAsync(server.BaseHost + "/UseRequestServices/");
task.Wait(TestTimeoutMs * 2);

var request = server.BackChannel.Buffer.OfType<RequestTelemetry>().Single();
var eventTelemetry = server.BackChannel.Buffer.OfType<EventTelemetry>().Single();
var metricTelemetry = server.BackChannel.Buffer.OfType<MetricTelemetry>().Single();

Assert.Equal(3, server.BackChannel.Buffer.Count);
Assert.NotNull(request);
Assert.NotNull(eventTelemetry);
Assert.NotNull(metricTelemetry);

server.BackChannel.Buffer.Clear();
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@{
ViewBag.Title = "UseRequestServices";
}

<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000">
</div>

<div class="row">
</div>

0 comments on commit cab7d6b

Please sign in to comment.