示例#1
0
        private void RegisterFactories(List <DiscoverableFactory> factories, List <Type> inputTypes)
        {
            List <Type> supportedOutputs = new List <Type>();

            HomelessTestHelpers.Merge(inputTypes, GatherFactoryInputs(factories));
            MapFactories(factories, inputTypes);
        }
示例#2
0
        /// <summary>
        /// Create a InkCanvas.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override InkCanvas Create(DeterministicRandom random)
        {
            InkCanvas inkCanvas = new InkCanvas();

            inkCanvas.Background = Background;
            HomelessTestHelpers.Merge(inkCanvas.Children, UIElementCollection);
            inkCanvas.DefaultDrawingAttributes      = DefaultDrawingAttributes;
            inkCanvas.DefaultStylusPointDescription = DefaultStylusPointDescription;
            inkCanvas.EditingMode           = random.NextEnum <InkCanvasEditingMode>();
            inkCanvas.EditingModeInverted   = random.NextEnum <InkCanvasEditingMode>();
            inkCanvas.EraserShape           = EraserShape;
            inkCanvas.MoveEnabled           = random.NextBool();
            inkCanvas.PreferredPasteFormats = PreferredPasteFormats;
            inkCanvas.ResizeEnabled         = random.NextBool();
            inkCanvas.Strokes         = Strokes;
            inkCanvas.UseCustomCursor = random.NextBool();

            inkCanvas.ActiveEditingModeChanged         += new RoutedEventHandler(ActiveEditingModeChanged);
            inkCanvas.DefaultDrawingAttributesReplaced += new DrawingAttributesReplacedEventHandler(DefaultDrawingAttributesReplaced);
            inkCanvas.EditingModeChanged         += new RoutedEventHandler(EditingModeChanged);
            inkCanvas.EditingModeInvertedChanged += new RoutedEventHandler(EditingModeInvertedChanged);
            inkCanvas.Gesture           += new InkCanvasGestureEventHandler(Gesture);
            inkCanvas.SelectionChanged  += new EventHandler(SelectionChanged);
            inkCanvas.SelectionChanging += new InkCanvasSelectionChangingEventHandler(SelectionChanging);
            inkCanvas.SelectionMoved    += new EventHandler(SelectionMoved);
            inkCanvas.SelectionMoving   += new InkCanvasSelectionEditingEventHandler(SelectionMoving);
            inkCanvas.SelectionResized  += new EventHandler(SelectionResized);
            inkCanvas.SelectionResizing += new InkCanvasSelectionEditingEventHandler(SelectionResizing);
            inkCanvas.StrokeCollected   += new InkCanvasStrokeCollectedEventHandler(StrokeCollected);
            inkCanvas.StrokeErased      += new RoutedEventHandler(StrokeErased);
            inkCanvas.StrokeErasing     += new InkCanvasStrokeErasingEventHandler(StrokeErasing);
            inkCanvas.StrokesReplaced   += new InkCanvasStrokesReplacedEventHandler(StrokesReplaced);

            return(inkCanvas);
        }
示例#3
0
        public override ListItem Create(DeterministicRandom random)
        {
            ListItem listItem = null;

            if (Paragraph != null)
            {
                listItem = new ListItem(Paragraph);
            }
            else
            {
                listItem = new ListItem();
            }

            ApplyTextElementFactory(listItem, random);
            HomelessTestHelpers.Merge(listItem.Blocks, Children);
            listItem.BorderBrush          = BorderBrush;
            listItem.BorderThickness      = BorderThickness;
            listItem.FlowDirection        = random.NextEnum <FlowDirection>();
            listItem.LineHeight           = CreateValidLineHeight(LineHeight);
            listItem.LineStackingStrategy = random.NextEnum <LineStackingStrategy>();
            listItem.Margin        = Margin;
            listItem.Padding       = Padding;
            listItem.TextAlignment = random.NextEnum <TextAlignment>();

            return(listItem);
        }
