public void CustomerEnabledCustomersSpecificationReturnDirectSpecification() { //Arrange ISpecification <Customer> spec = null; //Act spec = CustomerSpecifications.EnabledCustomers(); //Assert Assert.NotNull(spec); Assert.IsType <DirectSpecification <Customer> >(spec); }
public void CustomerEnabledCustomersSpecificationReturnDirectSpecification() { //Arrange ISpecification <Customer> spec = null; //Act spec = CustomerSpecifications.EnabledCustomers(); //Assert Assert.IsNotNull(spec); Assert.IsInstanceOfType(spec, typeof(DirectSpecification <Customer>)); }
public void CustomerRepositoryAllMatchingMethodReturnEntitiesWithSatisfiedCriteria() { //Arrange var customerRepository = new CustomerRepository(fixture.unitOfWork, fixture.customerLogger); var spec = CustomerSpecifications.EnabledCustomers(); //Act var result = customerRepository.AllMatching(spec); //Assert Assert.NotNull(result.All(c => c.IsEnabled)); }
/// <summary> /// <see /// cref="M:Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ICustomerManagement.FindCustomers" /> /// </summary> /// <param name="text"> /// <see /// cref="M:Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ICustomerManagement.FindCustomers" /> /// </param> /// <returns> /// <see /// cref="M:Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ICustomerManagement.FindCustomers" /> /// </returns> public List <CustomerListDto> FindCustomers(string text) { //get the specification var enabledCustomers = CustomerSpecifications.EnabledCustomers(); var filter = CustomerSpecifications.CustomerFullText(text); ISpecification <Customer> spec = enabledCustomers & filter; //Query this criteria var customers = _customerRepository.AllMatching(spec); if (customers != null && customers.Any()) { //return adapted data return(customers.ProjectedAsCollection <CustomerListDto>()); } else // no data.. { return(null); } }