Giter Site home page Giter Site logo

Comments (3)

andrewdavey avatar andrewdavey commented on September 25, 2024

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.

dotnetchris avatar dotnetchris commented on September 25, 2024

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.

dotnetchris avatar dotnetchris commented on September 25, 2024

Switched from using new Email().Send() to taking an explicit dependency to IEmailService and the peasants rejoice.

from postal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.