Beispiel #1
0
        public SalesData ExecuteConversion(string obj)
        {
            string[] data      = obj.Split("\u00E7");
            var      itensList = data[2]
                                 .Replace("[", string.Empty)
                                 .Replace("]", string.Empty)
                                 .Split(",").ToList();

            var sales = new SalesData(lineType: (ELineType)EnumeratorHelper.GetValueFromDescription <ELineType>(data[0]),
                                      saleId: data[1], salesmanName: data[3]);

            itensList.ForEach(delegate(string item){
                var itemArray = item.Split("-");

                var saleItens = new SalesItemData(itemId: int.Parse(itemArray[0]),
                                                  itemQuantity: int.Parse(itemArray[1]),
                                                  itemPrice: decimal.Parse(itemArray[2].Replace(".", ",")));

                sales.AddItens(saleItens);
            });

            AddNotifications(sales);

            return(sales);
        }
Beispiel #2
0
        public void ReturnErrorWhenSalesmanNameIsEmpty()
        {
            SalesData client = new SalesData(lineType: (ELineType)EnumeratorHelper.GetValueFromDescription <ELineType>("003"),
                                             saleId: "03",
                                             salesmanName: "");

            Assert.IsTrue(client.Notifications.Count == 1);
            Assert.IsTrue(client.Notifications.Count(c => c.Property.Equals("SalesData.SalesmanName") && c.Message.Equals("Informacao nao definida")) == 1);
        }
        public void ReturnErrorWhenBusinessAreaIsEmpty()
        {
            Client client = new Client(lineType: (ELineType)EnumeratorHelper.GetValueFromDescription <ELineType>("002"),
                                       cNPJ: "",
                                       name: "Jose Alencar",
                                       businessArea: "administrativo");

            Assert.IsTrue(client.Notifications.Count == 1);
            Assert.IsTrue(client.Notifications.Count(c => c.Property.Equals("Client.BusinessArea") && c.Message.Equals("Informacao nao definida")) == 1);
        }
        public void ReturnErrorWhenCNPJInvalid()
        {
            Client client = new Client(lineType: (ELineType)EnumeratorHelper.GetValueFromDescription <ELineType>("002"),
                                       cNPJ: "122355678",
                                       name: "Jose Alencar",
                                       businessArea: "administrativo");

            Assert.IsTrue(client.Notifications.Count == 1);
            Assert.IsTrue(client.Notifications.Count(c => c.Property.Equals("Client.CNPJ") && c.Message.Equals("Documento invalido")) > 0);
        }
        public void ReturnErrorWhenNameIsEmpty()
        {
            Client client = new Client(lineType: (ELineType)EnumeratorHelper.GetValueFromDescription <ELineType>("002"),
                                       cNPJ: "94631205000119",
                                       name: "",
                                       businessArea: "administrativo");

            Assert.IsTrue(client.Notifications.Count == 1);
            Assert.IsTrue(client.Notifications.Count(c => c.Property.Equals("Client.Name")) == 1);
        }
        public Client ExecuteConversion(string obj)
        {
            string[] data = obj.Split("\u00E7");

            var client = new Client(lineType: (ELineType)EnumeratorHelper.GetValueFromDescription <ELineType>(data[0]),
                                    cNPJ: data[1],
                                    name: data[2],
                                    businessArea: data[3]);

            AddNotifications(client);

            return(client);
        }
Beispiel #7
0
        public Salesman ExecuteConversion(string obj)
        {
            string[] data = obj.Split("\u00E7");

            var salesMan = new Salesman(lineType: (ELineType)EnumeratorHelper.GetValueFromDescription <ELineType>(data[0]),
                                        cPF: data[1],
                                        name: data[2],
                                        salary: decimal.Parse(data[3].Replace(".", ",")));

            AddNotifications(salesMan);

            return(salesMan);
        }
Beispiel #8
0
            public bool MoveNext()
            {
                bool flag;

                EnumeratorHelper.CheckVersion(this.ver, this.multimap.version);
                EnumeratorHelper.EnumeratorState state = this.state;
                if (state == EnumeratorHelper.EnumeratorState.Before)
                {
                    this.keyEnumerator = this.multimap.data.Keys.GetEnumerator();
                    flag = this.keyEnumerator.MoveNext();
                    if (!flag)
                    {
                        this.state = EnumeratorHelper.EnumeratorState.After;
                    }
                    else
                    {
                        this.valueEnumerator = this.multimap.data[this.keyEnumerator.Current].GetEnumerator();
                        this.valueEnumerator.MoveNext();
                        this.state = EnumeratorHelper.EnumeratorState.Current;
                    }
                    return(flag);
                }
                if (state == EnumeratorHelper.EnumeratorState.After)
                {
                    return(false);
                }
                flag = this.valueEnumerator.MoveNext();
                if (!flag)
                {
                    flag = this.keyEnumerator.MoveNext();
                    if (flag)
                    {
                        this.valueEnumerator = this.multimap.data[this.keyEnumerator.Current].GetEnumerator();
                        this.valueEnumerator.MoveNext();
                    }
                }
                if (!flag)
                {
                    this.state = EnumeratorHelper.EnumeratorState.After;
                }
                return(flag);
            }
Beispiel #9
0
        public void DepthFirstEnumeratorsAreLazyAndDisposeProperly()
        {
            var helper = new EnumeratorHelper();

            var sequence = Traverse.DepthFirst(10, i => helper.MakeEnumerator(i - 1));

            helper.IterateCount.ShouldEqual(0);
            helper.StartCount.ShouldEqual(0);
            helper.EndCount.ShouldEqual(0);

            using (var enumerator = sequence.GetEnumerator())
            {
                for (var i = 0; i < 10; ++i)
                {
                    enumerator.MoveNext().ShouldEqual(true);
                }
                helper.IterateCount.ShouldEqual(9); // -1 for root
            }

            helper.StartCount.ShouldEqual(helper.EndCount);
        }
Beispiel #10
0
        public void BreadthFirstEnumeratorsAreLazyAndDisposeProperly()
        {
            var helper = new EnumeratorHelper();

            var sequence = Traverse.BreadthFirst(10, i => helper.MakeEnumerator(i - 1));

            Assert.AreEqual(0, helper.IterateCount);
            Assert.AreEqual(0, helper.StartCount);
            Assert.AreEqual(0, helper.EndCount);

            using (var enumerator = sequence.GetEnumerator())
            {
                for (var i = 0; i < 10; ++i)
                {
                    Assert.IsTrue(enumerator.MoveNext());
                }
                Assert.AreEqual(9, helper.IterateCount); // -1 for root
            }

            Assert.AreEqual(helper.EndCount, helper.StartCount);
        }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(EnumeratorHelper.GetAll(value.GetType()));
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            IEnumerable <KeyValuePair <Enum, string> > collection = EnumeratorHelper.GetAll(value.GetType());

            return(collection.Reverse <KeyValuePair <Enum, string> >());
        }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(EnumeratorHelper.GetDescription((Options.VideoQualities)value));
 }