public void RaisesActiveChangedWhenActiveAssigned() { var connected1 = new object(); var connected2 = new object(); IItemsPlacementConnector connector = this.CreateTestObject(); connector.Connect(connected1); connector.Connect(connected2); ActiveChangedEventArgs args = null; connector.ActiveChanged += (sender, e) => args = e; connector.Active = connected1; Assert.IsNull(args.OldValue); Assert.AreEqual(connected1, args.NewValue); connector.Active = connected2; Assert.AreEqual(connected1, args.OldValue); Assert.AreEqual(connected2, args.NewValue); connector.Active = null; Assert.AreEqual(connected2, args.OldValue); Assert.IsNull(args.NewValue); }
/// <summary> /// Raises the event <see cref="ActiveChanged"/>. /// </summary> /// <param name="e">The object with event's arguments.</param> private void OnActiveChanged(ActiveChangedEventArgs e) { var activeChanged = this.ActiveChanged; if (activeChanged != null) { activeChanged(this, e); } }
public void MakesActiveNullWhenActiveIsSingleAndHaveDisconnected() { var connected = new object(); IItemsPlacementConnector connector = this.CreateTestObject(); connector.Connect(connected); connector.Active = connected; ActiveChangedEventArgs args = null; connector.ActiveChanged += (sender, e) => args = e; connector.Disconnect(connected); Assert.IsNull(connector.Active); Assert.AreEqual(connected, args.OldValue); Assert.IsNull(args.NewValue); }
public void ActivatesConnectedWhenViewsCurrentChanged() { var connected1 = new object(); var connected2 = new object(); var view1 = new object(); var view2 = new object(); var match1 = Substitute.For <IViewModelViewMatch>(); var match2 = Substitute.For <IViewModelViewMatch>(); match1.View.Returns(view1); match2.View.Returns(view2); this._viewMatcher.Match(connected1).Returns(match1); this._viewMatcher.Match(connected2).Returns(match2); IItemsPlacementConnector connector = this.CreateTestObject(); connector.Connect(connected1); connector.Connect(connected2); ActiveChangedEventArgs args = null; connector.ActiveChanged += (sender, e) => args = e; connector.Views.MoveCurrentTo(view2); Assert.AreEqual(connected2, connector.Active); Assert.IsNull(args.OldValue); Assert.AreEqual(connected2, args.NewValue); connector.Views.MoveCurrentTo(view1); Assert.AreEqual(connected1, connector.Active); Assert.AreEqual(connected2, args.OldValue); Assert.AreEqual(connected1, args.NewValue); connector.Views.MoveCurrentTo(null); Assert.IsNull(connector.Active); Assert.AreEqual(connected1, args.OldValue); Assert.IsNull(args.NewValue); }
public void ActivatesPreviousWhenActiveIsLastAndHaveDisconnected() { var connected1 = new object(); var connected2 = new object(); var connected3 = new object(); IItemsPlacementConnector connector = this.CreateTestObject(); connector.Connect(connected1); connector.Connect(connected2); connector.Connect(connected3); connector.Active = connected3; ActiveChangedEventArgs args = null; connector.ActiveChanged += (sender, e) => args = e; connector.Disconnect(connected3); Assert.AreEqual(connected2, connector.Active); Assert.AreEqual(connected3, args.OldValue); Assert.AreEqual(connected2, args.NewValue); }