public static void Test_EngineScriptComponentFactoryCreate_EngineScriptComponent()
        {
            //arrange
            EngineScriptComponent script     = EngineScriptComponentFactory.Create <TestEngineScriptChild>();
            EngineScriptComponent scriptBase = EngineScriptComponentFactory.Create <TestEngineScriptBase>();

            //assert
            //first
            Assert.NotNull(script);
            Assert.IsInstanceOf <TestEngineScriptChild>(script);
            Assert.IsInstanceOf <TestEngineScriptBase>(script);

            //We have to make sure it gives us a proper one even if we've created and cached a similar one before
            //second
            Assert.NotNull(scriptBase);
            Assert.IsInstanceOf <TestEngineScriptBase>(scriptBase);
            Assert.IsNotInstanceOf <TestEngineScriptChild>(scriptBase);
        }
Exemple #2
0
        public static void Test_Engine_Script_Component_Test_Equality()
        {
            //arrange
            Mock <EngineScriptComponent> engineScriptComponentMock = new Mock <EngineScriptComponent>(MockBehavior.Loose);
            Mock <EngineScriptComponent> engineScriptComponentSecondNonEqualMock = new Mock <EngineScriptComponent>(MockBehavior.Loose);

            engineScriptComponentMock.CallBase = true;
            engineScriptComponentSecondNonEqualMock.CallBase = true;

            EngineScriptComponent engineScriptComponent = engineScriptComponentMock.Object;
            EngineScriptComponent engineScriptComponentSecondNonEqual = engineScriptComponentSecondNonEqualMock.Object;

            //act (cast to interface for equal testing.
            IEngineObject engineObjectInterface         = engineScriptComponent;
            IEngineObject engineObjectInterfaceTwo      = engineScriptComponent;
            IEngineObject engineObjectInterfaceNotEqual = engineScriptComponentSecondNonEqual;

            //this tests equivalence. Not really Important because mostly you won't have references to the underlying script component and can't overload the equals.
            //assert
            Assert.AreEqual(engineScriptComponent, engineObjectInterface);
            Assert.IsTrue(engineScriptComponent == engineObjectInterface);
            Assert.IsTrue(engineObjectInterface == engineScriptComponent);
            Assert.IsTrue(engineObjectInterface.Equals(engineObjectInterfaceTwo));
            Assert.IsTrue(engineObjectInterface == engineObjectInterfaceTwo);

            Assert.IsTrue(engineScriptComponent.Equals(engineObjectInterface) == engineObjectInterface.Equals(engineScriptComponent));
            Assert.IsTrue(engineScriptComponent.Equals(engineObjectInterface));
            Assert.IsTrue(engineObjectInterface.Equals(engineScriptComponent));

            Assert.IsTrue(engineScriptComponentSecondNonEqual != engineScriptComponent);
            Assert.IsTrue(engineScriptComponent != engineScriptComponentSecondNonEqual);
            Assert.IsTrue(engineObjectInterface != engineObjectInterfaceNotEqual);

            Assert.IsTrue(engineScriptComponentSecondNonEqual != (IEngineObject)engineScriptComponent);
            Assert.IsTrue((IEngineObject)engineScriptComponentSecondNonEqual != engineScriptComponent);

            Assert.IsFalse(engineObjectInterface.Equals(engineScriptComponentSecondNonEqual));
            Assert.IsFalse(engineScriptComponent.Equals(engineScriptComponentSecondNonEqual));
        }
Exemple #3
0
 public static void Test_Engine_Script_Component_Base_Constructor()
 {
     //Shouldn't throw or anything.
     EngineScriptComponent engineScriptComponent = Mock.Of <EngineScriptComponent>();
 }