public void ReturnsBits() { var value = ByteSize.FromBits(10); var result = value.ToString("##.#### b"); Assert.Equal("10 b", result); }
public void FromBits() { var result = ByteSize.FromBits(8); Assert.Equal(8, result.Bits); Assert.Equal(1, result.Bytes); }
public void ReturnsZeroBits() { var value = ByteSize.FromBits(0); var result = value.ToString(); Assert.Equal("0 b", result); }
/// <summary> /// Builds an index from the files in a given folder /// </summary> /// <param name="path">The path to folder to index</param> /// <param name="batchSize">The size of a batch, after which the buffers are flushed</param> /// <param name="progress">Returns progress messages, use <seealso cref="Progress{T}" /></param> /// <returns></returns> public async Task Build(string path, int batchSize, IProgress <string> progress) { var root = new DirectoryInfo(path); var batches = Crawl(root).Batch(batchSize, r => r.Select(fi => (fi.FullName, fi.Length)).ToList()).ToList(); var count = 0; foreach (var part in batches) { //Measure speed and progress count++; var partStart = DateTime.Now; var size = ByteSize.FromBits(0); progress.Report($"Processing part {count}/{batches.Count}"); foreach (var(fullName, length) in part) { try { //Decode email var email = await MimeMessage.LoadAsync(fullName); //Gather fields var fields = new List <IIndexableField> { new StringField("path", fullName, Field.Store.YES), new Int64Field("Date", email.Date.Ticks, Field.Store.YES), new TextField("Subject", email.Subject, Field.Store.YES) }; var listFields = new[]
public void ParseBits() { var val = "1b"; var expected = ByteSize.FromBits(1); var result = ByteSize.Parse(val); Assert.Equal(expected, result); }
public void ThowsOnUnsupportedData(TimeUnit units) { var dummyRate = ByteSize.FromBits(1).Per(TimeSpan.FromSeconds(1)); Assert.Throws <NotSupportedException>(() => { dummyRate.Humanize(units); }); }
public void FromBitsMethod() { long value = 8; var result = ByteSize.FromBits(value); Assert.Equal(8, result.Bits); Assert.Equal(1, result.Bytes); }
public void ReturnsBits() { // Arrange var b = ByteSize.FromBits(10); // Act var result = b.ToString("##.#### b"); // Assert Assert.Equal("10 b", result); }
public void ReturnsZeroBits() { // Arrange var b = ByteSize.FromBits(0); // Act var result = b.ToString(); // Assert Assert.Equal("0 b", result); }
public Download() { //random data to test display this.DownloadName = "Car"; this.DownloadSize = ByteSize.FromBits(50000); this.Hoster = "Google Drive"; this.Status = "Online"; this.Speed = "5"; this.ETA = "1 minute"; this.BytesLoaded = "50 mb"; this.SaveTo = "Downloads"; }
public void FromBitsFraction() { // Arrange long value = 12; // Act var result = ByteSize.FromBits(value); // Assert Assert.Equal(12, result.Bits); Assert.Equal(1.5, result.Bytes); }
public void FromBitsMethod() { // Arrange long value = 8; // Act var result = ByteSize.FromBits(value); // Assert Assert.Equal(8, result.Bits); Assert.Equal(1, result.Bytes); }
private ActionResult FromLongBytes(long quantity, ByteMultiple multiple) { ByteSize calculatedSize; switch (multiple) { case ByteMultiple.Byte: calculatedSize = ByteSize.FromBytes(quantity); break; case ByteMultiple.KiloByte: calculatedSize = ByteSize.FromKiloBytes(quantity); break; case ByteMultiple.MegaByte: calculatedSize = ByteSize.FromMegaBytes(quantity); break; case ByteMultiple.GigaByte: calculatedSize = ByteSize.FromGigaBytes(quantity); break; case ByteMultiple.TeraByte: calculatedSize = ByteSize.FromTeraBytes(quantity); break; case ByteMultiple.PetaByte: calculatedSize = ByteSize.FromPetaBytes(quantity); break; default: calculatedSize = ByteSize.FromBits(quantity); break; } var viewModel = new ByteCalculatorViewModel(); viewModel.Results.Add(ByteMultiple.Bit.ToString(), calculatedSize.Bits.ToString()); viewModel.Results.Add(ByteMultiple.Byte.ToString(), calculatedSize.Bytes.ToString()); viewModel.Results.Add(ByteMultiple.KiloByte.ToString(), calculatedSize.KiloBytes.ToString()); viewModel.Results.Add(ByteMultiple.MegaByte.ToString(), calculatedSize.MegaBytes.ToString()); viewModel.Results.Add(ByteMultiple.GigaByte.ToString(), calculatedSize.GigaBytes.ToString()); viewModel.Results.Add(ByteMultiple.TeraByte.ToString(), calculatedSize.TeraBytes.ToString()); viewModel.Results.Add(ByteMultiple.PetaByte.ToString(), calculatedSize.PetaBytes.ToString()); return(this.PartialView("_CalculatorResults", viewModel)); }
public void ReturnsPluralBits() { Assert.Equal("2 bits", ByteSize.FromBits(2).ToFullWords()); }
public void ReturnsSingularBit() { Assert.Equal("1 bit", ByteSize.FromBits(1).ToFullWords()); }
public void LongBits() { const long size = 2; Assert.Equal(ByteSize.FromBits(size), size.Bits()); }
public void Bits() { Assert.Equal(ByteSize.FromBits(2), (2).Bits()); }
public void ParseBits() { Assert.Equal(ByteSize.FromBits(1), ByteSize.Parse("1b")); }
/// <summary> /// Considers input as bits /// </summary> /// <param name="input"></param> /// <returns></returns> public static ByteSize Bits(this ushort input) { return(ByteSize.FromBits(input)); }
public object Convert(object value, Type targetType, object parameter, string language) { var sent = (uint)value; return(string.Format("{0} kbps", ByteSize.FromBits(sent).KiloBytes.ToString().Split('.')[0])); }
// Token: 0x06000005 RID: 5 RVA: 0x00002074 File Offset: 0x00000274 public static ByteSize Bits(this int input) { return(ByteSize.FromBits((long)input)); }
// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250 public static ByteSize Bits(this byte input) { return(ByteSize.FromBits((long)((ulong)input))); }
public void SbyteBits() { const sbyte size = 2; Assert.Equal(ByteSize.FromBits(size), size.Bits()); }
public void ShortBits() { const short size = 2; Assert.Equal(ByteSize.FromBits(size), size.Bits()); }
/// <summary> /// Considers input as bits /// </summary> /// <param name="input"></param> /// <returns></returns> public static ByteSize Bits(this long input) { return(ByteSize.FromBits(input)); }
public void UintBits() { const uint size = 2; Assert.Equal(ByteSize.FromBits(size), size.Bits()); }
public void ReturnsBits() { Assert.Equal("10 b", ByteSize.FromBits(10).ToString("##.#### b")); }
public void MaxValueBits() { var size = ByteSize.FromBits(long.MaxValue); Assert.Equal(long.MaxValue, size.Bits); }