You've got three Asserts in that test. Which one is failing?
---
Patrick Steele
http://weblogs.asp.net/psteele
On Tue, Oct 2, 2012 at 11:24 AM, D M <
dorin....@gmail.com> wrote:
> I am trying to test an action method if returns expected values.
>
> here is my Action method & test code:
>
> [HttpPost]
> public JsonResult FindCustomer(SearchCriteria searchParams)
> {
> .....
>
> matchingCustomers = _databaseSearch.Find<SearchCriteria ,
> List<CompanyMatchItem>>(searchParams));
> matchingCustomers.AddRange(_webSearch.Find<SearchCriteria ,
> List<CompanyMatchItem>>(searchParams)));
>
> return Json(matchingCustomers);
> }
>
> [Test]
> public void
> test_credit_application_controller_FindCustomer_success()
> {
> var searchParams = new SearchCriteria();
> var companyMatchItems = new List<CompanyMatchItem>();
>
> var databaseSearch =
> MockRepository.GenerateMock<IDatabaseCompanySearch>();
> var webCompanySearch =
> MockRepository.GenerateMock<IWebCompanySearch>();
>
> databaseSearch.Expect(x => x.Find<SearchCriteria,
> List<CompanyMatchItem>>(searchParams)).Return(companyMatchItems).Repeat.AtLeastOnce();
> webCompanySearch.Expect(x => x.Find<SearchCriteria,
> List<CompanyMatchItem>>(searchParams)).Return(companyMatchItems).Repeat.AtLeastOnce();
>
> var myController = new MyController(databaseSearch, webSearch);
>
> var foundCustomers = myController.FindCustomer(searchParams);
>
> Assert.That(foundCustomers, Is.TypeOf<JsonResult>());
> Assert.That(foundCustomers, Is.Not.Null);
>
> var jsonResult = new JsonResult { Data = companyMatchItems };
>
> Assert.AreEqual(jsonResult.Data, foundCustomers.Data);
> }
>
>
>
> but the test fails with : Expected: <empty>
> But was: null
>
>
> I am not quite sure if it is correct to test for returned results?
>
> can anyone advise on this please?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Rhino.Mocks" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/rhinomocks/-/6lkNm6Jk5tsJ.
> To post to this group, send email to
rhino...@googlegroups.com.
> To unsubscribe from this group, send email to
>
rhinomocks+...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/rhinomocks?hl=en.