public void CorrectlySelectItem()
        {
            var target = Target;

            const int itemIndex = 2;

            EventAssert.Raised(target, nameof(target.SelectionChanged), () => target.Items[itemIndex].Select());
        }
Пример #2
0
        public void CorrectlyCancel()
        {
            var target = Target;

            target.SetFocus();

            EventAssert.Raised(target, nameof(target.Canceled), () => target.MouseClick(MouseButton.Right));
        }
Пример #3
0
        public void CorrectlyRespondToClick()
        {
            var target = Target;
            var model  = target.Current;

            //Fill content to provide clickable space
            model.Content = "Link";

            EventAssert.Raised(target, nameof(target.Click), () => target.Invoke());
        }
Пример #4
0
        public void Insert(IList <int> collection)
        {
            // Arrange
            using var eventAssert = new EventAssert(GetObservableCollection(collection));

            // Act
            collection.Insert(index: 0, item: 1);

            // Assert
            Assert.Equal(new[] { 1 }, collection.ToList());
            eventAssert.AssertPropertyChanged("Count", "Item[]");
            eventAssert.AssertCollectionChangedAddItem(1);
        }
Пример #5
0
        public void CorrectlyRespondToClick()
        {
            var target = Target;
            var model  = target.Current;

            model.Items = CreateTestStepBarItems(10);

            var item = target.Items[2];

            item.Execute <SpecifyCommandMethodRun>();

            //Catch command executed
            EventAssert.Raised(target, "AutomationMessageSent", () => item.Invoke());
        }
Пример #6
0
        public void Indexer_Set(IList <int> collection)
        {
            // Arrange
            collection.Add(1);
            using var eventAssert = new EventAssert(GetObservableCollection(collection));

            // Act
            collection[0] = 2;

            // Assert
            Assert.Equal(new[] { 2 }, collection.ToList());
            eventAssert.AssertPropertyChanged("Item[]");
            eventAssert.AssertCollectionChangedReplace(oldValue: 1, newValue: 2);
        }
Пример #7
0
        public void Remove(IList <int> collection)
        {
            // Arrange
            collection.Add(1);
            collection.Add(2);
            using var eventAssert = new EventAssert(GetObservableCollection(collection));

            // Act
            collection.Remove(1);

            // Assert
            Assert.Equal(new[] { 2 }, collection.ToList());
            eventAssert.AssertPropertyChanged("Count", "Item[]");
            eventAssert.AssertCollectionChangedRemoveItem(1);
        }
Пример #8
0
        public void Clear(IList <int> collection)
        {
            // Arrange
            collection.Add(1);
            collection.Add(2);
            collection.Add(3);
            using var eventAssert = new EventAssert(GetObservableCollection(collection));

            // Act
            collection.Clear();

            // Assert
            Assert.Equal(Array.Empty <int>(), collection.ToList());
            eventAssert.AssertPropertyChanged("Count", "Item[]");
            eventAssert.AssertCollectionChangedReset();
        }
Пример #9
0
            public async Task CollectingEventListenerTest()
            {
                CollectFrom("Microsoft-AspNetCore-Testing-Test");

                await Task.Yield();

                TestEventSource.Log.Test();
                await Task.Yield();

                TestEventSource.Log.TestWithPayload(42, 4.2);
                await Task.Yield();

                var events = GetEvents();

                EventAssert.Collection(events,
                                       EventAssert.Event(1, "Test", EventLevel.Informational),
                                       EventAssert.Event(2, "TestWithPayload", EventLevel.Verbose)
                                       .Payload("payload1", 42)
                                       .Payload("payload2", 4.2));
            }
Пример #10
0
        public void OutputSpanSignalsNewSpanWithStartPointAndContentFromBuffersAndSpecifiedSpanType()
        {
            // Arrange
            Mock <ParserVisitor> mockListener = new Mock <ParserVisitor>();
            ParserContext        context      = SetupTestRun("phoo", mockListener.Object);
            Span actualSpan = null;

            using (context.StartBlock(BlockType.Functions, outputCurrentBufferAsTransition: true)) {
                context.ContentBuffer.Append(context.Source.ReadToEnd());

                mockListener.Setup(l => l.VisitSpan(It.IsAny <Span>()))
                .Callback <Span>(s => actualSpan = s);

                // Act
                context.OutputSpan(CodeSpan.Create(context));
            }

            // Assert
            EventAssert.IsSpan(actualSpan, SpanKind.Code, "phoo", new SourceLocation(0, 0, 0));
        }
Пример #11
0
        public void CorrectlySetColor(Color color)
        {
            var target           = Target;
            var targetProperties = target.Current;

            target.Current.HorizontalAlignment = HorizontalAlignment.Center;
            target.Current.VerticalAlignment   = VerticalAlignment.Center;

            var colorBoard = target.OpenColorBoard();

            Assert.That(colorBoard, Is.Not.Null);
            Assert.That(targetProperties.IsDropDownOpen, Is.True);

            colorBoard.ArgbColor = color;

            //colorPicker CurrentColor should have as expected color
            Assert.That(targetProperties.CurrentColor, Is.EqualTo(color));

            //check event invocation
            //if color different event should be raised otherwise shouldn't
            if (!Equals(target.Color, color))
            {
                EventAssert.Raised(target, nameof(target.ColorChanged), () => colorBoard.Apply());
            }
            else
            {
                EventAssert.NotRaised(target, nameof(target.ColorChanged), () => colorBoard.Apply());
            }

            Wait.UntilResponsive();

            //After apply drop down should be closed
            Assert.That(targetProperties.IsDropDownOpen, Is.False);

            //colorPicker should have expected color
            Assert.That(target.Color, Is.EqualTo(color));
        }
Пример #12
0
        public void CorrectlyDecrease()
        {
            var target = Target;

            EventAssert.Raised(target, nameof(target.Decreased), () => target.Decrease());
        }