Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added sparkpost-net-core-compact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sparkpost-net-core.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 20 additions & 12 deletions src/SparkPost.Acceptance/SparkPost.Acceptance.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>SparkPost.Acceptance</AssemblyName>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Should" Version="1.1.20" />
<PackageReference Include="SpecFlow" Version="3.1.89" />
<PackageReference Include="SpecFlow.NUnit" Version="3.1.89" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.1.89" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="SpecFlow.xUnit" Version="3.9.74" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74" />
<ProjectReference Include="..\SparkPost\SparkPost.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="testtextfile.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Folder Include="Properties\" />
</ItemGroup>
</Project>

</Project>
63 changes: 63 additions & 0 deletions src/SparkPost.Acceptance/TransmissionsSteps.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using TechTalk.SpecFlow;

namespace SparkPost.Acceptance
{
[Binding]
public class TransmissionsSteps
{
[Given(@"I have a new transmission")]
public void GivenIHaveANewTransmission()
{
ScenarioContext.Current.Pending();
}

[Given(@"the transmission is meant to be sent from '(.*)'")]
public void GivenTheTransmissionIsMeantToBeSentFrom(string p0)
{
ScenarioContext.Current.Pending();
}

[Given(@"the transmission is meant to be sent to '(.*)'")]
public void GivenTheTransmissionIsMeantToBeSentTo(string p0)
{
ScenarioContext.Current.Pending();
}

[Given(@"the transmission content is")]
public void GivenTheTransmissionContentIs(Table table)
{
ScenarioContext.Current.Pending();
}

[Given(@"the transmission has a text file attachment")]
public void GivenTheTransmissionHasATextFileAttachment()
{
ScenarioContext.Current.Pending();
}

[Given(@"the transmission template id is set to '(.*)'")]
public void GivenTheTransmissionTemplateIdIsSetTo(string p0)
{
ScenarioContext.Current.Pending();
}

[Given(@"the transmission is meant to be CCd to '(.*)'")]
public void GivenTheTransmissionIsMeantToBeCCdTo(string p0)
{
ScenarioContext.Current.Pending();
}

[Given(@"the transmission is meant to be BCCd to '(.*)'")]
public void GivenTheTransmissionIsMeantToBeBCCdTo(string p0)
{
ScenarioContext.Current.Pending();
}

[When(@"I send the transmission")]
public void WhenISendTheTransmission()
{
ScenarioContext.Current.Pending();
}
}
}
33 changes: 23 additions & 10 deletions src/SparkPost.Tests/SparkPost.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>SparkPost.Tests</AssemblyName>
<TargetFramework>netcoreapp2.1</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="AutoMoq" Version="2.0.0" />
<PackageReference Include="CastAs" Version="4.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Should" Version="1.1.20" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SparkPost\SparkPost.csproj" />
</ItemGroup>
</Project>

</Project>
18 changes: 9 additions & 9 deletions src/SparkPost.Tests/SuppressionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public DeleteTests()
email = Guid.NewGuid().ToString();
}

[Fact]
[Test]
public async Task It_should_return_true_if_the_web_request_returns_no_content()
{
var result = await suppressions.Delete(email);
Assert.True(result);
}

[Fact]
[Test]
public async Task It_should_return_false_if_the_web_request_returns_anything_but_no_content()
{
response.StatusCode = HttpStatusCode.Accepted;
Expand All @@ -58,7 +58,7 @@ public async Task It_should_return_false_if_the_web_request_returns_anything_but
Assert.False(deleted);
}

[Fact]
[Test]
public async Task It_should_build_the_web_request_parameters_correctly()
{
var version = Guid.NewGuid().ToString();
Expand All @@ -79,7 +79,7 @@ public async Task It_should_build_the_web_request_parameters_correctly()
await suppressions.Delete(email);
}

[Fact]
[Test]
public async Task It_should_encode_the_email_address()
{
var version = Guid.NewGuid().ToString();
Expand Down Expand Up @@ -127,30 +127,30 @@ public CreateOrUpdateTests()
suppressions = new Suppressions(client.Object, requestSender.Object, dataMapper.Object);
}

[Fact]
[Test]
public async Task It_should_return_a_response_when_the_web_request_is_ok()
{
var result = await suppressions.CreateOrUpdate(suppressionsList);
Assert.NotNull(result);
}

[Fact]
[Test]
public async Task It_should_return_the_reason_phrase()
{
response.ReasonPhrase = Guid.NewGuid().ToString();
var result = await suppressions.CreateOrUpdate(suppressionsList);
Assert.Equal(response.ReasonPhrase, result.ReasonPhrase);
}

