Пример #1
0
        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);
        }
Пример #2
0
 public void SetUp()
 {
     containingObject = new GameObject();
     subject          = containingObject.AddComponent <BooleanActionMock>();
 }