Ejemplo n.º 1
0
 public FilmSearchModel()
 {
     Name      = string.Empty;
     Duration  = new DurationFilter();
     FilmMaker = string.Empty;
     Count     = DEFAULT_FILMS_COUNT;
 }
Ejemplo n.º 2
0
        public void PassesFilter_WithValidMethodAndArgumentAndParameter_ReturnsBool(TimeSpan argument, TimeSpan toTest,
                                                                                    DurationFilter.DurationFilterMethods method, bool expected)
        {
            var filter = new DurationFilter(method, argument);
            var result = filter.PassesFilter(toTest);

            Assert.Equal(expected, result);
        }
Ejemplo n.º 3
0
        public void PassesFilter_WithDateTimeAndMethodButNullArgument_ThrowsInvalidOperationException()
        {
            var filter = new DurationFilter
            {
                Method = DurationFilter.DurationFilterMethods.Greater
            };

            Assert.Throws <InvalidOperationException>(() => filter.PassesFilter(MediumDuration));
        }
Ejemplo n.º 4
0
        public void PassesFilter_WithDateTimeAndNullMethod_ThrowsInvalidOperationException()
        {
            var filter = new DurationFilter
            {
                Argument = MediumDuration
            };

            Assert.Throws <InvalidOperationException>(() => filter.PassesFilter(ShortDuration));
        }
        internal virtual StringBuilder GetAutoPropertyFilterString()
        {
            var res = new StringBuilder();


            if (ReceivedQtyFilter.HasValue)
            {
                res.Append(" && " + string.Format("ReceivedQty == {0}", ReceivedQtyFilter.ToString()));
            }

            if (string.IsNullOrEmpty(ItemNumberFilter) == false)
            {
                res.Append(" && " + string.Format("ItemNumber.Contains(\"{0}\")", ItemNumberFilter));
            }


            if (string.IsNullOrEmpty(ItemDescriptionFilter) == false)
            {
                res.Append(" && " + string.Format("ItemDescription.Contains(\"{0}\")", ItemDescriptionFilter));
            }


            if (CostFilter.HasValue)
            {
                res.Append(" && " + string.Format("Cost == {0}", CostFilter.ToString()));
            }

            if (InvoiceQtyFilter.HasValue)
            {
                res.Append(" && " + string.Format("InvoiceQty == {0}", InvoiceQtyFilter.ToString()));
            }

            if (string.IsNullOrEmpty(InvoiceNoFilter) == false)
            {
                res.Append(" && " + string.Format("InvoiceNo.Contains(\"{0}\")", InvoiceNoFilter));
            }



            if (Convert.ToDateTime(StartInvoiceDateFilter).Date != DateTime.MinValue &&
                Convert.ToDateTime(EndInvoiceDateFilter).Date != DateTime.MinValue)
            {
                res.Append(" && (");
            }

            if (Convert.ToDateTime(StartInvoiceDateFilter).Date != DateTime.MinValue)
            {
                if (StartInvoiceDateFilter.HasValue)
                {
                    res.Append(
                        (Convert.ToDateTime(EndInvoiceDateFilter).Date != DateTime.MinValue?"":" && ") +
                        string.Format("InvoiceDate >= \"{0}\"", Convert.ToDateTime(StartInvoiceDateFilter).Date.ToString("MM/dd/yyyy")));
                }
            }

            if (Convert.ToDateTime(EndInvoiceDateFilter).Date != DateTime.MinValue)
            {
                if (EndInvoiceDateFilter.HasValue)
                {
                    res.Append(" && " + string.Format("InvoiceDate <= \"{0}\"", Convert.ToDateTime(EndInvoiceDateFilter).Date.AddHours(23).ToString("MM/dd/yyyy HH:mm:ss")));
                }
            }

            if (Convert.ToDateTime(StartInvoiceDateFilter).Date != DateTime.MinValue &&
                Convert.ToDateTime(EndInvoiceDateFilter).Date != DateTime.MinValue)
            {
                res.Append(" )");
            }

            if (Convert.ToDateTime(_invoiceDateFilter).Date != DateTime.MinValue)
            {
                if (InvoiceDateFilter.HasValue)
                {
                    res.Append(" && " + string.Format("InvoiceDate == \"{0}\"", Convert.ToDateTime(InvoiceDateFilter).Date.ToString("MM/dd/yyyy")));
                }
            }


            if (string.IsNullOrEmpty(CNumberFilter) == false)
            {
                res.Append(" && " + string.Format("CNumber.Contains(\"{0}\")", CNumberFilter));
            }


            if (string.IsNullOrEmpty(RegistrationDateFilter) == false)
            {
                res.Append(" && " + string.Format("RegistrationDate.Contains(\"{0}\")", RegistrationDateFilter));
            }


            if (DurationFilter.HasValue)
            {
                res.Append(" && " + string.Format("Duration == {0}", DurationFilter.ToString()));
            }

            if (InvoiceMonthFilter.HasValue)
            {
                res.Append(" && " + string.Format("InvoiceMonth == {0}", InvoiceMonthFilter.ToString()));
            }

            if (AsycudaMonthFilter.HasValue)
            {
                res.Append(" && " + string.Format("AsycudaMonth == {0}", AsycudaMonthFilter.ToString()));
            }

            if (AllocatedValueFilter.HasValue)
            {
                res.Append(" && " + string.Format("AllocatedValue == {0}", AllocatedValueFilter.ToString()));
            }

            if (ReceivedValueFilter.HasValue)
            {
                res.Append(" && " + string.Format("ReceivedValue == {0}", ReceivedValueFilter.ToString()));
            }

            if (InvoiceValueFilter.HasValue)
            {
                res.Append(" && " + string.Format("InvoiceValue == {0}", InvoiceValueFilter.ToString()));
            }

            if (LineNumberFilter.HasValue)
            {
                res.Append(" && " + string.Format("LineNumber == {0}", LineNumberFilter.ToString()));
            }

            if (PiQuantityFilter.HasValue)
            {
                res.Append(" && " + string.Format("PiQuantity == {0}", PiQuantityFilter.ToString()));
            }

            if (string.IsNullOrEmpty(OverShortDetailStatusFilter) == false)
            {
                res.Append(" && " + string.Format("OverShortDetailStatus.Contains(\"{0}\")", OverShortDetailStatusFilter));
            }


            if (QtyAllocatedFilter.HasValue)
            {
                res.Append(" && " + string.Format("QtyAllocated == {0}", QtyAllocatedFilter.ToString()));
            }

            if (string.IsNullOrEmpty(AllocationStatusFilter) == false)
            {
                res.Append(" && " + string.Format("AllocationStatus.Contains(\"{0}\")", AllocationStatusFilter));
            }
            return(res.ToString().StartsWith(" &&") || res.Length == 0 ? res:  res.Insert(0, " && "));
        }
Ejemplo n.º 6
0
        public void PassesFilter_WithNonDateTime_ThrowInvalidOperationException()
        {
            var filter = new DurationFilter(DurationFilter.DurationFilterMethods.Greater, MediumDuration);

            Assert.Throws <ArgumentException>(() => filter.PassesFilter(new object()));
        }
Ejemplo n.º 7
0
 public FilmSearchModel()
 {
     Name      = string.Empty;
     Duration  = new DurationFilter();
     FilmMaker = string.Empty;
 }