public void WhenTargetIsNull_ShouldThrowArgumentNullException() { try { ListElementEventHandler.RaiseEventBaseOnEvtTarget(null, new List <Events.EventRaiserDefinition>()); } catch (ArgumentNullException e) { Assert.AreEqual("target", e.ParamName); } }
public void WhenEventRaisersIsNull_ShouldThrowArgumentNullException() { try { ListElementEventHandler.RaiseEventBaseOnEvtTarget(new VisualElement(), null); } catch (ArgumentNullException e) { Assert.AreEqual("eventRaisers", e.ParamName); } }
public IEnumerator ShouldRegisterAllCallbacks() { ListElement element = new ListElement(true); WindowFixture.Window.rootVisualElement.Add(element); TestEventHandler handler = new TestEventHandler(); ListElementEventHandler.RegisterCallbacks(element, handler); element.SendEvent(new ClearListRequestedEvent { target = element }); element.SendEvent(new ClearListEvent { target = element }); element.SendEvent(new ClearListCancelledEvent { target = element }); element.SendEvent(new MoveItemEvent { target = element }); element.SendEvent(new RemoveItemEvent { target = element }); element.SendEvent(new AddItemEvent { target = element }); element.SendEvent(new ClickEvent { target = element }); element.SendEvent(new ChangeEvent <Object> { target = element }); element.SendEvent(new ChangeEvent <int> { target = element }); element.SendEvent(new RowInsertedEvent { target = element }); element.SendEvent(new ListResetEvent { target = element }); element.SendEvent(new AttachToPanelEvent { target = element }); yield return(null); WindowFixture.Window.rootVisualElement.Remove(element); Assert.IsEmpty(handler.EventNames); }
public void ShouldRaiseEvent() { VisualElement control = new VisualElement(); EventRaiserDefinition def = EventRaiserDefinition.Create <RaiseEventTestEvent>(control, null, control); control.RegisterCallback <RaiseEventTestEvent>(e => { Assert.Pass($"{nameof(RaiseEventTestEvent)} was raised"); }); WindowFixture.RootElement.AddAndRemove(control, () => ListElementEventHandler.RaiseEventBaseOnEvtTarget(control, new[] { def })); Assert.Fail($"{nameof(RaiseEventTestEvent)} was NOT raised"); }