Comments (3)
The view engine infrastructure that Postal uses is very tied to ASP.NET. So running outside of this context is always going to cause problems.
Options available:
1- Switch to using Postal's FileSystemRazorViewEngine
var engines = new ViewEngineCollection();
engines.Add(new FileSystemRazorViewEngine(viewsPath));
var service = new EmailService(engines);
service.Send(myEmail);
This uses the RazorEngine library, which hasn't always provided support for all of Razor's features, but may be enough for your needs.
2- Don't test the rendering of the email views in a unit test. Instead mock and verify Postal's IEmailService.Send
method.
var emailService = new Mock<IEmailService>();
dynamic email = null;
emailService.Setup(s=>s.Send(It.IsAny<Email>())).Callback<Email>(e => email = e);
// pass the emailService to your RegistrationOrchestrator
// call TrySendEmail...
// then assert things about he email object.
Asset.Equal("example", email.Subject);
from postal.
Thanks for the update on this Andrew, going with the verified call to Send should be good enough from my specification level, i have an integration test that i can use for rendering the email. I was just wondering if there was a simple fix here.
I might try the filesystem engine but I'm extremely hesitant to adding view engines, i'm using a custom view engine and i always have fear of apocalypse from adding another view engine and that some of my expectations in my custom view engine causes chaos with it.
from postal.
Switched from using new Email().Send() to taking an explicit dependency to IEmailService and the peasants rejoice.
from postal.
Related Issues (20)
- Add support on other html attributes except alt in @Html.EmbedImage() HOT 2
- How to add external link with params? HOT 2
- Is this project still being supported? HOT 3
- How to identify if the email is sent or not HOT 4
- Html Helpers not working from console application HOT 4
- Postal MVC5 project references MVC 5.1.0.0 instead of 5.1.2 as the requirements state HOT 7
- Postal w/o MVC NuGet package?
- How to provide smtp settings runtime(not in web or app config)
- With Framework 4.6.2 it give error Attempted to access an element as a type incompatible with the array HOT 6
- Previewing emails with addresses with names HOT 4
- Install-Package : Input string was not in a correct format. HOT 6
- Continuation of Postal HOT 26
- enable sasl authentification HOT 7
- System.ArgumentNullException with .NET 4.5.2 WebApi HOT 9
- Sample For Postal.AspnetCore? HOT 3
- The parameter 'addresses' cannot be an empty string. HOT 1
- Layouts Stopped Working
- MVC4 throws exception when using autofac and MVC async controller actions HOT 3
- How to use Postal with Unity IoC Container MVC 5?
- Subject encoding HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postal.