public void TestServiceTaxCalculation()
        {
            //In real world applications moq is used.
            var taxSummary=new TaxSummary();

            var testOutput=new TaxModel[2];
            testOutput[0]=new TaxModel
            {
                DateTime = Convert.ToDateTime(null),
                Invoice = 13000,
                ServiceTax = 0,
                EducationalCess = 0,
                ForeignRemittanceTax = 0
            };
            testOutput[1]=new TaxModel
            {
                DateTime = Convert.ToDateTime(null),
                Invoice = 1500,
                ServiceTax = 0,
                EducationalCess = 0,
                ForeignRemittanceTax = 0
            };

            var educationCess = new EducationCess();

            var result=educationCess.RetrieveResults(testOutput);

            foreach (var taxModel in result)
            {
                Assert.AreEqual(taxModel.ServiceTax,testOutput[0].ServiceTax,"The values are null");
            }
        }
        internal TaxModel[] RetrieveResults(TaxModel[] file,TaxModel[] taxModels)
        {
            TaxModel[] international=file
                            .Select(
                                l =>
                                    new TaxModel()
                                    {
                                        DateTime = l.DateTime,
                                        Invoice = (l.Invoice),
                                        EmpId = null,
                                        Id = (int) 0,
                                        ServiceTax = (int) 0,
                                        EducationalCess = (int) 0,
                                        ForeignRemittanceTax = (l.Invoice*0.05)
                                    })
                            .ToArray();
                TaxModel[] domestic = taxModels.Select(
                        l =>
                            new TaxModel()
                            {
                                DateTime = l.DateTime,
                                Invoice = l.Invoice,
                                EducationalCess = l.EducationalCess,
                                EmpId = l.EmpId,
                                ForeignRemittanceTax = l.ForeignRemittanceTax,
                                Id = l.Id,
                                ServiceTax = l.ServiceTax
                            }).ToArray();

                TaxModel[] result = international.Concat(domestic).ToArray();
                OutputModel[] displayResult =
                    result.GroupBy(g => new {g.DateTime})
                        .Select(
                            group =>
                                new OutputModel()
                                {
                                    datetime = group.Key.DateTime,
                                    invoice = group.Sum(i => i.Invoice),
                                    serviceTax = Math.Ceiling(group.Sum(s => s.ServiceTax)),
                                    educationalCess = Math.Ceiling(group.Sum(e => e.EducationalCess)),
                                    foreignRemittanceCess = Math.Ceiling(group.Sum(frt => frt.ForeignRemittanceTax))
                                })
                        .ToArray();
                return taxSummary.SumArrays(displayResult);
        }
Ejemplo n.º 3
0
 public TaxModel[] RetrieveResults(TaxModel[] file)
 {
     return educationCess
         .RetrieveResults(file.Select(l=>new TaxModel(){DateTime = l.DateTime,Invoice = (l.Invoice),EmpId = null,Id = (int)0,ServiceTax = (l.Invoice*0.1),EducationalCess = (int)0,ForeignRemittanceTax = (int)0})
         .ToArray());
 }