public GetSuppliersResponse GetSuppliersByCriteria(GetSuppliersRequest request) { GetSuppliersResponse response = new GetSuppliersResponse(); SupplierBusinessComponent bc = DependencyInjectionHelper.GetSupplierBusinessComponent(); IQueryable <Supplier> suppliers = bc.GetSuppliersByCriteria(request.SearchType, request.Name); response.Suppliers = SupplierAdapter.SuppliersToDtos(suppliers); return(response); }
public void TestGetSupplierByCriteria() { SupplierBusinessComponent service = new SupplierBusinessComponent(this.context); Supplier supplier = new Supplier() { SupplierId = 456, Name = "FakeSupplier" }; IList <Supplier> suppliers = new List <Supplier>(); suppliers.Add(supplier); foreach (SupplierSearchType type in Enum.GetValues(typeof(SupplierSearchType))) { Expect.Once.On(context).Method("GetAll").Will(Return.Value(suppliers.AsQueryable())); IQueryable <Supplier> resultSuppliers = service.GetSuppliersByCriteria(type, "FakeSupplier"); Assert.AreEqual <decimal>(1, resultSuppliers.Count()); Assert.AreEqual <decimal>(supplier.SupplierId, resultSuppliers.First().SupplierId); } mockBuilder.VerifyAllExpectationsHaveBeenMet(); }