Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }