Ejemplo n.º 1
0
        public void FileSizeSumTestKb()
        {
            var a1 = new FileSize((decimal)2.8, Prefix.Kb);
            var a2 = new FileSize((decimal)3.21, Prefix.Kb);

            var result = new FileSize((decimal)6.01, Prefix.Kb);

            (a1 + a2).Should().Be(result);
        }
Ejemplo n.º 2
0
        public void FileSizeSumTestManyGBs()
        {
            var list = new List<FileSize>();

            Enumerable.Range(1, 1024 * 1024 * 10).ToList().ForEach(it => list.Add(new FileSize(1, Prefix.Mb)));

            var result = new FileSize(10, Prefix.Tb);

            list.Sum().Should().Be(result);
        }
Ejemplo n.º 3
0
 protected bool Equals(FileSize other)
 {
     return _internalRepresentation == other._internalRepresentation;
 }
Ejemplo n.º 4
0
        public static FileSize operator +(FileSize left, FileSize right)
        {
            var newValue = left.InternalRepresentation + right.InternalRepresentation;

            var newFileSize = new FileSize(newValue);

            return newFileSize;
        }
Ejemplo n.º 5
0
        private async Task LoadTorrentQueryModels()
        {
            var result = (await TorrentsQuery.GetTorrentQueryModelsAsync());
            
            Torrents = new BindingList<TorrentQueryModel>(result);

            var totalFileSize = new FileSize();
            
            Torrents.ForEach(it => { totalFileSize += it.FileSize; });

            TotalSize = totalFileSize.RawValue;
        }
Ejemplo n.º 6
0
        public static FileSize Sum(this IEnumerable<FileSize> fileSizes)
        {
            var result = new FileSize();

            return fileSizes.Aggregate(result, (current, fileSize) => current + fileSize);
        }