Exemplo n.º 1
0
        public void CanHashCodeWhenSizeIs1034AndCultureIsPT_BR()
        {
            var originalSize = 1034;
            var sizeInBytes = new FileSize(originalSize);
            var sizeInKBytes = sizeInBytes.In(FileSizeUnit.KB);

            sizeInBytes.Equals(originalSize).Should().Be.True();
            sizeInKBytes.Equals(originalSize).Should().Be.True();

            sizeInKBytes.Equals(sizeInBytes).Should().Be.True();

            sizeInKBytes.ToString(CultureInfo.GetCultureInfo("pt-BR")).Should().Be("1,01 KB");
        }
Exemplo n.º 2
0
        public FileSize InBestUnit()
        {
            FileSize temp = 0;

            foreach (FileSizeUnit value in Enum.GetValues(typeof(FileSizeUnit)))
            {
                temp = this.In(value);
                if (temp.Size < StopSearchingFactor)
                {
                    return(temp);
                }
            }
            return(temp);
        }
Exemplo n.º 3
0
        public void CanConvertBetweenUnitsWhenSizeIs1060111()
        {
            var originalSize = 1060111;
            var sizeInBytes = new FileSize(originalSize);
            var sizeInKBytes = sizeInBytes.In(FileSizeUnit.KB);
            var sizeInMBytes = sizeInBytes.In(FileSizeUnit.MB);

            sizeInBytes.Equals(originalSize).Should().Be.True();
            sizeInKBytes.Equals(originalSize).Should().Be.True();
            sizeInMBytes.Equals(originalSize).Should().Be.True();

            sizeInKBytes.Equals(sizeInBytes).Should().Be.True();
            sizeInMBytes.Equals(sizeInBytes).Should().Be.True();

            sizeInMBytes.Equals(sizeInKBytes).Should().Be.True();

            sizeInMBytes.ToString(CultureInfo.InvariantCulture).Should().Be("1.01 MB");
            sizeInMBytes.ToString("0.###", CultureInfo.InvariantCulture).Should().Be("1.011 MB");
        }
Exemplo n.º 4
0
 public bool Equals(FileSize size)
 {
     return size == this;
 }
Exemplo n.º 5
0
 public bool Equals(FileSize size)
 {
     return(size == this);
 }