public void CustomerFullTextNonEmptyTextReturnAndSpecification()
        {
            //Arrange
            ISpecification <Customer> spec = null;

            //Act
            spec = CustomerSpecifications.CustomerFullText("Unai");

            //Assert
            Assert.NotNull(spec);
            Assert.IsType <AndSpecification <Customer> >(spec);
        }
Example #2
0
        public void CustomerEnabledCustomersSpecificationReturnDirectSpecification()
        {
            //Arrange
            ISpecification <Customer> spec = null;

            //Act
            spec = CustomerSpecifications.EnabledCustomers();

            //Assert
            Assert.NotNull(spec);
            Assert.IsType <DirectSpecification <Customer> >(spec);
        }
        public void CustomerFullTextNullTextReturnDirectSpecification()
        {
            //Arrange
            ISpecification <Customer> spec = null;

            //Act
            spec = CustomerSpecifications.CustomerFullText(null);

            //Assert
            Assert.NotNull(spec);
            Assert.IsType <DirectSpecification <Customer> >(spec);
        }
Example #4
0
        public void CustomerEnabledCustomersSpecificationReturnDirectSpecification()
        {
            //Arrange
            ISpecification <Customer> spec = null;

            //Act
            spec = CustomerSpecifications.EnabledCustomers();

            //Assert
            Assert.IsNotNull(spec);
            Assert.IsInstanceOfType(spec, typeof(DirectSpecification <Customer>));
        }
Example #5
0
        public void CustomerFullTextNonEmptyTextReturnAndSpecification()
        {
            //Arrange
            ISpecification <Customer> spec = null;

            //Act
            spec = CustomerSpecifications.CustomerFullText("Unai");

            //Assert
            Assert.IsNotNull(spec);
            Assert.IsInstanceOfType(spec, typeof(AndSpecification <Customer>));
        }
Example #6
0
        public void CustomerFullTextNullTextReturnDirectSpecification()
        {
            //Arrange
            ISpecification <Customer> spec = null;

            //Act
            spec = CustomerSpecifications.CustomerFullText(null);

            //Assert
            Assert.IsNotNull(spec);
            Assert.IsInstanceOfType(spec, typeof(DirectSpecification <Customer>));
        }
Example #7
0
        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));
        }
Example #8
0
        public CustomerIsValidToImportValidator(
            DomainModelValidatorBaseSpecifications <Customer> domainModelValidatorBaseSpecifications,
            CustomerSpecifications customerSpecifications
            )
            : base(domainModelValidatorBaseSpecifications)
        {
            AddSpecification(domainModelValidatorBaseSpecifications.DomainModelMustHaveIdSpecification);
            AddSpecificationsForTenantInfo();
            AddSpecificationsForCreationInfo();
            AddSpecificationsForActivationInfo();

            AddSpecification(customerSpecifications.CustomerMustHaveCodeSpecification);
            AddSpecification(customerSpecifications.CustomerMustHaveCodeWithValidLengthSpecification);
            AddSpecification(customerSpecifications.CustomerMustHaveNameSpecification);
            AddSpecification(customerSpecifications.CustomerMustHaveNameWithValidLengthSpecification);
            AddSpecification(customerSpecifications.CustomerMustHaveBirthDateSpecification);
            AddSpecification(customerSpecifications.CustomerMustHaveLegalAgeSpecification);
            AddSpecification(customerSpecifications.CustomerMustHaveUniqueCodeSpecification, validationResultType: ValidationResultTypeEnum.Warning);
        }
Example #9
0
        /// <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);
            }
        }