public void UnitTest_GetAll_Returns_ListOfProperties() { var dummyData = new List <usp_GetAllProperties_Result> { new usp_GetAllProperties_Result() { PropertyID = 1, Location = "111 street", Bedroom = 3, Bathroom = 2, ConfidentialNotes = null, Status = 1 }, new usp_GetAllProperties_Result() { PropertyID = 2, Location = "222 street", Bedroom = 3, Bathroom = 1, ConfidentialNotes = null, Status = 2 }, new usp_GetAllProperties_Result() { PropertyID = 3, Location = "333 street", Bedroom = 5, Bathroom = 3, ConfidentialNotes = null, Status = 4 } }; var mockedObjectResult = new Mock <ObjectResult <usp_GetAllProperties_Result> >(); mockedObjectResult.Setup(x => x.GetEnumerator()).Returns(dummyData.GetEnumerator()); mockUnitOfWork.Setup(x => x.GetDB().usp_GetAllProperties()).Returns(mockedObjectResult.Object); PropertyProvider provider = new PropertyProvider(mockUnitOfWork.Object); var result = provider.GetAll(); Assert.AreEqual(3, result.Count()); }
public ActionResult Search(string term) { PropertyProvider propertyProvider = new PropertyProvider(_dbContext); var allProperties = propertyProvider.GetAll(); var data1 = allProperties.Where(x => x.AirBnBHomeName.Contains(term)).Select(x => new { label = x.AirBnBHomeName + "," + x.PropertyCode + "," + x.Address, value = x.AirBnBHomeName, Bedrooms = x.Bedrooms, Account = x.Account, CleaningFee = x.CleaningFees, RevTeam2xApproval = x.RevTeam2xApproval, NeedsownerApproval = x.NeedsOwnerApproval, BookingGuidelines = x.BookingGuidelines, AirBnBHomeName = x.AirBnBHomeName, PropertyCode = x.PropertyCode, NeedsOwnerApproval = x.NeedsOwnerApproval }).ToList(); var data2 = allProperties.Where(x => x.PropertyCode.Contains(term)).Select(x => new { label = x.AirBnBHomeName + "," + x.PropertyCode + "," + x.Address, value = x.AirBnBHomeName, Bedrooms = x.Bedrooms, Account = x.Account, CleaningFee = x.CleaningFees, RevTeam2xApproval = x.RevTeam2xApproval, NeedsownerApproval = x.NeedsOwnerApproval, BookingGuidelines = x.BookingGuidelines, AirBnBHomeName = x.AirBnBHomeName, PropertyCode = x.PropertyCode, NeedsOwnerApproval = x.NeedsOwnerApproval }).ToList(); var data3 = allProperties.Where(x => x.Owner.Contains(term)).Select(x => new { label = x.AirBnBHomeName + "," + x.PropertyCode + "," + x.Address, value = x.AirBnBHomeName, Bedrooms = x.Bedrooms, Account = x.Account, CleaningFee = x.CleaningFees, RevTeam2xApproval = x.RevTeam2xApproval, NeedsownerApproval = x.NeedsOwnerApproval, BookingGuidelines = x.BookingGuidelines, AirBnBHomeName = x.AirBnBHomeName, PropertyCode = x.PropertyCode, NeedsOwnerApproval = x.NeedsOwnerApproval }).ToList(); var result = data1; result.AddRange(data2); result.AddRange(data3); return(Json(result, JsonRequestBehavior.AllowGet)); }