Assert.AreEqual(jsonResult.Data, foundCustomers.Data); this one @_ On Tuesday, October 2, 2012 5:00:16 PM UTC+1, Patrick Steele wrote: > > 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 <[email protected] <javascript:>> > 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 > > [email protected]<javascript:>. > > > To unsubscribe from this group, send email to > > [email protected] <javascript:>. > > For more options, visit this group at > > http://groups.google.com/group/rhinomocks?hl=en. >
-- 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/-/oPOQVKGGeUMJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