示例#4
0
        public override GridView Create(DeterministicRandom random)
        {
            GridView gridView = new GridView();

            HomelessTestHelpers.Merge(gridView.Columns, HomelessTestHelpers.FilterListOfType(Children, typeof(ContextMenu)));
            return(gridView);
        }
示例#5
0
        public override Viewport3D Create(DeterministicRandom random)
        {
            Viewport3D viewport3D = new Viewport3D();

            viewport3D.Camera = Camera;
            HomelessTestHelpers.Merge(viewport3D.Children, Children);
            return(viewport3D);
        }
示例#6
0
 /// <summary>
 /// Apply common Grid properties.
 /// </summary>
 /// <param name="grid"/>
 /// <param name="random"/>
 protected void ApplyGridProperties(GridType grid, DeterministicRandom random)
 {
     ApplyCommonProperties(grid, random);
     HomelessTestHelpers.Merge(grid.ColumnDefinitions, ColumnDefinitions);
     HomelessTestHelpers.Merge(grid.RowDefinitions, RowDefinitions);
     SetChildrenLayout(grid, random);
     grid.ShowGridLines = random.NextBool();
 }
示例#7
0
        public override ContainerUIElement3D Create(DeterministicRandom random)
        {
            ContainerUIElement3D containerUIElement3D = new ContainerUIElement3D();

            ApplyTransform(containerUIElement3D);
            HomelessTestHelpers.Merge(containerUIElement3D.Children, Children);
            return(containerUIElement3D);
        }
示例#8
0
        public override TableRowGroup Create(DeterministicRandom random)
        {
            TableRowGroup rowGroup = new TableRowGroup();

            ApplyTextElementFactory(rowGroup, random);
            HomelessTestHelpers.Merge(rowGroup.Rows, Rows);

            return(rowGroup);
        }
示例#9
0
        public override ModelVisual3D Create(DeterministicRandom random)
        {
            ModelVisual3D modelVisual3D = new ModelVisual3D();

            ApplyTransform(modelVisual3D);
            modelVisual3D.Content = Model3D;
            HomelessTestHelpers.Merge(modelVisual3D.Children, Children);
            return(modelVisual3D);
        }
示例#10
0
        public override Section Create(DeterministicRandom random)
        {
            Section section = new Section();

            ApplyBlockProperties(section, random);
            HomelessTestHelpers.Merge(section.Blocks, Children);
            section.HasTrailingParagraphBreakOnPaste = random.NextBool();
            return(section);
        }
示例#11
0
        public override FixedDocument Create(DeterministicRandom random)
        {
            FixedDocument fixedDocument = new FixedDocument();

            HomelessTestHelpers.Merge(fixedDocument.Pages, Children);
            fixedDocument.DocumentPaginator.PageSize = PageSize;
            fixedDocument.PrintTicket = PrintTicket;
            return(fixedDocument);
        }
示例#12
0
        public override Span Create(DeterministicRandom random)
        {
            Span span = new Span();

            ApplyInlineProperties(span, random);
            HomelessTestHelpers.Merge(span.Inlines, Children);

            return(span);
        }
示例#13
0
        public override TableRow Create(DeterministicRandom random)
        {
            TableRow tableRow = new TableRow();

            ApplyTextElementFactory(tableRow, random);
            HomelessTestHelpers.Merge(tableRow.Cells, Cells);

            return(tableRow);
        }
示例#14
0
        public override Style Create(DeterministicRandom random)
        {
            Style style = null;

            if (random.NextBool())
            {
                style = new Style();
                HomelessTestHelpers.Merge(style.Setters, Setters);
            }
            return(style);
        }
示例#15
0
        public override Table Create(DeterministicRandom random)
        {
            Table table = new Table();

            ApplyBlockProperties(table, random);
            table.CellSpacing = random.NextDouble() * 5;
            HomelessTestHelpers.Merge(table.Columns, Columns);
            HomelessTestHelpers.Merge(table.RowGroups, RowGroups);

            return(table);
        }
