public void TestPersonSearch() { PersonController personController = new PersonController(mockPersonService.Object); SearchParameters searchParameters = new SearchParameters(); searchParameters.NumberRecordsPerPage = pageSize; searchParameters.PageNumber = pageIndex; searchParameters.SortColumn = "PersonID"; searchParameters.SortDirection = "ASC"; searchParameters.SearchCriteria = new Dictionary<string, string>(); ActionResult result = personController.Search(searchParameters); // Verify that the result is of type PartialViewResult Assert.IsInstanceOf<PartialViewResult>(result); var partialViewResult = result as PartialViewResult; // Verify that the model of the result is PageOfList<PersonDocument> Assert.IsInstanceOf<PageOfList<PersonDocument>>(partialViewResult.Model); var personPage = partialViewResult.Model as PageOfList<PersonDocument>; // Verify that the same number of object provided by the service search method are returned by the controller Assert.AreEqual(personPage.Data.Count, 10); }
public void TestPersonSave() { PersonController personController = new PersonController(mockFootlooseFSService.Object); FormCollection formCollection = new FormCollection(); formCollection.Add("personID", "1"); formCollection.Add("firstName", "Pam"); formCollection.Add("lastName", "Scicchitano"); formCollection.Add("emailAddress", "*****@*****.**"); formCollection.Add("homePhone", "336-418-5000"); formCollection.Add("workPhone", "336-418-4000"); formCollection.Add("cellPhone", "336-418-3000"); formCollection.Add("homeAddressID", "1"); formCollection.Add("homeStreetAddress", "38 S Dunworth St #4185"); formCollection.Add("homeCity", "Raleigh"); formCollection.Add("homeState", "NC"); formCollection.Add("homeZip", "27215"); formCollection.Add("workAddressID", "2"); formCollection.Add("workStreetAddress", "38 S Dunworth St #4185"); formCollection.Add("workCity", "Raleigh"); formCollection.Add("workState", "NC"); formCollection.Add("workZip", "27215"); formCollection.Add("altAddressID", "1"); formCollection.Add("altStreetAddress", "38 S Dunworth St #4185"); formCollection.Add("altCity", "Raleigh"); formCollection.Add("altState", "NC"); formCollection.Add("altZip", "27215"); ActionResult result = personController.Save(formCollection); // Verify that the result is of type JsonResult Assert.IsInstanceOfType(result, typeof(JsonResult)); var jsonResult = result as JsonResult; // Verify that the model of the result is SavePersonResult Assert.IsInstanceOfType(jsonResult.Data, typeof(SavePersonResult)); var savePersonResult = jsonResult.Data as SavePersonResult; // Verify that Person object returned from the OperationStatus has the data provided from the form Assert.AreEqual(savePersonResult.Person.PersonID, 1); Assert.AreEqual(savePersonResult.Person.FirstName, "Pam"); Assert.AreEqual(savePersonResult.Person.LastName, "Scicchitano"); Assert.AreEqual(savePersonResult.Person.EmailAddress, "*****@*****.**"); }
public void TestPersonSave() { PersonController personController = new PersonController(mockPersonService.Object); var person = new Person(); person.PersonID = 1; person.FirstName = "Pam"; person.LastName = "Scicchitano"; person.EmailAddress = "*****@*****.**"; ActionResult result = personController.Save(person); // Verify that the result is of type ContentResult Assert.IsInstanceOf<ContentResult>(result); }