Exemple #1
0
        public void Strings()
        {
            Assert.Equal("500m", ByteUnits.ToMilliByteString(0.5m));
            Assert.Equal("1000000m", ByteUnits.ToMilliByteString(1000));

            Assert.Equal("500", ByteUnits.ToByteString(500));
            Assert.Equal("1000000", ByteUnits.ToByteString(1000000));

            Assert.Equal("1K", ByteUnits.ToKString(1000));
            Assert.Equal("2K", ByteUnits.ToKString(2000));
            Assert.Equal("0.5K", ByteUnits.ToKString(500));

            Assert.Equal("1Ki", ByteUnits.ToKiString(1024));
            Assert.Equal("2Ki", ByteUnits.ToKiString(2048));
            Assert.Equal("0.5Ki", ByteUnits.ToKiString(512));

            Assert.Equal("1M", ByteUnits.ToMString(1000000));
            Assert.Equal("2M", ByteUnits.ToMString(2000000));
            Assert.Equal("0.5M", ByteUnits.ToMString(500000));

            Assert.Equal("1Mi", ByteUnits.ToMiString(1 * ByteUnits.MebiBytes));
            Assert.Equal("2Mi", ByteUnits.ToMiString(2 * ByteUnits.MebiBytes));
            Assert.Equal("0.5Mi", ByteUnits.ToMiString(ByteUnits.MebiBytes / 2));

            Assert.Equal("1G", ByteUnits.ToGString(1000000000));
            Assert.Equal("2G", ByteUnits.ToGString(2000000000));
            Assert.Equal("0.5G", ByteUnits.ToGString(500000000));

            Assert.Equal("1Gi", ByteUnits.ToGiString(1 * ByteUnits.GibiBytes));
            Assert.Equal("2Gi", ByteUnits.ToGiString(2 * ByteUnits.GibiBytes));
            Assert.Equal("0.5Gi", ByteUnits.ToGiString(ByteUnits.GibiBytes / 2));

            Assert.Equal("1T", ByteUnits.ToTString(1000000000000));
            Assert.Equal("2T", ByteUnits.ToTString(2000000000000));
            Assert.Equal("0.5T", ByteUnits.ToTString(500000000000));

            Assert.Equal("1Ti", ByteUnits.ToTiString(1 * ByteUnits.TebiBytes));
            Assert.Equal("2Ti", ByteUnits.ToTiString(2 * ByteUnits.TebiBytes));
            Assert.Equal("0.5Ti", ByteUnits.ToTiString(ByteUnits.TebiBytes / 2));

            Assert.Equal("1P", ByteUnits.ToPString(1000000000000000));
            Assert.Equal("2P", ByteUnits.ToPString(2000000000000000));
            Assert.Equal("0.5P", ByteUnits.ToPString(500000000000000));

            Assert.Equal("1Pi", ByteUnits.ToPiString(1 * ByteUnits.PebiBytes));
            Assert.Equal("2Pi", ByteUnits.ToPiString(2 * ByteUnits.PebiBytes));
            Assert.Equal("0.5Pi", ByteUnits.ToPiString(ByteUnits.PebiBytes / 2));

            Assert.Equal("1E", ByteUnits.ToEString(1000000000000000000));
            Assert.Equal("2E", ByteUnits.ToEString(2000000000000000000));
            Assert.Equal("0.5E", ByteUnits.ToEString(500000000000000000));

            Assert.Equal("1Ei", ByteUnits.ToEiString(1 * ByteUnits.ExbiBytes));
            Assert.Equal("2Ei", ByteUnits.ToEiString(2 * ByteUnits.ExbiBytes));
            Assert.Equal("0.5Ei", ByteUnits.ToEiString(ByteUnits.ExbiBytes / 2));
        }