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