-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d48a3ad
commit 667ca3c
Showing
14 changed files
with
187 additions
and
15 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
namespace Opw.PineBlog | ||
{ | ||
public static class Constants | ||
{ | ||
public const string SkipAzureStorageEmulatorTests = "Requires Azure Storage Emulator."; | ||
} | ||
} |
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
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
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
30 changes: 30 additions & 0 deletions
30
tests/Opw.PineBlog.Sample.Tests/Controllers/FileControllerTests.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Newtonsoft.Json; | ||
using Opw.PineBlog.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Opw.PineBlog.Sample.Controllers | ||
{ | ||
public class FileControllerTests : IClassFixture<TestWebApplicationFactory> | ||
{ | ||
private readonly TestWebApplicationFactory _factory; | ||
private readonly HttpClient _client; | ||
|
||
public FileControllerTests(TestWebApplicationFactory factory) | ||
{ | ||
_factory = factory; | ||
_client = _factory.CreateClient(); | ||
} | ||
|
||
[Fact] | ||
public async Task Get_Should_BeFound() | ||
{ | ||
var response = await _client.GetAsync("admin/file"); | ||
response.EnsureSuccessStatusCode(); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/Opw.PineBlog.Sample.Tests/Opw.PineBlog.Sample.Tests.csproj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp3.0;netcoreapp3.1</TargetFrameworks> | ||
<IsPackable>false</IsPackable> | ||
<RootNamespace>Opw.PineBlog.Sample</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.msbuild" Version="2.7.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="FluentAssertions" Version="5.9.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\samples\Opw.PineBlog.Sample\Opw.PineBlog.Sample.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="appsettings.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
35 changes: 35 additions & 0 deletions
35
tests/Opw.PineBlog.Sample.Tests/TestWebApplicationFactory.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Net.Http; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Mvc.Testing; | ||
using Microsoft.Extensions.Configuration; | ||
using Opw.PineBlog.EntityFrameworkCore; | ||
|
||
namespace Opw.PineBlog.Sample | ||
{ | ||
public class TestWebApplicationFactory : WebApplicationFactory<Startup> | ||
{ | ||
public IConfigurationRoot Configuration { get; } | ||
|
||
public TestWebApplicationFactory() | ||
{ | ||
Configuration = new ConfigurationBuilder() | ||
.AddJsonFile("appsettings.json") | ||
.Build(); | ||
} | ||
|
||
protected override IWebHostBuilder CreateWebHostBuilder() | ||
{ | ||
return new WebHostBuilder() | ||
.UseConfiguration(Configuration) | ||
.UseStartup<Startup>() | ||
.ConfigureAppConfiguration((_, config) => config.AddPineBlogConfiguration(reloadOnChange: true)); | ||
} | ||
|
||
//public new HttpClient CreateClient() | ||
//{ | ||
// var baseAddress = new Uri($"http://localhost/"); | ||
// return CreateClient(new WebApplicationFactoryClientOptions { BaseAddress = baseAddress }); | ||
//} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"ConnectionStrings": { | ||
"DefaultConnection": "Server=inMemory; Database=pineblog-db;" | ||
}, | ||
"PineBlogOptions": { | ||
"Title": "PineBlog", | ||
"Description": "A blogging engine based on ASP.NET Core MVC Razor Pages and Entity Framework Core", | ||
"CoverUrl": "/images/woods.gif", | ||
"CoverCaption": "Battle background for the Misty Woods in the game Shadows of Adam by Tim Wendorf", | ||
"CoverLink": "http://pixeljoint.com/pixelart/94359.htm", | ||
"ItemsPerPage": 2, | ||
"CreateAndSeedDatabases": true, | ||
"ConnectionStringName": "DefaultConnection", | ||
"AzureStorageConnectionString": "UseDevelopmentStorage=true", | ||
"AzureStorageBlobContainerName": "pineblog", | ||
"FileBaseUrl": "http://127.0.0.1:10000/devstoreaccount1" | ||
}, | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information" | ||
} | ||
}, | ||
"AllowedHosts": "*", | ||
"StopApplicationPath": "/stop-app", | ||
"ApplicationInsights": { | ||
"InstrumentationKey": null | ||
} | ||
} |