This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
... | |
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> | |
<Exec Command="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v temp -p $(WebProjectOutputDir) -x node_modules"/> | |
</Target> | |
... | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
... | |
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> | |
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" /> | |
</Target> | |
... | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CollectionDefinition(nameof(WebAppFixture))] | |
public class WebAppFixtureTestCollection : ICollectionFixture<WebAppFixture> | |
{ | |
// This class has no code, and is never created. Its purpose is simply | |
// to be the place to apply [CollectionDefinition] and all the | |
// ICollectionFixture<> interfaces. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Starts an IIS Express instance to run the ExampleWebApp. | |
/// | |
/// Code heavily borrowed from Michael Whelan's blog post and Seleno (MIT license). | |
/// - Michael Whelan's blog post http://www.michael-whelan.net/testing-mvc-application-with-iis-express-webdriver/ | |
/// - Seleno https://github.com/TestStack/TestStack.Seleno | |
/// | |
/// This is an xUnit fixture class. Refer to https://xunit.github.io/docs/shared-context.html. | |
/// </summary> | |
public class WebAppFixture : IDisposable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Collection(nameof(WebAppFixture))] | |
public class _2_Running_A_Web_App | |
{ | |
/* | |
* This is a bare minimum example of starting IIS Express to run a web application for testing. | |
* It uses xUnit collection fixtures to start the web application before running the test. | |
* Only a single instance of the application is started and is shared between all tests in the collection. | |
*/ | |
[Fact] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<rule name="HTTP to HTTPs Redirect" stopProcessing="true"> | |
<match url="(.*)"/> | |
<conditions> | |
<add input="{HEADER_X-Forwarded-Proto}" pattern="https" negate="true" /> | |
</conditions> | |
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent"/> | |
</rule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Task<T> ExecuteReaderAsync<T>(string sql, Func<DbDataReader, Task<T>> readAction) | |
{ | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<T> ExecuteReaderAsync<T>(string sql, Func<DbDataReader, T> readAction) | |
{ | |
return await _pool.ExecuteAsync(_connectionString, async connection => | |
{ | |
using (var command = new OdbcCommand(sql, connection)) | |
{ | |
var dataReader = await command.ExecuteReaderAsync(); | |
return readAction(dataReader); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Task ExecuteReaderAsync(string sql, Action<DbDataReader> readAction) | |
{ | |
... | |
} | |
public Task<T> ExecuteReaderAsync<T>(string sql, Func<DbDataReader, T> readAction) | |
{ | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<List<Data>> ExecuteQuery(string sql) | |
{ | |
var results = new List<Data>(); | |
await _querier.ExecuteReaderAsync(sql, async reader => | |
{ | |
while (await reader.ReadAsync()) | |
{ | |
results.Add(ReadData(reader)); | |
} | |
}); |
NewerOlder