Ejemplo n.º 1
0
        public void OrderFromDateRangeNullEndDateReturnDirectSpecification()
        {
            //Arrange
            DateTime?start = DateTime.Now;
            DateTime?end   = null;

            //Act
            var spec = OrdersSpecifications.OrderFromDateRange(start, end);

            //Assert
            Assert.NotNull(spec);
            Assert.IsType <AndSpecification <Order> >(spec);
        }
Ejemplo n.º 2
0
        public void OrderFromDateRangeNullDatesReturnTrueSpecification()
        {
            //Arrange
            DateTime?start = null;
            DateTime?end   = null;

            //Act
            var spec = OrdersSpecifications.OrderFromDateRange(start, end);

            //Assert
            Assert.NotNull(spec);
            Assert.IsType <TrueSpecification <Order> >(spec);
        }
Ejemplo n.º 3
0
        public void OrderRepositoryAllMatchingMethodReturnEntitiesWithSatisfiedCriteria()
        {
            //Arrange
            var orderRepository = new OrderRepository(fixture.unitOfWork, fixture.orderLogger);

            var spec = OrdersSpecifications.OrderFromDateRange(DateTime.Now.AddDays(-2), DateTime.Now.AddDays(-1));

            //Act
            var result = orderRepository.AllMatching(spec);

            //Assert
            Assert.NotNull(result.All(o => o.OrderDate > DateTime.Now.AddDays(-2) && o.OrderDate < DateTime.Now.AddDays(-1)));
        }
        public void OrderFromDateRangeNullStartDateReturnDirectSpecification()
        {
            //Arrange
            DateTime?start = null;
            DateTime?end   = DateTime.Now;

            //Act
            var spec = OrdersSpecifications.OrderFromDateRange(start, end);

            //Assert
            Assert.IsNotNull(spec);
            Assert.IsInstanceOfType(spec, typeof(AndSpecification <Order>));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService" />
        /// </summary>
        /// <param name="dateFrom">
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService" />
        /// </param>
        /// <param name="dateTo">
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService" />
        /// </param>
        /// <returns>
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService" />
        /// </returns>
        public List <OrderListDto> FindOrders(DateTime?dateFrom, DateTime?dateTo)
        {
            //create the specification ( how to filter orders from dates..)
            var spec = OrdersSpecifications.OrderFromDateRange(dateFrom, dateTo);

            //recover orders
            var orders = _orderRepository.AllMatching(spec);

            if (orders != null && orders.Any())
            {
                return(orders.ProjectedAsCollection <OrderListDto>());
            }
            else //no data
            {
                return(null);
            }
        }