Exemple #1
0
        public void Test_Can_Register_Callback_Without_Throw(long guid, EntityDataFieldType fieldType)
        {
            //arrange
            EntityDataChangeCallbackManager callbackManager = new EntityDataChangeCallbackManager();

            Assert.DoesNotThrow(() => callbackManager.RegisterCallback <float>(new NetworkEntityGuid((ulong)guid), fieldType, (eg, args) => { }));
        }
Exemple #2
0
        public void Test_Can_Registered_Multiple_Seperate_Callbacks_Called_Be_Called_Only()
        {
            //arrange
            Mock <IEnumerable> testCallback  = new Mock <IEnumerable>(MockBehavior.Loose);
            Mock <IEnumerable> testCallback2 = new Mock <IEnumerable>(MockBehavior.Loose);
            EntityDataChangeCallbackManager callbackManager = new EntityDataChangeCallbackManager();

            //act
            callbackManager.RegisterCallback <float>(new NetworkEntityGuid((ulong)5), EntityDataFieldType.EntityCurrentHealth, (eg, args) =>
            {
                //Call so we can check for test purposes
                testCallback.Object.GetEnumerator();
            });

            //Of the same type
            callbackManager.RegisterCallback <float>(new NetworkEntityGuid((ulong)6), EntityDataFieldType.EntityCurrentHealth, (eg, args) =>
            {
                //Call so we can check for test purposes
                testCallback2.Object.GetEnumerator();
            });

            //Call twice
            callbackManager.InvokeChangeEvents(new NetworkEntityGuid((ulong)5), EntityDataFieldType.EntityCurrentHealth, 5);
            callbackManager.InvokeChangeEvents(new NetworkEntityGuid((ulong)6), EntityDataFieldType.EntityCurrentHealth, 5);

            //assert
            testCallback.Verify(enumerable => enumerable.GetEnumerator(), Times.Exactly(1));
            testCallback2.Verify(enumerable => enumerable.GetEnumerator(), Times.Exactly(1));
        }
Exemple #3
0
        public void Test_Can_ServiceCallbacks_For_Empty_CallbackRegister()
        {
            //arrange
            EntityDataChangeCallbackManager callbackManager = new EntityDataChangeCallbackManager();

            //assert
            Assert.DoesNotThrow(() => callbackManager.InvokeChangeEvents(NetworkEntityGuid.Empty, EntityDataFieldType.EntityCurrentHealth, 5));
        }
Exemple #4
0
        public void Test_Can_Registered_Callback_Called(long guid, EntityDataFieldType fieldType)
        {
            //arrange
            Mock <IEnumerable> testCallback = new Mock <IEnumerable>(MockBehavior.Loose);
            EntityDataChangeCallbackManager callbackManager = new EntityDataChangeCallbackManager();

            //act
            callbackManager.RegisterCallback <float>(new NetworkEntityGuid((ulong)guid), fieldType, (eg, args) =>
            {
                //Call so we can check for test purposes
                testCallback.Object.GetEnumerator();
            });

            callbackManager.InvokeChangeEvents(new NetworkEntityGuid((ulong)guid), fieldType, 5);

            //assert
            testCallback.Verify(enumerable => enumerable.GetEnumerator(), Times.Once);
        }