Inheritance: MonoBehaviour
Esempio n. 1
0
        public Program(EventTest test)
        {
            test.OnUserInput += new EventTest.UserInput(Handler);
            test.OnUserInput += new EventTest.UserInput(HandlerMore);

            //test.OnUserInput-=new EventTest.UserInput(Handle);
        }
Esempio n. 2
0
        public void OneEvent()
        {
            var e1 = new EventTest();

            e1.EventId = "Heool World";
            AssertGenerated(e1);
        }
Esempio n. 3
0
        public void AreTheSame()
        {
            var e1 = new EventTest();
            var e2 = new EventTest();

            Assert.Equal(e1.GetHashCode(), e2.GetHashCode());
        }
 private void InitializeVariables()
 {
     inGameShop = transform.GetChild(1).GetComponent <Shop>();
     inGameUI   = transform.parent.parent.GetChild(0).GetComponent <InGameUI>();
     board      = transform.parent.GetComponent <Board>();
     events     = transform.parent.parent.GetComponent <EventTest>();
 }
Esempio n. 5
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     // Используется механизм событий
     // При нажатии на кнопку интерфейса, мы генерируем новое собственное событые
     // определенное выше, а в контроллере подписываемся на него
     EventTest?.Invoke(this, e);
 }
Esempio n. 6
0
        static void Main(string[] args)
        {
            //TpTest tt = new TpTest();
            //tt.Test1();

            //CMTest ct = new CMTest();
            //ct.Test1();
            //SortTest();
            //ProMain();

            //Linq1Test lt = new Linq1Test();
            //lt.Test();

            //MutexTest mt = new MutexTest();
            //mt.Test1();
            try
            {
                EventTest et = new EventTest();
                et.SetNotify("hello world!");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadKey();
        }
Esempio n. 7
0
    public static void Main()
    {
        EventClass ec = new EventClass();
        EventTest  et = new EventTest();

        ec.Status += new EDelegate(et.EventCatch);
        ec.TriggerEvent();
    }
Esempio n. 8
0
 static void Main(string[] args)
 {
     //ObserverTest.Test();
     //ObserverDetegeTest.Test();
     //TestDetegate.Test();
     EventTest.Test();
     Console.ReadLine();
 }
Esempio n. 9
0
            public static void Mains()
            {
                EventTest     e = new EventTest();                             /* 实例化对象,第一次没有触发事件 */
                subscribEvent v = new subscribEvent();                         /* 实例化对象 */

                e.ChangeNum += new EventTest.NumManipulationHandler(v.printf); /* 注册 */
                e.SetValue(7);
                e.SetValue(11);
            }
Esempio n. 10
0
        public void Test_PropertyDoesNotChange_EventRaised()
        {
            // Arrange.
            var test = new EventTest();

            // Act/Assert.
            Assert.Throws <PropertyDoesNotChangeException>(() =>
                                                           AssertThat.PropertyDoesNotChange(test, t => t.IntProperty, () => test.IntProperty = 3));
        }
Esempio n. 11
0
    private void EventAction()
    {
        Debug.Log("イベント受け取ったよ!!");

        //一応 Destroyしておく
        eventTest.RemoveEventListener("event_complete", EventAction);
        eventTest.Destroy();
        eventTest = null;
    }
Esempio n. 12
0
        public void Test_PropertyChanged_EventRaised_WrongProperty()
        {
            // Arrange.
            var test = new EventTest();

            // Act/Assert.
            Assert.Throws <PropertyChangedException>(() =>
                                                     AssertThat.PropertyChanged(test, t => t.IntProperty, () => test.StringProperty = "value"));
        }
    static void Main(string[] args)
    {
        EventTest     e = new EventTest();                             /* Instantiate the object, without triggering event */
        subscribEvent v = new subscribEvent();                         /* Instantiate object */

        e.ChangeNum += new EventTest.NumManipulationHandler(v.printf); /* subscribe the event */
        e.SetValue(7);
        e.SetValue(11);
    }
Esempio n. 14
0
        public void Test_PropertyChanged_EventRaised()
        {
            // Arrange.
            var test = new EventTest();

            // Act/Assert.
            Assert.DoesNotThrow(() =>
                                AssertThat.PropertyChanged(test, t => t.IntProperty, () => test.IntProperty = 3));
        }
Esempio n. 15
0
        public void Test_PropertyDoesNotChange_EventRaised_WrongProperty()
        {
            // Arrange.
            var test = new EventTest();

            // Act/Assert.
            Assert.DoesNotThrow(() =>
                                AssertThat.PropertyDoesNotChange(test, t => t.IntProperty, () => test.StringProperty = "value"));
        }
Esempio n. 16
0
        public void NotSame()
        {
            var e1 = new EventTest();

            e1.EventId = "Heool World";

            var e2 = new EventTest();

            Assert.NotEqual(e1.GetHashCode(), e2.GetHashCode());
        }
Esempio n. 17
0
        public void Run()
        {
            EventTest eTest = new EventTest();

            // 이벤트 핸들러 지정
            eTest.Event2 += new EventHandler(btn_Click);
            eTest.Event2 += HandleOutOfBeans;
            // 이벤트 핸들러 삭제
            eTest.Event2 -= HandleOutOfBeans;
        }
Esempio n. 18
0
        public void Test_Raises_WithEventName_Success()
        {
            // Arrange.
            IEventTest test = new EventTest();

            // Act/Assert.
            Assert.DoesNotThrow(() =>
                                AssertThat.Raises(test, "TestEvent", () => test.OnTestEvent(4)));

            Assert.True(test.EventRaised);
        }
Esempio n. 19
0
 private void InitializeVariables()
 {
     match           = transform.parent.GetComponent <Match>();
     events          = match.GetComponent <EventTest>();
     roundInfo       = transform.GetChild(1).GetChild(3).GetChild(0).GetComponent <Text>();
     middleInfoPanel = transform.GetChild(1).GetChild(4).GetChild(0).GetComponent <Text>();
     sellButton      = transform.GetChild(1).GetChild(6).gameObject;
     shopPanel       = transform.parent.GetChild(1).GetChild(3).GetChild(1).GetChild(0).gameObject;
     GetPlayers();
     GetInfoPanels();
 }
Esempio n. 20
0
        public void Test_PropertyChanged_EventNotRaised()
        {
            // Arrange.
            var test = new EventTest {
                IntProperty = 3
            };

            // Act/Assert.
            Assert.Throws <PropertyChangedException>(() =>
                                                     AssertThat.PropertyChanged(test, t => t.IntProperty, () => test.IntProperty = 3));
        }
Esempio n. 21
0
        public void Test_DoesNotRaise_WithEventSubscriber_Failure()
        {
            // Arrange.
            IEventTest test = new EventTest();

            // Act/Assert.
            Assert.DoesNotThrow(() =>
                                AssertThat.DoesNotRaise(test, t => t.TestEvent += null, () => test.ToString()));

            Assert.False(test.EventRaised);
        }
Esempio n. 22
0
        public void Test_RaisesWithEventArgs_WithEventSubscriber_Failure_EventNotRaised()
        {
            // Arrange.
            IEventTest test = new EventTest();

            // Act/Assert.
            Assert.Throws <RaisesException>(() =>
                                            AssertThat.RaisesWithEventArgs <IEventTest, TestEventArgs>(test, t => t.TestEvent += null, () => test.ToString()));

            Assert.False(test.EventRaised);
        }
Esempio n. 23
0
        public void Test_RaisesWithEventArgs_WithEventName_EventNotRaised()
        {
            // Arrange.
            IEventTest test = new EventTest();

            // Act/Assert.
            Assert.Throws <RaisesException>(() =>
                                            AssertThat.RaisesWithEventArgs <TestEventArgs>(test, "TestEvent", () => test.ToString()));

            Assert.False(test.EventRaised);
        }
Esempio n. 24
0
        public void Test_DoesNotRaise_WithEventSubscriber_Success()
        {
            // Arrange.
            IEventTest test = new EventTest();

            // Act/Assert.
            Assert.Throws <RaisesException>(() =>
                                            AssertThat.DoesNotRaise(test, t => t.TestEvent += null, () => test.OnTestEvent(4)));

            Assert.True(test.EventRaised);
        }
Esempio n. 25
0
        public void Test_DoesNotRaise_WithEventName_Failure()
        {
            // Arrange.
            IEventTest test = new EventTest();

            // Act/Assert.
            Assert.DoesNotThrow(() =>
                                AssertThat.DoesNotRaise(test, "TestEvent", () => test.ToString()));

            Assert.False(test.EventRaised);
        }
Esempio n. 26
0
        public void EventFieldSame()
        {
            var e1 = new EventTest();

            e1.EventId = "Heool World";

            var e2 = new EventTest();

            e2.ApplyEvents(e1.PeekEvents());

            Assert.Equal(e1.EventId, e2.EventId);
        }
Esempio n. 27
0
        public void SnapshotSame()
        {
            var e1 = new EventTest();

            e1.EventId = "Heool World";

            var e2 = new EventTest();

            e2.ApplyEvents(e1.GenerateSnapshot());

            Assert.Equal(e1, e2);
        }
Esempio n. 28
0
        public void EventSame()
        {
            var e1 = new EventTest();

            e1.EventId = "Heool World";

            var e2 = new EventTest();

            e2.ApplyEvents(e1.PeekEvents());

            Assert.Equal(e1.GetHashCode(), e2.GetHashCode());
        }
Esempio n. 29
0
    void Start()
    {
        //まずEventTestゲームオブジェクトを見つける
        GameObject eventTestGameObject = GameObject.Find("EventTest") as GameObject;

        //次にEventTestゲームオブジェクトに張り付いてるEventTestインスタンス(EventTest.cs)を抽出
        eventTest = eventTestGameObject.GetComponent(typeof(EventTest)) as EventTest;
        Debug.Log(eventTest);

        //
        eventTest.AddEventListener("event_complete", EventAction);
    }
Esempio n. 30
0
        public void Test_RaisesWithEventArgs_WithEventSubscriber_Success()
        {
            // Arrange.
            IEventTest test = new EventTest();

            // Act/Assert.
            TestEventArgs args = null;

            Assert.DoesNotThrow(() =>
                                args = AssertThat.RaisesWithEventArgs <IEventTest, TestEventArgs>(test, t => t.TestEvent += null, () => test.OnTestEvent(4)));

            Assert.Equal(4, args.Value);
            Assert.True(test.EventRaised);
        }
Esempio n. 31
0
        public void EventTestUse()
        {
            var eventTest = new EventTest<EventArgsForTest>();
            Event += eventTest.OnTriggered;

            Assert.IsTrue(!eventTest.HasOccured);
            Assert.IsTrue(eventTest.Sender == null);
            Assert.IsTrue(eventTest.Args == null);

            if (Event != null)
                Event.Invoke(this, new EventArgsForTest("Hello World", 10));

            Assert.IsTrue(eventTest.HasOccured);
            Assert.IsTrue(eventTest.Sender == this);
            Assert.IsTrue(eventTest.Args != null);
            Assert.IsTrue(eventTest.Args.Text == "Hello World");
            Assert.IsTrue(eventTest.Args.Number == 10);
        }
Esempio n. 32
0
        public static void PerformanceTest()
        {
            int repeats = 10000000;
            TimeSpan baseTime = TimeSpan.MinValue;

            Action<string, Action> test = (n, t) =>
                {
                    Console.Write(n + ":");
                    DateTime startTime;
                    TimeSpan result;
                    startTime = DateTime.Now;
                    for (int j = 0; j < repeats; j++)
                        t();
                    result = DateTime.Now - startTime;
                    var spaces = new String(' ', 20 - n.Length);
                    if (baseTime == TimeSpan.MinValue)
                    {
                        baseTime = result;
                        Console.WriteLine(spaces + result.ToString());
                    }
                    else
                    {
                        Console.WriteLine(String.Format("{0}{1} {2}ns",
                            spaces,
                            result.ToString(),
                            (result - baseTime).TotalMilliseconds / repeats * 1000000
                            ));
                    }
                };

            RPCTest tester = new RPCTest();
            EventTest et = new EventTest();
            et.ev1 += () => tester.IncI();
            byte[] bytes = Encoding.UTF8.GetBytes("[\"IncI\",null]");
            ClassBox callbox = ClassBox.Get(tester.GetType());
            JsonDecoder d = new JsonDecoder();
            d.Parse(bytes);

            var dynamicFunc = tester.GetType().GetMethod("IncI").CreateDynamicFunc();
            var eventFunc = et.GetType().GetEvent("ev1").CreateDynamicFunc();

            test("Direct", () => tester.IncI());
            test("DynamicFunc", () => dynamicFunc(tester, null));
            test("DynamicFunc(Event)", () => eventFunc(et, null));
            test("CallBox(Direct)", () => callbox.Call(tester, "IncI", null));
            test("CallBox", () => callbox.SerializedCall(tester, d));
            test("CallBox(Full)", () => callbox.SerializedCall(tester, d, bytes));
        }
Esempio n. 33
0
            public static void Main()
            {
                EventTest e = new EventTest(5);
                e.SetValue(7);
                e.SetValue(11);
                Console.ReadKey();

                RangeClass myRangeObject = new RangeClass();
                uint myTotal;

                // Question #15 - jhow to initialize a strng without needing backslash each \ character - use the @ modifier
                //Initialize with a regular string literal.
                string oldPath = "c:\\Program Files\\Microsoft Visual Studio 8.0";
                // Initialize with a verbatim string literal.
                string newPath = @"c:\Program Files\Microsoft Visual Studio 9.0";

                myTotal = myRangeObject.AddRange(1, 4);
                Console.WriteLine("Total from {0} to {1} is: {2}", 1, 4, myTotal);
                Console.ReadKey();
            }