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
Showing
9 changed files
with
622 additions
and
12 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
52 changes: 52 additions & 0 deletions
52
src/AglCodingTest.Functions/Formatters/HtmlMediaTypeFormatter.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,52 @@ | ||
using System; | ||
using System.IO; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Net.Http.Formatting; | ||
using System.Net.Http.Headers; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace AglCodingTest.Functions.Formatters | ||
{ | ||
/// <summary> | ||
/// This represents the media type formatter entity for HTML. | ||
/// </summary> | ||
public class HtmlMediaTypeFormatter : MediaTypeFormatter | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HtmlMediaTypeFormatter"/> class. | ||
/// </summary> | ||
public HtmlMediaTypeFormatter() | ||
{ | ||
this.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html")); | ||
this.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain")); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool CanReadType(Type type) | ||
{ | ||
return false; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool CanWriteType(Type type) | ||
{ | ||
return typeof(string) == type; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken) | ||
{ | ||
using (var writer = new StreamWriter(writeStream)) | ||
{ | ||
writer.WriteLine(value.ToString()); | ||
} | ||
|
||
var tcs = new TaskCompletionSource<Stream>(); | ||
tcs.SetResult(writeStream); | ||
|
||
return tcs.Task; | ||
} | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
test/AglCodingTest.Functions.Tests/AglCodingTest.Functions.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,99 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{1CAF0093-DD43-45FB-9E21-CF7147A4F49E}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>AglCodingTest.Functions.Tests</RootNamespace> | ||
<AssemblyName>AglCodingTest.Functions.Tests</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="AutoFixture"> | ||
<Version>3.51.0</Version> | ||
</PackageReference> | ||
<PackageReference Include="AutoFixture.AutoMoq"> | ||
<Version>3.51.0</Version> | ||
</PackageReference> | ||
<PackageReference Include="AutoFixture.Xunit2"> | ||
<Version>3.51.0</Version> | ||
</PackageReference> | ||
<PackageReference Include="FluentAssertions"> | ||
<Version>4.19.4</Version> | ||
</PackageReference> | ||
<PackageReference Include="Legacy2CPSWorkaround" Version="1.0.0"> | ||
<PrivateAssets>All</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Moq"> | ||
<Version>4.7.142</Version> | ||
</PackageReference> | ||
<PackageReference Include="Newtonsoft.Json"> | ||
<Version>9.0.1</Version> | ||
</PackageReference> | ||
<PackageReference Include="xunit"> | ||
<Version>2.3.0</Version> | ||
</PackageReference> | ||
<PackageReference Include="xunit.runner.console"> | ||
<Version>2.3.0</Version> | ||
</PackageReference> | ||
<PackageReference Include="xunit.runner.visualstudio"> | ||
<Version>2.3.0</Version> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="AglCodingTestHttpTriggerFunctionTests.cs" /> | ||
<Compile Include="Fixtures\FooFunctionOptions.cs" /> | ||
<Compile Include="Fixtures\FunctionFixture.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\AglCodingTest.Functions\AglCodingTest.Functions.csproj"> | ||
<Project>{974e7b3f-80de-486c-8968-27219d2f079f}</Project> | ||
<Name>AglCodingTest.Functions</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\..\src\AglCodingTest.Models\AglCodingTest.Models.csproj"> | ||
<Project>{c7d5bbb5-482d-49f6-9e0e-9f33f95a64cd}</Project> | ||
<Name>AglCodingTest.Models</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\..\src\AglCodingTest.Services\AglCodingTest.Services.csproj"> | ||
<Project>{2d1b8fd2-f4f5-4354-80fb-569d3491d78b}</Project> | ||
<Name>AglCodingTest.Services</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
Oops, something went wrong.