public void LL_NoNulls() { Action add = () => ListLayout.Add(null); Action insert = () => ListLayout.Insert(3, null); add.Should().Throw <ArgumentNullException>(); insert.Should().Throw <ArgumentNullException>(); }
public void LL_WidgetCapturesInput() { var inputWidget = CommonMocks.Widget("test"); int ignoreNext = 3; inputWidget .Setup(x => x.ProcessEvent(It.IsAny <WidgetEventArgs>())) .Callback <WidgetEventArgs>(e => { if (e.EventType != WidgetEventType.ButtonDown) { return; } if (ignoreNext > 0) { ignoreNext--; e.Handled = true; return; } }); ListLayout.Insert(3, inputWidget.Object); ListLayout.FocusIndex = 2; ListLayout.FocusIndex.Should().Be(2); ignoreNext.Should().Be(3); NextItem(); ListLayout.FocusIndex.Should().Be(3); ignoreNext.Should().Be(3); NextItem(); ListLayout.FocusIndex.Should().Be(3); ignoreNext.Should().Be(2); NextItem(); ListLayout.FocusIndex.Should().Be(3); ignoreNext.Should().Be(1); NextItem(); ListLayout.FocusIndex.Should().Be(3); ignoreNext.Should().Be(0); NextItem(); ListLayout.FocusIndex.Should().Be(4); }
public void LL_ListBehavior() { var item = new Mock <IWidget>().Object; var item3 = ListLayout[3]; ListLayout.IndexOf(item3).Should().Be(3); ListLayout.Contains(item).Should().BeFalse(); ListLayout.Insert(3, item); ListLayout[3].Should().Be(item); ListLayout[4].Should().Be(item3); ListLayout.IndexOf(item).Should().Be(3); ListLayout.IndexOf(item3).Should().Be(4); ListLayout.Count.Should().Be(11); ListLayout.Contains(item).Should().BeTrue(); ListLayout.Remove(item).Should().BeTrue(); ListLayout[3].Should().Be(item3); ListLayout.Count.Should().Be(10); ListLayout.Contains(item).Should().BeFalse(); ListLayout.RemoveAt(3); ListLayout.IndexOf(item3).Should().Be(-1); ListLayout.Contains(item3).Should().BeFalse(); ListLayout.Count.Should().Be(9); IWidget[] array = new IWidget[9]; ListLayout.CopyTo(array, 0); var index = 0; foreach (var listItem in ListLayout) { listItem.Should().Be(array[index]); index++; } }