0
namespace MoqSample.Test
{
    [TestFixture]
    public class GivenCustomerServiceTest
    {
        private ICustomerService customerService;
        private CustomerModel customer;
        // Defining the mock object.
        private Mock<ICustomerRepository> mockCustomerRepository;

        [SetUp]
        public void SetUp()
        {
            //Creating the mock object.
            mockCustomerRepository = new Mock<ICustomerRepository>();
            customerService = new CustomerService(mockCustomerRepository.Object);
        }

        [Test]
        public void GetCustomerByIdTest()
        {
            customer = new CustomerModel { Id = 1, Name = "TEST-CUSTOMER", Address = "abc" };
            mockCustomerRepository.Setup(customerRepository => customerRepository.GetCustomerById(1)).Returns(customer);

            var customerReturned = customerService.GetCustomerById(1);

            //Verifying values.
            Assert.AreEqual(customer.Id, customerReturned.Id);
            Assert.AreEqual(customer.Name, customerReturned.Name);
            Assert.AreEqual(customer.Address, customerReturned.Address);
        }
    }
}

When I am trying to debug the code in aforementioned class , it's not hitting the break point. I.e I am unable to debug the code. Any suggestions are welcome.

nulltoken
  • 64,429
  • 20
  • 138
  • 130
Prakhar Mehta
  • 15
  • 1
  • 6
  • Sounds like a duplicate of this: http://stackoverflow.com/questions/930438/nunit-isnt-running-visual-studio-2010-code – Pedro Jan 05 '12 at 17:36

1 Answers1

1

Using the Resharper or TestDriven test runners should allow you to debug through your unit tests.

nulltoken
  • 64,429
  • 20
  • 138
  • 130