示例#16
0
        /// <summary>
        /// Create a ToolBarTray.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override ToolBarTray Create(DeterministicRandom random)
        {
            ToolBarTray toolBarTray = new ToolBarTray();

            toolBarTray.Background  = Background;
            toolBarTray.IsLocked    = random.NextBool();
            toolBarTray.Orientation = random.NextEnum <Orientation>();
            HomelessTestHelpers.Merge(toolBarTray.ToolBars, ToolBars);

            return(toolBarTray);
        }
示例#17
0
        // Identify the types needed to produce content for Factories
        private List <Type> GatherFactoryInputs(List <DiscoverableFactory> factories)
        {
            List <Type> testInputTypes = new List <Type>();

            foreach (DiscoverableFactory factory in factories)
            {
                List <Type> factoryInputTypes = DiscoverableInputHelper.GetFactoryInputTypes(factory.GetType());
                HomelessTestHelpers.Merge(testInputTypes, factoryInputTypes);
            }
            return(testInputTypes);
        }
示例#18
0
 protected void ApplyAnchoredBlockProperties(AnchoredBlockType anchoredBlock, DeterministicRandom random)
 {
     ApplyInlineProperties(anchoredBlock, random);
     HomelessTestHelpers.Merge(anchoredBlock.Blocks, Blocks);
     anchoredBlock.BorderBrush          = BorderBrush;
     anchoredBlock.BorderThickness      = BorderThickness;
     anchoredBlock.LineHeight           = CreateValidLineHeight(LineHeight);
     anchoredBlock.LineStackingStrategy = random.NextEnum <LineStackingStrategy>();
     anchoredBlock.Margin        = Margin;
     anchoredBlock.Padding       = Padding;
     anchoredBlock.TextAlignment = random.NextEnum <TextAlignment>();
 }
示例#19
0
        public override Viewport3DVisual Create(DeterministicRandom random)
        {
            Viewport3DVisual viewport3DVisual = new Viewport3DVisual();

            viewport3DVisual.Camera = Camera;
            HomelessTestHelpers.Merge(viewport3DVisual.Children, Children);
            viewport3DVisual.Clip        = Geometry;
            viewport3DVisual.Offset      = Vector;
            viewport3DVisual.Opacity     = random.NextDouble();
            viewport3DVisual.OpacityMask = Brush;
            viewport3DVisual.Transform   = Transform;
            viewport3DVisual.Viewport    = Rect;
            return(viewport3DVisual);
        }
示例#20
0
        public override Paragraph Create(DeterministicRandom random)
        {
            Paragraph paragraph = new Paragraph();

            ApplyBlockProperties(paragraph, random);
            HomelessTestHelpers.Merge(paragraph.Inlines, Children);
            paragraph.KeepTogether    = KeepTogether;
            paragraph.KeepWithNext    = KeepWithNext;
            paragraph.MinOrphanLines  = MinOrphanLines;
            paragraph.MinWidowLines   = MinWidowLines;
            paragraph.TextDecorations = TextDecorations;
            paragraph.TextIndent      = TextIndent;
            return(paragraph);
        }
示例#21
0
        public override ContainerVisual Create(DeterministicRandom random)
        {
            ContainerVisual containerVisual = new ContainerVisual();

            containerVisual.Clip                = Geometry;
            containerVisual.Offset              = Vector;
            containerVisual.Opacity             = random.NextDouble();
            containerVisual.OpacityMask         = Brush;
            containerVisual.Transform           = Transform;
            containerVisual.XSnappingGuidelines = XSnappingGuidelines;
            containerVisual.YSnappingGuidelines = YSnappingGuidelines;
            HomelessTestHelpers.Merge(containerVisual.Children, Children);
            return(containerVisual);
        }
示例#22
0
        public override List Create(DeterministicRandom random)
        {
            List list = new List();

            ApplyBlockProperties(list, random);
            HomelessTestHelpers.Merge(list.ListItems, Children);
            list.MarkerOffset = MarkerOffset;
            //HACK: Work around
            list.TextEffects = null;

            list.MarkerStyle = random.NextEnum <TextMarkerStyle>();
            list.StartIndex  = random.Next(list.ListItems.Count) + 1;
            return(list);
        }
