Exemplo n.º 1
0
        public void GuidComponent_AddsToGuidManager_WhenInstantiated()
        {
            var guidComponent = GuidComponentTests.CreateNewGuid();

            Assert.AreEqual(guidComponent.GetGuid(), guidManagerMock.AddGuidArgument);
            Assert.AreEqual(guidComponent.gameObject, guidManagerMock.AddGameObjectArgument);
        }
        public void GuidReference_ReturnsGameObject_WhenValidReference()
        {
            GuidComponent newGuid   = GuidComponentTests.CreateNewGuid();
            GuidReference reference = new GuidReference(newGuid.GetGuid());

            guidManagerMock.ResolveGuidResult = newGuid.gameObject;
            Assert.AreEqual(newGuid.gameObject, reference.gameObject);
        }
Exemplo n.º 3
0
        public void GuidComponent_RemovesToGuidManager_WhenDestroyed()
        {
            var guidComponent = GuidComponentTests.CreateNewGuid();
            var guid          = guidComponent.GetGuid();

            Object.DestroyImmediate(guidComponent.gameObject);
            Assert.AreEqual(guid, guidManagerMock.RemoveGuidArgument);
        }
        public void GuidReference_ReturnsNull_WhenTargetGameObjectDestroyed()
        {
            GuidComponent newGuid   = GuidComponentTests.CreateNewGuid();
            GuidReference reference = new GuidReference(newGuid.GetGuid());

            // todo
            Object.DestroyImmediate(newGuid);

            Assert.IsNull(reference.gameObject);
        }
        public void RemovedEvent_Raises_WhenGuidRemoved()
        {
            var           guidComponent = GuidComponentTests.CreateNewGuid();
            GuidReference reference     = new GuidReference(guidComponent.GetGuid());

            reference.RequestResolve();
            int eventRaiseCount = 0;

            reference.Removed += () => eventRaiseCount++;
            guidManagerMock.InvokeRemoveCallback();
            // main test
            Assert.AreEqual(1, eventRaiseCount);
        }
        public void AddedEvent_Raises_WhenGuidAdded()
        {
            var           guidComponent        = GuidComponentTests.CreateNewGuid();
            GuidReference reference            = new GuidReference(guidComponent.GetGuid());
            int           addedEventRaiseCount = 0;
            GameObject    addedEventResult     = null;

            reference.Added += gameObject =>
            {
                addedEventRaiseCount++;
                addedEventResult = gameObject;
            };
            reference.RequestResolve();

            guidManagerMock.InvokeAddCallback(guidComponent.gameObject);

            // main test
            Assert.AreEqual(1, addedEventRaiseCount);
            Assert.AreEqual(guidComponent.gameObject, addedEventResult);
        }