forked from smsohan/MvcMailer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the extenstion methods into MvcMailMessage
- Loading branch information
Showing
72 changed files
with
11,808 additions
and
345 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="NUnit.Runners" version="2.6.1" /> | ||
</packages> |
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 |
---|---|---|
@@ -1,92 +1,92 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{3664DD95-3C70-421E-96CA-9B63EE086C27}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Mvc.Mailer.Test</RootNamespace> | ||
<AssemblyName>Mvc.Mailer.Test</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</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> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Moq"> | ||
<HintPath>..\lib\Moq\Moq.dll</HintPath> | ||
</Reference> | ||
<Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\lib\NUnit.2.5.9.10348\lib\nunit.framework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.configuration" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\lib\MVC4\System.Web.Mvc.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ExtensionMethods\HtmlHelperExtensionsTest.cs" /> | ||
<Compile Include="LinkedResourceProviderTest.cs" /> | ||
<Compile Include="MailerBaseTest.cs" /> | ||
<Compile Include="ExtensionMethods\MailMessageExtensionsTest.cs" /> | ||
<Compile Include="Mocks.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="SmtpClientWrapperTest.cs" /> | ||
<Compile Include="StringResultTest.cs" /> | ||
<Compile Include="TestSmtpClientTest.cs" /> | ||
<Compile Include="ExtensionMethods\UrlHelperExtensionsTest.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Mvc.Mailer\Mvc.Mailer.csproj"> | ||
<Project>{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}</Project> | ||
<Name>Mvc.Mailer</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="Chrysanthemum.jpg"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<PostBuildEvent> | ||
</PostBuildEvent> | ||
</PropertyGroup> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{3664DD95-3C70-421E-96CA-9B63EE086C27}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Mvc.Mailer.Test</RootNamespace> | ||
<AssemblyName>Mvc.Mailer.Test</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</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> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Moq"> | ||
<HintPath>..\lib\Moq\Moq.dll</HintPath> | ||
</Reference> | ||
<Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\lib\NUnit.2.5.9.10348\lib\nunit.framework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.configuration" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\lib\MVC4\System.Web.Mvc.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ExtensionMethods\HtmlHelperExtensionsTest.cs" /> | ||
<Compile Include="LinkedResourceProviderTest.cs" /> | ||
<Compile Include="MailerBaseTest.cs" /> | ||
<Compile Include="MvcMailMessageTest.cs" /> | ||
<Compile Include="Mocks.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="SmtpClientWrapperTest.cs" /> | ||
<Compile Include="StringResultTest.cs" /> | ||
<Compile Include="TestSmtpClientTest.cs" /> | ||
<Compile Include="ExtensionMethods\UrlHelperExtensionsTest.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Mvc.Mailer\Mvc.Mailer.csproj"> | ||
<Project>{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}</Project> | ||
<Name>Mvc.Mailer</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="Chrysanthemum.jpg"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<PostBuildEvent> | ||
</PostBuildEvent> | ||
</PropertyGroup> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
134 changes: 67 additions & 67 deletions
134
...nsionMethods/MailMessageExtensionsTest.cs → Mvc.Mailer.Test/MvcMailMessageTest.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 |
---|---|---|
@@ -1,68 +1,68 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using System.Net.Mail; | ||
using System.IO; | ||
using Moq; | ||
|
||
namespace Mvc.Mailer.Test.ExtensionMethods { | ||
[TestFixture] | ||
public class MailMessageExtensionsTest { | ||
|
||
private SmtpClientWrapper _smtpClient; | ||
private MailMessage _mailMessage; | ||
private DirectoryInfo _mailDirectory; | ||
|
||
[SetUp] | ||
public void SetUp() { | ||
var smtpClient = new SmtpClient { | ||
DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory | ||
}; | ||
|
||
_mailDirectory = Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "Mails")); | ||
smtpClient.PickupDirectoryLocation = _mailDirectory.FullName; | ||
smtpClient.Host = "smtp.gmail.com"; | ||
smtpClient.Port = 597; | ||
_smtpClient = new SmtpClientWrapper { InnerSmtpClient = smtpClient }; | ||
_mailMessage = new MailMessage { From = new MailAddress("gaga@gaga.com") }; | ||
_mailMessage.To.Add("gigi@gigi.com"); | ||
_mailMessage.Subject = "Hello!"; | ||
_mailMessage.Body = "Mail Body"; | ||
} | ||
|
||
[Test] | ||
public void TestSend() { | ||
_mailMessage.Send(_smtpClient); | ||
Assert.Pass("Mail Send working since no exception wast thrown"); | ||
} | ||
|
||
[Test] | ||
public void TestSendAsync() { | ||
_mailMessage.SendAsync(smtpClient: _smtpClient); | ||
Assert.Pass("Mail Send Async working since no exception wast thrown"); | ||
} | ||
|
||
[Test] | ||
public void SendAsync_with_userState_should_pass_that() { | ||
var client = new Mock<ISmtpClient>(); | ||
client.Setup(c => c.SendAsync(_mailMessage, "something")); | ||
_mailMessage.SendAsync(userState: "something", smtpClient: client.Object); | ||
client.VerifyAll(); | ||
} | ||
|
||
[Test] | ||
public void In_Test_Mode_should_use_TestSmtpClient() { | ||
TestSmtpClient.SentMails.Clear(); | ||
MailerBase.IsTestModeEnabled = true; | ||
_mailMessage.Send(); | ||
Assert.AreEqual(1, TestSmtpClient.SentMails.Count); | ||
Assert.AreSame(_mailMessage, TestSmtpClient.SentMails[0]); | ||
} | ||
|
||
[TearDown] | ||
public void TearDown() { | ||
MailerBase.IsTestModeEnabled = false; | ||
TestSmtpClient.SentMails.Clear(); | ||
_mailDirectory.Delete(true); | ||
} | ||
} | ||
using System; | ||
using NUnit.Framework; | ||
using System.Net.Mail; | ||
using System.IO; | ||
using Moq; | ||
|
||
namespace Mvc.Mailer.Test { | ||
[TestFixture] | ||
public class MvcMailMessageTest { | ||
|
||
private SmtpClientWrapper _smtpClient; | ||
private MvcMailMessage _mailMessage; | ||
private DirectoryInfo _mailDirectory; | ||
|
||
[SetUp] | ||
public void SetUp() { | ||
var smtpClient = new SmtpClient { | ||
DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory | ||
}; | ||
|
||
_mailDirectory = Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "Mails")); | ||
smtpClient.PickupDirectoryLocation = _mailDirectory.FullName; | ||
smtpClient.Host = "smtp.gmail.com"; | ||
smtpClient.Port = 597; | ||
_smtpClient = new SmtpClientWrapper { InnerSmtpClient = smtpClient }; | ||
_mailMessage = new MvcMailMessage { From = new MailAddress("gaga@gaga.com") }; | ||
_mailMessage.To.Add("gigi@gigi.com"); | ||
_mailMessage.Subject = "Hello!"; | ||
_mailMessage.Body = "Mail Body"; | ||
} | ||
|
||
[Test] | ||
public void TestSend() { | ||
_mailMessage.Send(_smtpClient); | ||
Assert.Pass("Mail Send working since no exception wast thrown"); | ||
} | ||
|
||
[Test] | ||
public void TestSendAsync() { | ||
_mailMessage.SendAsync(smtpClient: _smtpClient); | ||
Assert.Pass("Mail Send Async working since no exception wast thrown"); | ||
} | ||
|
||
[Test] | ||
public void SendAsync_with_userState_should_pass_that() { | ||
var client = new Mock<ISmtpClient>(); | ||
client.Setup(c => c.SendAsync(_mailMessage, "something")); | ||
_mailMessage.SendAsync(userState: "something", smtpClient: client.Object); | ||
client.VerifyAll(); | ||
} | ||
|
||
[Test] | ||
public void In_Test_Mode_should_use_TestSmtpClient() { | ||
TestSmtpClient.SentMails.Clear(); | ||
MailerBase.IsTestModeEnabled = true; | ||
_mailMessage.Send(); | ||
Assert.AreEqual(1, TestSmtpClient.SentMails.Count); | ||
Assert.AreSame(_mailMessage, TestSmtpClient.SentMails[0]); | ||
} | ||
|
||
[TearDown] | ||
public void TearDown() { | ||
MailerBase.IsTestModeEnabled = false; | ||
TestSmtpClient.SentMails.Clear(); | ||
_mailDirectory.Delete(true); | ||
} | ||
} | ||
} |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="NUnit" version="2.6.1" targetFramework="net40" /> | ||
</packages> |
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mvc.Mailer", "Mvc.Mailer\Mvc.Mailer.csproj", "{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mvc.Mailer.Test", "Mvc.Mailer.Test\Mvc.Mailer.Test.csproj", "{3664DD95-3C70-421E-96CA-9B63EE086C27}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{3664DD95-3C70-421E-96CA-9B63EE086C27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3664DD95-3C70-421E-96CA-9B63EE086C27}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3664DD95-3C70-421E-96CA-9B63EE086C27}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3664DD95-3C70-421E-96CA-9B63EE086C27}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mvc.Mailer", "Mvc.Mailer\Mvc.Mailer.csproj", "{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mvc.Mailer.Test", "Mvc.Mailer.Test\Mvc.Mailer.Test.csproj", "{3664DD95-3C70-421E-96CA-9B63EE086C27}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{37B58562-EF1A-47FE-A02E-98C82D5FB5BC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{3664DD95-3C70-421E-96CA-9B63EE086C27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3664DD95-3C70-421E-96CA-9B63EE086C27}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3664DD95-3C70-421E-96CA-9B63EE086C27}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3664DD95-3C70-421E-96CA-9B63EE086C27}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.