Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6033411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:28:45+00:00 2026-05-23T05:28:45+00:00

In a new project we use MvcMailer, it’s great and I would like to

  • 0

In a new project we use MvcMailer, it’s great and I would like to know how I can test it using Rhino and NUnit? There’s an other post on SO and a good Wiki page but it’s not what I’m looking for. For my controllers I usualy test them with MvcContrib’s Testhelper

  • I try first to mock the mailer class but if I do this I can’t verify my ViewBag data, I’m having problem with the PopulateBody method and I have to build my own IMailerBase interface
  • I try after this to test the mailer as I do with controller using MvcContrib but it only accept Controller object in the InitializeController() so it did’nt work.
  • There’s also a IsTestModeEnabled property in the MailerBase.cs class but when I test against it I get an error on empty URI.

Don’t know what is the best way to do this and I’m looking for help, thanks everyone!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:28:46+00:00Added an answer on May 23, 2026 at 5:28 am

    Here’s the code how I did it :

    // arrange
        var passwordMailer = MockRepository.GeneratePartialMock<PasswordMailer>();
        passwordMailer.Stub(mailer => mailer.PopulateBody(Arg<MailMessage>.Is.Anything, Arg.Is("ForgotPassword"), Arg<string>.Is.Null, Arg<Dictionary<string, string>>.Is.Null));
    
        // act
        var mailMessage = passwordMailer.ForgotPassword("test@example.com", "4454-8838-73773");
    
        // assert
        Assert.AreEqual(string.Format(Login.mailBody, "4454-8838-73773"), passwordMailer.ViewBag.Body);
        Assert.AreEqual(Login.mailSubject, mailMessage.Subject);
        Assert.AreEqual("test@example.com", mailMessage.To.First().ToString());
    

    As you can see it, you can achieve it using partialMock functionnality from Rhino.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would just like to setup a new GWT project in Eclipse and use
I would like to use Criteria API in my new project and from what
Starting a new project and would like to use one of the MVC framworks.
When starting a new project based on clang using c++11, how would you use
I use Devise in my new project,but I have some problems in roles. There
Starting a new project I'd like to use Hibernate annotations with MySQL instead of
I would use CodeIgniter in my new project, but i only use the helper
I'm starting a new project and I want to use NHibernate 3.2. I know
I'm starting a new project soon and I'd like to try to use some
i want to use stripes in our new project. This will take care of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.