示例#23
0
        public override Italic Create(DeterministicRandom random)
        {
            Italic italic = new Italic();

            ApplyInlineProperties(italic, random);
            if (MultiInlinesRate < 0.1)
            {
                HomelessTestHelpers.Merge(italic.Inlines, Children);
            }
            else
            {
                italic.Inlines.Add(Content);
            }

            return(italic);
        }
示例#24
0
        public override Bold Create(DeterministicRandom random)
        {
            Bold bold = new Bold();

            ApplyInlineProperties(bold, random);
            if (MultiInlinesRate < 0.1)
            {
                HomelessTestHelpers.Merge(bold.Inlines, Children);
            }
            else
            {
                bold.Inlines.Add(Content);
            }

            return(bold);
        }
示例#25
0
        public override Underline Create(DeterministicRandom random)
        {
            Underline underline = new Underline();

            ApplyInlineProperties(underline, random);
            if (MultiInlinesRate < 0.1)
            {
                HomelessTestHelpers.Merge(underline.Inlines, Children);
            }
            else
            {
                underline.Inlines.Add(Content);
            }

            return(underline);
        }
示例#26
0
        public override FlowDocument Create(DeterministicRandom random)
        {
            FlowDocument flowDocument = new FlowDocument();

            HomelessTestHelpers.Merge(flowDocument.Blocks, Children);
            flowDocument.Background      = Background;
            flowDocument.ColumnGap       = random.NextDouble() * 10;
            flowDocument.ColumnRuleBrush = ColumnRuleBrush;
            flowDocument.ColumnRuleWidth = random.NextDouble() * 10;
            flowDocument.ColumnWidth     = random.NextDouble() * 100;
            flowDocument.FlowDirection   = random.NextEnum <FlowDirection>();

            if (FontFamily != null)
            {
                flowDocument.FontFamily = FontFamily;
            }

            flowDocument.FontSize                  = random.NextDouble() * 20 + 0.1;
            flowDocument.FontStretch               = random.NextStaticProperty <FontStretch>(typeof(FontStretches));
            flowDocument.FontStyle                 = random.NextStaticProperty <FontStyle>(typeof(FontStyles));
            flowDocument.FontWeight                = random.NextStaticProperty <FontWeight>(typeof(FontWeights));
            flowDocument.Foreground                = Foreground;
            flowDocument.IsColumnWidthFlexible     = IsColumnWidthFlexible;
            flowDocument.IsHyphenationEnabled      = IsHyphenationEnabled;
            flowDocument.IsOptimalParagraphEnabled = IsOptimalParagraphEnabled;
            flowDocument.LineHeight                = random.NextDouble() * 5 + 0.005;
            flowDocument.LineStackingStrategy      = random.NextEnum <LineStackingStrategy>();
            double minPageHeight = random.NextDouble() * 100 + 100;
            double maxPageHeight = minPageHeight + random.NextDouble() * 900;
            double minPageWidth  = random.NextDouble() * 100 + 100;
            double maxPageWidth  = minPageWidth + random.NextDouble() * 900;

            flowDocument.MaxPageHeight = maxPageHeight;
            flowDocument.MaxPageWidth  = maxPageWidth;
            flowDocument.MinPageHeight = minPageHeight;
            flowDocument.MinPageWidth  = minPageWidth;
            flowDocument.PageHeight    = minPageHeight + random.NextDouble() * (maxPageHeight - minPageHeight);
            flowDocument.PageWidth     = minPageWidth + random.NextDouble() * (maxPageWidth - minPageWidth);
            flowDocument.PagePadding   = Thickness;
            flowDocument.TextAlignment = random.NextEnum <TextAlignment>();
            flowDocument.TextEffects   = TextEffectCollection;

            return(flowDocument);
        }
