public void ClearSources() { UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock unchangedListenerMock = new UnityEventListenerMock(); subject.Activated.AddListener(activatedListenerMock.Listen); subject.Deactivated.AddListener(deactivatedListenerMock.Listen); subject.ValueChanged.AddListener(changedListenerMock.Listen); subject.ValueUnchanged.AddListener(unchangedListenerMock.Listen); GameObject sourceObject = new GameObject(); BooleanActionMock sourceMock = sourceObject.AddComponent <BooleanActionMock>(); subject.AddSource(sourceMock); Assert.AreEqual(1, subject.ReadOnlySources.Count); sourceMock.Receive(true); Assert.IsTrue(activatedListenerMock.Received); Assert.IsFalse(deactivatedListenerMock.Received); Assert.IsTrue(changedListenerMock.Received); Assert.IsFalse(unchangedListenerMock.Received); subject.ClearSources(); sourceMock.SetIsActivated(false); sourceMock.SetValue(false); activatedListenerMock.Reset(); deactivatedListenerMock.Reset(); changedListenerMock.Reset(); unchangedListenerMock.Reset(); Assert.AreEqual(0, subject.ReadOnlySources.Count); sourceMock.Receive(true); Assert.IsFalse(activatedListenerMock.Received); Assert.IsFalse(deactivatedListenerMock.Received); Assert.IsFalse(changedListenerMock.Received); Assert.IsFalse(unchangedListenerMock.Received); Object.DestroyImmediate(sourceObject); }
public void ActivatedEmitted() { UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock unchangedListenerMock = new UnityEventListenerMock(); subject.Activated.AddListener(activatedListenerMock.Listen); subject.Deactivated.AddListener(deactivatedListenerMock.Listen); subject.ValueChanged.AddListener(changedListenerMock.Listen); subject.ValueUnchanged.AddListener(unchangedListenerMock.Listen); Assert.IsFalse(activatedListenerMock.Received); Assert.IsFalse(deactivatedListenerMock.Received); Assert.IsFalse(changedListenerMock.Received); Assert.IsFalse(unchangedListenerMock.Received); subject.Receive(true); Assert.IsTrue(activatedListenerMock.Received); Assert.IsFalse(deactivatedListenerMock.Received); Assert.IsTrue(changedListenerMock.Received); Assert.IsFalse(unchangedListenerMock.Received); }