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

  • Home
  • SEARCH
  • 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 8566781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:44:04+00:00 2026-06-11T17:44:04+00:00

I’ve got an interface being mocked: public interface IEmailService { void SendAsHtml(string to, string

  • 0

I’ve got an interface being mocked:

public interface IEmailService
{
    void SendAsHtml(string to, string from, string subject, string notification);
    void SendAsHtml(string to, string from, string subject, string notification, string[] cc);
}

It was previously a single method with a params string[] cc but I split the methods up while attempting to figure out what is wrong on our build server. What I really want is a strict mock, but I am running it as dynamic right now so I can compare results, using the following verification:

emailService.Verify(es => es.SendAsHtml(accountEmail, fromEmail, subject, expectedEmailString));

The parameters match up on accountEmail, fromEmail and subject – it is the expectedEmailString (constructed in the method under test via string.Format) that does not seem to be working. I’ve written expected and actual values to the console while testing and when viewing the output they appear to be the same on the build server. Here is the test failure (this is from a variation where I tried to force an ordinal comparison):

Expected invocation on the mock at least once, but was never
performed: es => es.SendAsHtml(.accountEmail, .fromEmail, .subject,
It.Is(s => s.Equals(.expectedEmailString,
StringComparison.Ordinal))) No setups configured.

Performed invocations: IEmailService.SendAsHtml(“user@test.com”,
“sender@email.net”, “asdfasdf”, “long html string”)

Here are what I think are the relevant setups (all injected directly to the controller under test):

    var getPersonalAccount = new Mock<IGetPersonalAccount>(MockBehavior.Strict);
    getPersonalAccount.Setup(gpa => gpa.WithAccountId(userAccountId).Execute()).Returns(account);

    var emailService = new Mock<IEmailService>();

    var trialSettings = new Mock<TrialSettings>(MockBehavior.Strict);
    trialSettings.Setup(ts => ts.Length).Returns(trialLength);
    trialSettings.Setup(ts => ts.FromEmail).Returns(fromEmail);
    trialSettings.Setup(ts => ts.Subject).Returns(subject);

Subject and from address are returned by trial settings, and the to email address is taken off the account. The message body is formatted with a values from the account as well.

Relevant bits:

  • TeamCity 7.1 (build 23907) – tried both nunit 2.5.10 and 2.6 test
    runners
  • .NET 4
  • NUnit 2.5.10.11092
  • Moq 4.0.10827.0
  • 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-06-11T17:44:05+00:00Added an answer on June 11, 2026 at 5:44 pm

    So, I ended up just removing the “whole string” check on the giant HTML string and checking only to confirm that the values we are injecting into the string (via string.format) are there. This passes both locally and on the server. It’s not ideal, but I guess its not the worst thing in the world either.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
i got an object with contents of html markup in it, for example: string
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string

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.