using Microsoft.AspNet.SignalR.Client; using System; using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Threading; using Xunit; namespace E2ETests { public partial class SmokeTests { private void VerifyStaticContentServed() { Console.WriteLine("Validating if static contents are served.."); Console.WriteLine("Fetching favicon.ico.."); var response = httpClient.GetAsync("favicon.ico").Result; ThrowIfResponseStatusNotOk(response); Console.WriteLine("Etag received: {0}", response.Headers.ETag.Tag); //Check if you receive a NotModified on sending an etag Console.WriteLine("Sending an IfNoneMatch header with e-tag"); httpClient.DefaultRequestHeaders.IfNoneMatch.Add(response.Headers.ETag); response = httpClient.GetAsync("favicon.ico").Result; Assert.Equal(HttpStatusCode.NotModified, response.StatusCode); httpClient.DefaultRequestHeaders.IfNoneMatch.Clear(); Console.WriteLine("Successfully received a NotModified status"); Console.WriteLine("Fetching /Content/bootstrap.css.."); response = httpClient.GetAsync("Content/bootstrap.css").Result; ThrowIfResponseStatusNotOk(response); Console.WriteLine("Verified static contents are served successfully"); } private void VerifyHomePage(HttpResponseMessage response, string responseContent, bool useNtlmAuthentication = false) { Console.WriteLine("Home page content : {0}", responseContent); Assert.Equal(HttpStatusCode.OK, response.StatusCode); ValidateLayoutPage(responseContent); Assert.Contains("Home Page – MVC Music Store", responseContent, StringComparison.OrdinalIgnoreCase); if (!useNtlmAuthentication) { //We don't display these for Ntlm Assert.Contains("Register", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("Login", responseContent, StringComparison.OrdinalIgnoreCase); } Assert.Contains("mvcmusicstore.codeplex.com", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("/Images/home-showcase.png", responseContent, StringComparison.OrdinalIgnoreCase); Console.WriteLine("Application initialization successful."); } private void ValidateLayoutPage(string responseContent) { Assert.Contains("ASP.NET MVC Music Store", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("
  • Home
  • ", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("Store ", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("