public void Format_ProviderIsCapacityFormatterValueIsUnsupported_ResultAsExpected()
        {
            CapacityFormatter instance = this.GetInstance();
            DateTime          value    = new DateTime(2019, 5, 23, 17, 5, 23);

            Assert.That(instance.Format("yyyy-MM-dd HH:mm:ss", value, instance), Is.EqualTo("2019-05-23 17:05:23"));
        }
        public ReleasesOverview()
        {
            this.InitializeComponent();
            this.ApplyPagings(null);

            this.capacity = new CapacityFormatter(new CultureInfo("en-US"));

            // Data binding is a mystery.
            this.model       = new ReleaseQueryArgumentsModel();
            this.DataContext = this.model;
        }
Exemplo n.º 3
0
        private String GetTooltip(CultureInfo culture)
        {
            StringBuilder     builder  = new StringBuilder(512);
            CapacityFormatter capacity = new CapacityFormatter(culture);

            builder.AppendLine(String.Format("Location: {0}", this.FullPath));
            builder.AppendLine(String.Format("Created: {0} (UTC)", this.Created.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss", culture)));
            builder.AppendLine(String.Format("Changed: {0} (UTC)", this.Changed.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss", culture)));
            builder.AppendLine(String.Format("Accessed: {0} (UTC)", this.Accessed.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss", culture)));
            builder.AppendLine(String.Format("Size: {0} ({1})", String.Format(capacity, "{0:two2}", this.Size), String.Format(capacity, "{0:bytes}", this.Size)));
            builder.Append(String.Format("Attributes: {0}", this.Attributes));

            return(builder.ToString());
        }
        public void Examples_RecommendedUsage_ResultsInOutput()
        {
            CapacityFormatter formatter = this.GetInstance();

            Debug.WriteLine("Auto-format, auto-unit-selection, zero decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0}", 0));
            Debug.WriteLine(String.Format(formatter, "{0}", 123));
            Debug.WriteLine(String.Format(formatter, "{0}", 1234));
            Debug.WriteLine(String.Format(formatter, "{0}", 12345));
            Debug.WriteLine(String.Format(formatter, "{0}", 123456));
            Debug.WriteLine(String.Format(formatter, "{0}", 1234567));
            Debug.WriteLine(String.Format(formatter, "{0}", 12345678));
            Debug.WriteLine(String.Format(formatter, "{0}", 123456789));
            Debug.WriteLine(String.Format(formatter, "{0}", 1234567890));
            Debug.WriteLine(String.Format(formatter, "{0}", 12345678901));
            Debug.WriteLine(String.Format(formatter, "{0}", 123456789012));
            Debug.WriteLine(String.Format(formatter, "{0}", 1234567890123));
            Debug.WriteLine(String.Format(formatter, "{0}", 12345678901234));
            Debug.WriteLine(String.Format(formatter, "{0}", 123456789012345));
            Debug.WriteLine(String.Format(formatter, "{0}", 1234567890123456));
            Debug.WriteLine(String.Format(formatter, "{0}", 12345678901234567));
            Debug.WriteLine(String.Format(formatter, "{0}", 123456789012345678));

            Debug.WriteLine("Auto-format, auto-unit-selection, three decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0:3}", 0));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 123));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 1234));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 12345));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 123456));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 1234567));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 12345678));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 123456789));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 1234567890));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 12345678901));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 123456789012));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 1234567890123));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 12345678901234));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 123456789012345));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 1234567890123456));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 12345678901234567));
            Debug.WriteLine(String.Format(formatter, "{0:3}", 123456789012345678));

            Debug.WriteLine("Auto-format, unit one preferred, zero decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0:one}", 0));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 123));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 1234));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 12345));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 123456));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 1234567));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 12345678));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 123456789));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 1234567890));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 12345678901));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 123456789012));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 1234567890123));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 12345678901234));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 123456789012345));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 1234567890123456));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 12345678901234567));
            Debug.WriteLine(String.Format(formatter, "{0:one}", 123456789012345678));

            Debug.WriteLine("Auto-format, unit one preferred, six decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 0));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 123));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 1234));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 12345));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 123456));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 1234567));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 12345678));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 123456789));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 1234567890));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 12345678901));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 123456789012));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 1234567890123));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 12345678901234));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 123456789012345));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 1234567890123456));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 12345678901234567));
            Debug.WriteLine(String.Format(formatter, "{0:one6}", 123456789012345678));

            Debug.WriteLine("Auto-format, unit two preferred, zero decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0:two}", 0));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 123));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 1234));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 12345));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 123456));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 1234567));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 12345678));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 123456789));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 1234567890));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 12345678901));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 123456789012));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 1234567890123));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 12345678901234));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 123456789012345));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 1234567890123456));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 12345678901234567));
            Debug.WriteLine(String.Format(formatter, "{0:two}", 123456789012345678));

            Debug.WriteLine("Auto-format, unit two preferred, six decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 0));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 123));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 1234));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 12345));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 123456));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 1234567));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 12345678));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 123456789));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 1234567890));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 12345678901));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 123456789012));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 1234567890123));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 12345678901234));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 123456789012345));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 1234567890123456));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 12345678901234567));
            Debug.WriteLine(String.Format(formatter, "{0:two6}", 123456789012345678));

            Debug.WriteLine("Auto-format, unit one preferred, four decimal digits, mixed interception.");
            Debug.WriteLine(String.Format(formatter, "{0:One4}", 1073741824m));
            Debug.WriteLine(String.Format(formatter, "{0:One~4}", 1073741824m));
            Debug.WriteLine(String.Format(formatter, "{0:One4}", 2213102268m));
            Debug.WriteLine(String.Format(formatter, "{0:One~4}", 2213102268m));

            Debug.WriteLine("Unit-one-driven format, zero decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0:bytes}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:kb}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:mb}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:gb}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:tb}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:pb}", 123456789012345678));

            Debug.WriteLine("Unit-one-driven format, four decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0:bytes4}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:kb4}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:mb4}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:gb4}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:tb4}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:pb4}", 123456789012345678));

            Debug.WriteLine("Unit-two-driven format, zero decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0:bib}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:kib}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:mib}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:gib}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:tib}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:pib}", 123456789012345678));

            Debug.WriteLine("Unit-two-driven format, four decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0:bib4}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:kib4}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:mib4}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:gib4}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:tib4}", 123456789012345678));
            Debug.WriteLine(String.Format(formatter, "{0:pib4}", 123456789012345678));

            Debug.WriteLine("Custom-unit-format, zero decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0:my-size}", 123456789012345678));

            Debug.WriteLine("Custom-unit-format, six decimal digits.");
            Debug.WriteLine(String.Format(formatter, "{0:my-size6}", 123456789012345678));

            Debug.WriteLine("Unit-two-driven format, four decimal digits, but no calculation.");
            Debug.WriteLine(String.Format(formatter, "{0:!bib4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:!kib4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:!mib4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:!gib4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:!tib4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:!pib4}", 1152921504606846976m));

            Debug.WriteLine("Unit-two-driven format, four decimal digits, but interception.");
            Debug.WriteLine(String.Format(formatter, "{0:bib~4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:kib~4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:mib~4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:gib~4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:tib~4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:pib~4}", 1152921504606846976m));

            Debug.WriteLine("Unit-two-driven format, four decimal digits, with interception, but no calculation.");
            Debug.WriteLine(String.Format(formatter, "{0:!bib~4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:!kib~4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:!mib~4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:!gib~4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:!tib~4}", 1152921504606846976m));
            Debug.WriteLine(String.Format(formatter, "{0:!pib~4}", 1152921504606846976m));

            Assert.That(true);
        }
        public void Format_ProviderIsCapacityFormatterValueIsSupported_ResultAsExpected(String format, Int32 value, String expected)
        {
            CapacityFormatter instance = this.GetInstance();

            Assert.That(instance.Format(format, value, instance), Is.EqualTo(expected));
        }
        public void Format_NullValue_ResultIsEmpty()
        {
            CapacityFormatter instance = this.GetInstance();

            Assert.That(instance.Format("format", null, instance), Is.Empty);
        }