Ejemplo n.º 1
0
    private void Awake()
    {
        Test = 10;

        string hotfixMonoBehaviourFullName = "HotFix_Project." + m_HotfixMonoBehaviourName;

        if (HotfixManager.Instance.ILRuntimeMode)
        {
            IType type = HotfixManager.Instance.Appdomain.LoadedTypes[hotfixMonoBehaviourFullName];
            HotfixInstance = ((ILType)type).Instantiate();

            m_Start  = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Start", 0);
            m_Update = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Update", 0);
            m_Test   = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Test", 1);

            HotfixManager.Instance.Appdomain.Invoke(hotfixMonoBehaviourFullName, "Awake", HotfixInstance, this);
        }
        else
        {
            HotfixInstance = HotfixManager.Instance.HotfixAssembly.CreateInstance(hotfixMonoBehaviourFullName);

            InstanceMethod awake = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Awake", new Type[] { typeof(MainMonoBehaviour) });
            m_Start  = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Start", null);
            m_Update = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Update", null);
            m_Test   = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Test", new Type[] { typeof(int) });

            awake?.Invoke(this);
        }
        m_Test.Invoke(5);
    }
Ejemplo n.º 2
0
        public void InvokeParameterlessMethodReturnsCorrectResult(object owner)
        {
            // Arrange
            var method = owner.GetType().GetMethod("GetHashCode", Type.EmptyTypes);
            var sut    = new InstanceMethod(method, owner);
            // Act
            var result = sut.Invoke(Enumerable.Empty <object>());
            // Assert
            var expected = owner.GetHashCode();

            Assert.Equal(expected, result);
        }
Ejemplo n.º 3
0
        public void InvokeMethodWithParametersReturnsCorrectResult(int x, int y)
        {
            // Arrange
            var owner  = Comparer <int> .Default;
            var method = owner.GetType().GetMethod("Compare");
            var sut    = new InstanceMethod(method, owner);
            // Act
            var result = sut.Invoke(new object[] { x, y });
            // Assert
            var expected = owner.Compare(x, y);

            Assert.Equal(expected, result);
        }
Ejemplo n.º 4
0
        public void InvokeParameterlessMethodReturnsCorrectResult(object owner)
        {
            // Fixture setup
            var method = owner.GetType().GetMethod("GetHashCode", Type.EmptyTypes);
            var sut    = new InstanceMethod(method, owner);
            // Exercise system
            var result = sut.Invoke(Enumerable.Empty <object>());
            // Verify outcome
            var expected = owner.GetHashCode();

            Assert.Equal(expected, result);
            // Teardown
        }
Ejemplo n.º 5
0
        public void InvokeMethodWithParametersReturnsCorrectResult(int x, int y)
        {
            // Fixture setup
            var owner  = Comparer <int> .Default;
            var method = owner.GetType().GetMethod("Compare");
            var sut    = new InstanceMethod(method, owner);
            // Exercise system
            var result = sut.Invoke(new object[] { x, y });
            // Verify outcome
            var expected = owner.Compare(x, y);

            Assert.Equal(expected, result);
            // Teardown
        }
Ejemplo n.º 6
0
 void Update()
 {
     m_Update?.Invoke();
 }
Ejemplo n.º 7
0
 void Start()
 {
     m_Start?.Invoke();
 }
Ejemplo n.º 8
0
 public void InvokeMethodWithParametersReturnsCorrectResult(int x, int y)
 {
     // Fixture setup
     var owner = Comparer<int>.Default;
     var method = owner.GetType().GetMethod("Compare");
     var sut = new InstanceMethod(method, owner);
     // Exercise system
     var result = sut.Invoke(new object[] { x, y });
     // Verify outcome
     var expected = owner.Compare(x, y);
     Assert.Equal(expected, result);
     // Teardown
 }
Ejemplo n.º 9
0
 public void InvokeParameterlessMethodReturnsCorrectResult(object owner)
 {
     // Fixture setup
     var method = owner.GetType().GetMethod("GetHashCode");
     var sut = new InstanceMethod(method, owner);
     // Exercise system
     var result = sut.Invoke(Enumerable.Empty<object>());
     // Verify outcome
     var expected = owner.GetHashCode();
     Assert.Equal(expected, result);
     // Teardown
 }