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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:54:58+00:00 2026-05-18T01:54:58+00:00

I have not been doing TDD and Unit Tests for 7 months now and

  • 0

I have not been doing TDD and Unit Tests for 7 months now and I kind of forgot. I am now in shop that wants to start doing it but I am the only one there
and not exactly a guru in the matter.

I am a bit rusty and I am getting all sorts of questions and many times I cannot give a proper answer.

Typical questions I get:

  • I dont see anything wrong with
    integration Testing? I told them is
    slow ,you should never do it.

    If I
    cannot test privateMethod (I know
    MSTest does) what is the point in
    testing? All my important methods are
    private.

    I dont see the point of setting up an
    expectation and return a result that
    pleases the test?

    What are the typical unit tests you
    should perform in each layer? Should
    you test only at boundary levels?

    How
    do I test my Stored Procedure return
    the intended results?

Do you think the below tests make any sense to you?What kind of test would you generally do at each layer?Any examples with code?

I do 3 kinds of tests

1)ViewModel Tests.

2)Wcf Tests by mocking the service

3)Wcf Integratontest but mocking the Dal

Is this what you do?.Can you correct me if yoou thing this is wrong.Can you improve them?

ViewModel tests
property has changed
and methods have been called example below

      //property has changed
      [TestMethod]
      public void Should_be_able_to_test_that_customer_description_propertyChanged_was_raised()
      {
         //act
         var customerResponse=new CustomerResponse{Description = "Test"};
         var customerViewModel = new CustomerViewModel(customerResponse);
         var eventWasRaised = false;

         customerViewModel.PropertyChanged += (sender, e) => eventWasRaised = e.PropertyName == "Description";
         customerViewModel.Description = "DescriptionTest";


         Assert.IsTrue(eventWasRaised, "PropertyChanged event was not raised correctly.");
      }

        //Testing a method on the view model has been called
        [Test]
        public void Should_be_able_to_test_that_insert_method_on_view_Model_has_been_executed()
        {
            var mock = new Mock<IRepository>();
            var employeeVm = new EmployeeVM(mock.Object) {Age = 19};
            employeeVm.SaveCommand.Execute(null);
            mock.Verify(e=>e.Insert(It.IsAny<Employee>()));
        }

WCF Unit Tests

// Test 1 mocking the service

      [TestMethod]
      public void Should_be_able_to_verify_getCustomer_has_been_called)
      {
         var mockService = new Mock<ICustomer>();
         var expectedCustomer=new Customer{Id=1,Name="Jo"};
         mockService.Setup(x => x.GetCustomer(It.IsAny<int>())).Returns(expectedCustomer);

         var customerViewModel = new customerViewModel(mockService.Object);
         customerViewModel.GetCustomer.Execute(null);

         mockService.Verify(x=>x.GetCustomer(),Times.AtLeastOnce());
      }

      //Test 2 mocking the repository
      [TestMethod]
      public void Should_be_able_to_verify_getCustomer_has_been_called_on_the_service)
      {
         var mockRepository = new Mock<IRepositoryCustomer>();
         var expectedCustomer=new Customer{Id=1,Name="Jo"};
         mockRepository.Setup(x => x.GetCustomer(It.IsAny<int>())).Returns(expectedCustomer);

         var customerService = new CustomerService(mock.Object);
         customerService.GetCustomer(1);

         mockRepository.Verify(x=>x.GetCustomer(),Times.AtLeastOnce());
      }
  • 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-18T01:54:58+00:00Added an answer on May 18, 2026 at 1:54 am

    Ok let’s see if I can answer

    I dont see anything wrong with integration Testing? I told them is
    

    slow ,you should never do it.

    Integration tests is an overloaded term now.
    When you’re writing unit tests, you want to substitute fakes/mocks for timeconsuming/unpredictable/expensive real collaborators so that you can focus on your own code (and assume that the real collabs satisfy an assumed contract). This can help you run your unit tests in a fraction of the time leading to faster feedback and progress. Also a test failure now indicates an error in your code.. the converse being any error in any dependency can cause your test to fail

    You also need other (slow) tests that verify if the real collabs (e.g. the DAL) behave as per the contract. (I tend to call these integration tests now)

    If I cannot test privateMethod (I know MSTest does) what is the point in
    testing? All my important methods are
    private.

    Private methods should be tested via the public interface which exercises them. Write tests for the public methods which call the private methods.. If this cannot be done, maybe the private methods or parts of it are redundant.

    I dont see the point of setting up an
    expectation and return a result that
    pleases the test?

    See answer#1- you’re assuming that the real dependencies will behave as per an agreed contract. This allows you to focus on the code you’re writing using the dependencies.

    What are the typical unit tests you
    should perform in each layer? Should
    you test only at boundary levels?

    Unit tests should test objects, Acceptance tests verify that all the objects work together when plugged into each other

    How do I test my Stored Procedure return the intended results?

    Write a test that exercises the DAL against a known reference database and verify the expected results. This should be tagged as a slow integration test (as per my chosen definition).

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

Sidebar

Related Questions

I've not used C++ very much in the past, and have recently been doing
I have not used Windows Vista. I knew that many APIs have been changed/deprecated
I only want a list of files that have been added (not ones that
I have been doing some searching for a regex that can be used as
I have not been able to find a way to cancel/terminate asynchronous read operation
I am trying to use the following code, which I have not been able
There have been some questions about whether or not JavaScript is an object-oriented language.
I have been told and I'm not sure I believe this: Removing white space
I have been getting an error in VB .Net object reference not set to
I have been maintaining an installation for a while but I am not really

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.