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 6786547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:15:30+00:00 2026-05-26T17:15:30+00:00

So I have a view model that takes an instance of IAdapter right? And

  • 0

So I have a view model that takes an instance of IAdapter right? And when I set a property in the view model I call some method in that IAdapter. This I can easily moq & test and I do. Here is the test method.

 [TestMethod]
public void Setting_ExchangePrice_Calls_UpdateExcahngeCosts()
{
  var currentItem = new InventoryItem();
  bool adapterUpdateExchangeCostsWasCalled = false;
  adapterMock.Setup(x => x.CurrentItem).Returns(currentItem);
  adapterMock.Setup(x => x.UpdateExchangeCosts()).Callback(() => adapterUpdateExchangeCostsWasCalled = true);
  vm.Adapter = adapterMock.Object;
  vm.ExchangePrice = 4;
  Assert.IsTrue(adapterUpdateExchangeCostsWasCalled);
}

Here is the problem, UpdateExchangeCosts() needs to call UpdateExchangePrices() – They will both live in the concrete instance of the adapter so there isn’t any reason to make it public which means there isn’t any reason to define it in the interface cause we don’t define private methods in interfaces. Sooooo….. I am stuck as to how I test to make sure calling UpdateExchangeCosts() also calls UpdateExchangePrices? I could imagine a state based test but in a lot of cases the UpdateExchangePrices won’t update anything (for various reasons) so there wont be any changed state to test.

Thank you and have a lovely day!

  • 1 1 Answer
  • 2 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-26T17:15:31+00:00Added an answer on May 26, 2026 at 5:15 pm

    If UpdateExchangeCosts needs to call UpdateExchangePrices, you should test that as you test the specific Adapter classes. When testing whatever vm is, it doesn’t need to care (and shouldn’t care) about what its given Adapter does.

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

Sidebar

Related Questions

I have a view model that looks like this public class ViewModelRound2 { public
I have a model that gets it's view-count updated after it's viewed. This is
I have a view model that contains a Product class type and an IEnumerable<
I have a view model that is displayed in a view that uses uploadify.
I am using javascript unobtrusive validation. I have a view model that I am
I have a view with a model that has several fields. When I render
I have a view model with a couple of properties that are not displaying
if i have created a view model and have a partial form that is
I have three models that are coming together to create one view model and
I have a Java project that I'm trying to implement with a model-view-controller design.

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.