public void CustomFormat_ShouldReturnProperValue(number metres, string customFormat, string cultureName, string expectedResult)
            {
                // arrange
                var formatter = new LengthFormatter(CultureInfo.GetCultureInfo(cultureName));
                var length    = new Length(metres, LengthUnit.Metre);

                // act
                string actualResult = formatter.Format(customFormat, length);

                // assert
                actualResult.Should().Be(expectedResult);
            }
            public void StringFormat_StandardFormat_ShouldReturnProperValue(number kilograms, string format, string cultureName, string expectedResult, string reason)
            {
                // arrange
                var formatter = new LengthFormatter(CultureInfo.GetCultureInfo(cultureName));
                var length    = new Length(kilograms, LengthUnit.Metre);

                // act
                string actualResult = string.Format(formatter, format, length);

                // assert
                actualResult.Should().Be(expectedResult, because: reason);
            }
        public static DriveTabItem Create(string drive)
        {
            var driveInfo = FileSystem.DriveInformation(drive);
            var source    = IconExtractor.GetDriveIcon(driveInfo.DriveType);

            var toolTipText = (driveInfo.IsReady
                                    ? string.Format("{0}{1}\nСвободно: {2} КБ" +
                                                    "\nВсего:         {3} КБ",
                                                    driveInfo.VolumeLabel,
                                                    driveInfo.DriveFormat,
                                                    LengthFormatter.LengthFormat(driveInfo.AvailableFreeSpace),
                                                    LengthFormatter.LengthFormat(driveInfo.TotalSize))
                                    : string.Format("{0} {1}",
                                                    driveInfo.DriveType,
                                                    driveInfo.Name));

            return(new DriveTabItem(source, drive.ToLower(), toolTipText, driveInfo.RootDirectory));
        }
        protected void OnImageWrapPanelClick(object sender, RoutedEventArgs e)
        {
            var img = (Image)sender;

            IndexOfCurImg = imgWrapList.Children.IndexOf(img);

            var inf = new FileInfo(img.Tag.ToString());

            DefaultEditingValues();

            bigImage.Source = ImageUtils.GetSmallImage(img.Tag.ToString());

            // TODO: Повторяется при клике по табам
            _tempBitmap = ((BitmapSource)bigImage.Source).Clone();

            imageDescription.Content = "Файл: " + inf.Name + ", "
                                       + _tempBitmap.PixelWidth + "x" + _tempBitmap.PixelHeight + ", размер файла: "
                                       + LengthFormatter.LengthFormat(inf.Length);
            zoomText.Text = "1";
        }
예제 #5
0
        [TestMethod] public void Simple_Len_Ser()
        {
            void Check <T>(T obj)
            {
                var ser = new LengthFormatter <T>(getFormatter.GetFormatter <T>());
                var arr = ser.serialize(obj);
                T   des = ser.deserialize(arr);

                if (obj is ValueType || obj is string)
                {
                    Assert.AreEqual(obj, des);
                }
                else if (obj is Array)
                {
                    var oa = obj as Array;
                    var da = des as Array;
                    foreach (var inds in oa.Indices())
                    {
                        Assert.AreEqual(oa.GetValue(inds), da.GetValue(inds));
                    }
                }
                else if (obj is IDictionary)
                {
                    var od = obj as IDictionary;
                    var dd = des as IDictionary;
                    foreach (var inds in od.Keys)
                    {
                        Assert.AreEqual(od[inds], dd[inds]);
                    }
                }
                else if (obj.GetType() == typeof(object))
                {
                    Assert.IsTrue(des.GetType() == typeof(object));
                }
                else
                {
                    Assert.Fail($"unhandled type: {obj.GetType()}");
                }
            }

            var strings = new[] { "", "a", "abcdef", "garland", new string('a', 1000), new string('a', 67_000) };