コード例 #1
0
ファイル: DailyReportParser.cs プロジェクト: tparvi/tomato
        private static DailyBandwidth CreateDailyBandwidth(string rawValue, string page)
        {
            var values = rawValue.Split(',').ToList();

            if (3 != values.Count)
            {
                var msg = "Cannot parse daily bandwidth from <{0}> because it does not contain exactly three elements separated by comma."
                    .FormatWith(rawValue);
                throw new ParseException(msg, page);
            }

            try
            {
                var date = ParserHelper.DailyTimestampToDate(values[0]);

                var download = ParserHelper.ToKilobytes(values[1]);
                var upload = ParserHelper.ToKilobytes(values[2]);

                var daily = new DailyBandwidth(date.Year, date.Month, date.Day, download, upload);
                return daily;
            }
            catch (Exception exp)
            {
                throw new ParseException("Failed to parse single daily bandwidth information", page, rawValue, exp);
            }
        }
コード例 #2
0
ファイル: DailyValue.cs プロジェクト: tparvi/tomatoui
 /// <summary>
 /// Initializes a new instance of the <see cref="DailyValue"/> class.
 /// </summary>
 /// <param name="bandwidth">
 /// The daily bandwidth.
 /// </param>
 public DailyValue(DailyBandwidth bandwidth)
 {
     this.bandwidth = bandwidth;
     this.Timestamp = bandwidth.Timestamp;
     this.ChangeTransferUnit(TransferUnit.Megabytes);
 }
コード例 #3
0
ファイル: BandwidthTests.cs プロジェクト: tparvi/tomato
 public void DailyBandwidth_should_return_correct_Timestamp()
 {
     var daily = new DailyBandwidth(2011, 1, 1, 0, 0);
     var expected = new DateTime(2011, 1, 1);
     Assert.AreEqual(expected, daily.Timestamp);
 }