Example #1
0
 public void WhenTheCollectionIsNullMustThrowError()
 {
     //
     // Act
     //
     summary.CalculateFileSummary <LP_data>(-1, null, data => data.DataValue);
 }
Example #2
0
        static void Main(string[] args)
        {
            try
            {
                var             directoryLocation = ConfigurationManager.AppSettings.Get("DirectoryPath");
                List <FileData> filesData         = new FileLoader().GetFilesData(directoryLocation).Result.ToList();

                ObjectCreater objCre  = new ObjectCreater();
                Summary       summObj = new Summary();
                List <File_Info <LP_data> >  LPFileInfo  = new List <File_Info <LP_data> >();
                List <File_Info <TOU_data> > TOUFileInfo = new List <File_Info <TOU_data> >();


                foreach (var filedata in filesData)
                {
                    if (filedata.Type == "LP")
                    {
                        File_Info <LP_data> tempFileInfo = new File_Info <LP_data>();
                        tempFileInfo.Type     = filedata.Type;
                        tempFileInfo.FileName = filedata.FileName;
                        objCre.GetdataObjects <LP_data>(filedata.Data.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList(), tempFileInfo).Wait();
                        tempFileInfo.summary = summObj.CalculateFileSummary <LP_data>(20, tempFileInfo.FileDataLP, (x) => x.DataValue);
                        LPFileInfo.Add(tempFileInfo);
                    }
                    else
                    {
                        File_Info <TOU_data> tempFileInfo = new File_Info <TOU_data>();
                        tempFileInfo.Type     = filedata.Type;
                        tempFileInfo.FileName = filedata.FileName;
                        objCre.GetdataObjects <TOU_data>(filedata.Data.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList(), tempFileInfo).Wait();
                        tempFileInfo.summary = summObj.CalculateFileSummary <TOU_data>(20, tempFileInfo.FileDataTOU, (x) => x.Energy);;
                        TOUFileInfo.Add(tempFileInfo);
                    }
                }

                DisplayInformation(LPFileInfo, TOUFileInfo);

                System.Console.ReadLine();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Application Error Happened : " + ex.Message);
                if (ex.InnerException != null && string.IsNullOrWhiteSpace(ex.InnerException.Message))
                {
                    System.Console.WriteLine("Inner Exception : " + ex.InnerException.Message);
                }
                System.Console.Read();
            }
        }
Example #3
0
        public void WhenTheGivenPercentageIsNegativeMustThrowError()
        {
            //
            // Arrange
            //
            Summary summary = new Summary();
            var     lpData  = new List <LP_data>
            {
                new LP_data {
                    DataValue = 10
                },
                new LP_data {
                    DataValue = 20
                },
                new LP_data {
                    DataValue = 30
                },
            };

            //
            // Act
            //
            summary.CalculateFileSummary(-1, lpData.AsReadOnly(), data => data.DataValue);
        }