[Fact]
[Test]
public async Task It_should_return_the_content()
{
response.Content = Guid.NewGuid().ToString();
var result = await suppressions.CreateOrUpdate(suppressionsList);
Assert.Equal(response.Content, result.Content);
}

[Fact]
[Test]
public async Task It_should_make_a_properly_formed_request()
{
client.Setup(x => x.Version).Returns(Guid.NewGuid().ToString());
Expand All @@ -168,7 +168,7 @@ public async Task It_should_make_a_properly_formed_request()
await suppressions.CreateOrUpdate(suppressionsList);
}

[Fact]
[Test]
public async Task It_should_throw_if_the_http_status_code_is_not_ok()
{
response.StatusCode = HttpStatusCode.Accepted;
Expand Down
8 changes: 4 additions & 4 deletions src/SparkPost/File.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.IO;
using System.Web;
using SparkPost.Utilities;

namespace SparkPost
{
Expand All @@ -25,7 +25,7 @@ public abstract class File

public static T Create<T>(byte[] content) where T : File, new()
{
return Create<T>(content, String.Empty);
return Create<T>(content, string.Empty);
}

public static T Create<T>(byte[] content, string name) where T : File, new()
Expand All @@ -34,7 +34,7 @@ public abstract class File
if (content != null)
{
result.Data = Convert.ToBase64String(content);
result.Type = MimeMapping.MimeUtility.GetMimeMapping(name);
result.Type = MimeMapping.GetContentType(name);
result.Name = name;
}
;
Expand All @@ -43,7 +43,7 @@ public abstract class File

public static T Create<T>(Stream content) where T : File, new()
{
return Create<T>(content, String.Empty);
return Create<T>(content, string.Empty);
}

public static T Create<T>(Stream content, string name) where T : File, new()
Expand Down
5 changes: 4 additions & 1 deletion src/SparkPost/ITemplates.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace SparkPost
{
Expand All @@ -25,5 +26,7 @@ public interface ITemplates
Task<RetrieveTemplatesResponse> List();

Task<bool> Delete(string templateId);

Task<TemplateContent> Preview(string templateId, IDictionary<string, object> substitutionData, bool? draft = null);
}
}
4 changes: 1 addition & 3 deletions src/SparkPost/RequestMethods/Get.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
Expand Down
4 changes: 1 addition & 3 deletions src/SparkPost/SendingDomains.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Net;
using System.Threading.Tasks;
using System.Web;
using Microsoft.AspNetCore.WebUtilities;
using SparkPost.RequestSenders;
using SparkPost.Utilities;

Expand Down Expand Up @@ -109,7 +107,7 @@ public async Task<Response> Delete(string domain)
if (response.StatusCode == HttpStatusCode.NoContent)
{
response.StatusCode = HttpStatusCode.OK;
response.ReasonPhrase = ReasonPhrases.GetReasonPhrase((int)HttpStatusCode.OK);
response.ReasonPhrase = nameof(HttpStatusCode.OK);
}

if (response.StatusCode != HttpStatusCode.OK)
Expand Down
51 changes: 27 additions & 24 deletions src/SparkPost/SparkPost.csproj
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyTitle>SparkPost</AssemblyTitle>
<Company>SparkPost</Company>
<Product>SparkPost</Product>
<Description>SparkPost API</Description>
<Copyright>Copyright 2022</Copyright>
<Version>2.0.2</Version>
<AssemblyVersion>2.0.2</AssemblyVersion>
<FileVersion>2.0.2</FileVersion>
<Authors>Darren Cauthon; Adam Hathcock</Authors>
<icon>https://www.sparkpost.com/sites/default/files/attachments/SparkPost_Logo_2-Color_Gray-Orange_RGB.svg</icon>
<PackageId>SparkPost</PackageId>
<license>https://github.com/darrencauthon/csharp-sparkpost/blob/master/LICENSE.md</license>
<PackageProjectUrl>https://github.com/SparkPost/csharp-sparkpost</PackageProjectUrl>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageReleaseNotes>Added support to pass a user-agent.</PackageReleaseNotes>
<PackageTags>email</PackageTags>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>10</LangVersion>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
<Version>1.14.0.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>SparkPost.NetCore</PackageId>
<Description>Lean Sparkpost API client port to .net standard 2.0</Description>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/maxlego/csharp-sparkpost</PackageProjectUrl>
<RepositoryUrl>https://github.com/maxlego/csharp-sparkpost</RepositoryUrl>
<PackageIcon>sparkpost-net-core.png</PackageIcon>
<PackageIconUrl />
<PackageReleaseNotes>Added template preview functionality</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="MimeMapping" Version="1.0.1.37" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\LICENSE.md" Pack="true" PackagePath="">
<Link>LICENSE.md</Link>
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\sparkpost-net-core.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>

</Project>
Loading