示例#27
0
        public override TableCell Create(DeterministicRandom random)
        {
            TableCell tableCell = new TableCell();

            ApplyTextElementFactory(tableCell, random);
            HomelessTestHelpers.Merge(tableCell.Blocks, Blocks);
            tableCell.BorderBrush     = BorderBrush;
            tableCell.BorderThickness = BorderThickness;
            //Set ColumnSpan and RowSpan between 1 and 10.
            tableCell.ColumnSpan           = ColumnSpan % 10 + 1;
            tableCell.RowSpan              = RowSpan % 10 + 1;
            tableCell.FlowDirection        = FlowDirection;
            tableCell.LineHeight           = CreateValidLineHeight(LineHeight);
            tableCell.LineStackingStrategy = LineStackingStrategy;
            tableCell.Padding              = Padding;
            tableCell.TextAlignment        = TextAlignment;

            return(tableCell);
        }
示例#28
0
        /// <summary>
        /// Apply common ItemsControl properties.
        /// </summary>
        /// <param name="itemsControl"></param>
        /// <param name="random"></param>
        protected void ApplyItemsControlProperties(T itemsControl, DeterministicRandom random)
        {
            HomelessTestHelpers.Merge(itemsControl.Items, Children);
            HomelessTestHelpers.Merge(itemsControl.GroupStyle, GroupStyleList);
            itemsControl.AlternationCount = random.Next();
#if TESTBUILD_CLR40
            itemsControl.IsTextSearchCaseSensitive = random.NextBool();
#endif
            itemsControl.IsTextSearchEnabled        = random.NextBool();
            itemsControl.ItemContainerStyle         = ItemContainerStyle;
            itemsControl.ItemContainerStyleSelector = ItemContainerStyleSelector;
            itemsControl.DisplayMemberPath          = null;
            itemsControl.ItemStringFormat           = "Title:{0}";

            if (random.NextDouble() < 0.1)//ItemsControl set DataTemplate 10% possibility.
            {
                itemsControl.ItemTemplate = DataTemplate;
            }
        }
示例#29
0
        public override TextBlock Create(DeterministicRandom random)
        {
            TextBlock textBlock = new TextBlock();

            if (random.NextBool())
            {
                textBlock.Text = Text;
            }
            else
            {
                //HACK: Floater and Figure types are not valid as children of TextBlock.
                //Elements in the collection need to satisfy InlineCollection.ValidateChild behavior. This step filters those types
                List <Inline> filteredChildren = HomelessTestHelpers.FilterListOfType(Children, typeof(Floater));
                filteredChildren = HomelessTestHelpers.FilterListOfType(filteredChildren, typeof(Figure));

                // assign filtered inlines collection to the TextBlock.
                HomelessTestHelpers.Merge(textBlock.Inlines, filteredChildren);
            }

            return(textBlock);
        }
示例#30
0
        /// <summary>
        /// Createa a Calendar.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override Calendar Create(DeterministicRandom random)
        {
            Calendar calendar = new Calendar();

            if (DisplayDate != null)
            {
                calendar.DisplayDate = (DateTime)DisplayDate.GetData(random);
            }

            if (DisplayDateEnd != null)
            {
                calendar.DisplayDateEnd = (DateTime)DisplayDateEnd.GetData(random);
            }

            if (DisplayDateStart != null)
            {
                calendar.DisplayDateStart = (DateTime)DisplayDateStart.GetData(random);
            }

            calendar.FirstDayOfWeek     = FirstDayOfWeek;
            calendar.IsTodayHighlighted = IsTodayHighlighted;
            calendar.SelectionMode      = SelectionMode;
            calendar.DisplayMode        = DisplayMode;
            HomelessTestHelpers.Merge(calendar.BlackoutDates, BlackoutDates);

            //SelectedDate property cannot be set when the selection mode is None.
            // and
            //BlackoutDates cannot contain the SelectedDate.
            if (SelectedDate != null && calendar.SelectionMode != CalendarSelectionMode.None)
            {
                DateTime date = (DateTime)SelectedDate.GetData(random);
                if (!calendar.BlackoutDates.Contains(date))
                {
                    calendar.SelectedDate = date;
                }
            }

            return(calendar);
        }