コード例 #1
0
        public IEnumerator AttachPasses()
        {
            var recorder = new GameObject().AddComponent <InputRecorderMonoBehaviour>();
            var inputObj = recorder.gameObject.AddComponent <AppendAxisButtonInputData>();

            yield return(null);

            var names = new string[] { "Horizontal", "Vertical" };

            inputObj.AddEnabledAxisButtons(names);

            inputObj.Attach();
            var frameInputData = recorder.UseRecorder.FrameDataRecorder as FrameInputData;

            Assert.IsTrue(frameInputData.ContainsChildRecorder <AxisButtonFrameInputData>());

            var axisButtonData = frameInputData.GetChildRecorderEnumerable()
                                 .Select(_t => _t.child)
                                 .OfType <AxisButtonFrameInputData>()
                                 .FirstOrDefault();

            AssertionUtils.AssertEnumerableByUnordered(
                names
                , axisButtonData.ObservedButtonNames
                , ""
                );
        }
コード例 #2
0
        public void RemovePasses()
        {
            var helper = new HashSetHelper <int>();

            var testData = new int[] {
                100, 200
            };

            foreach (var d in testData)
            {
                helper.Add(d);
            }

            helper.Remove(testData[0]);
            AssertionUtils.AssertEnumerableByUnordered(
                new int[] { testData[1] }
                , helper.Items
                , ""
                );

            helper.Remove(testData[1]);
            AssertionUtils.AssertEnumerableByUnordered(
                new int[] { }
                , helper.Items
                , ""
                );
        }
コード例 #3
0
        public void OnRemovedInRemoveItemsPasses()
        {
            var helper       = new HashSetHelper <int>();
            var recievedList = new List <int>();
            var counter      = 0;

            helper.OnRemoved.Add((v) => { recievedList.Add(v); counter++; });


            var testData = Enumerable.Range(0, 10);

            helper.Add(testData);

            helper.Remove(testData.Where(_v => _v % 2 == 0));

            Assert.AreEqual(testData.Count() / 2, counter);
            AssertionUtils.AssertEnumerableByUnordered(
                testData.Where(_v => _v % 2 == 0),
                recievedList,
                ""
                );
            AssertionUtils.AssertEnumerableByUnordered(
                testData.Where(_v => _v % 2 != 0),
                helper.Items,
                ""
                );
        }
コード例 #4
0
ファイル: TestKeyCodeDefines.cs プロジェクト: tositeru/hinode
        public void AllSupportedKeyCodesPasses()
        {
            var ignoreKeyCodes = new HashSet <KeyCode>()
            {
                KeyCode.RightApple,
                KeyCode.LeftApple,
            };

            // 同値のEnumに対応するために使用している
            var ignoreCounter = new Dictionary <KeyCode, int>();

            AssertionUtils.AssertEnumerableByUnordered(
                System.Enum.GetValues(typeof(KeyCode))
                .GetEnumerable <KeyCode>()
                .Where(_k => {
                if (!ignoreKeyCodes.Contains(_k))
                {
                    return(true);
                }
                if (ignoreCounter.ContainsKey(_k))
                {
                    return(false);
                }
                ignoreCounter.Add(_k, 1);
                return(true);
            }).ToArray(),
                KeyCodeDefines.AllSupportedKeyCodes,
                ""
                );
        }
コード例 #5
0
ファイル: TestKeyCodeDefines.cs プロジェクト: tositeru/hinode
 public void KeypadKeyCodesPasses()
 {
     AssertionUtils.AssertEnumerableByUnordered(
         new KeyCode[] {
         KeyCode.Keypad0,
         KeyCode.Keypad1,
         KeyCode.Keypad2,
         KeyCode.Keypad3,
         KeyCode.Keypad4,
         KeyCode.Keypad5,
         KeyCode.Keypad6,
         KeyCode.Keypad7,
         KeyCode.Keypad8,
         KeyCode.Keypad9,
         KeyCode.KeypadPeriod,
         KeyCode.KeypadDivide,
         KeyCode.KeypadMultiply,
         KeyCode.KeypadMinus,
         KeyCode.KeypadPlus,
         KeyCode.KeypadEnter,
         KeyCode.KeypadEquals
     }
         , KeyCodeDefines.KeypadKeyCodes
         , ""
         );
 }
コード例 #6
0
        public void AddItemsWhenOccurExceptionPasses()
        {
            var helper       = new HashSetHelper <int>();
            var recievedList = new List <int>();
            var counter      = 0;

            helper.OnAdded.Add((v) => {
                if (v % 2 == 0)
                {
                    throw new System.Exception();
                }
                recievedList.Add(v); counter++;
            });


            var testData = Enumerable.Range(0, 10);

            Assert.DoesNotThrow(() => {
                helper.Add(testData);
            });

            Assert.AreEqual(testData.Count() / 2, counter);
            AssertionUtils.AssertEnumerableByUnordered(
                testData.Where(_v => _v % 2 != 0),
                recievedList,
                ""
                );
            AssertionUtils.AssertEnumerableByUnordered(
                testData,
                helper.Items,
                ""
                );
        }
コード例 #7
0
        public IEnumerator AttachPasses()
        {
            var recorder = new GameObject().AddComponent <InputRecorderMonoBehaviour>();
            var inputObj = recorder.gameObject.AddComponent <AppendKeyboardInputData>();

            yield return(null);

            var keycodes = new KeyCode[] { KeyCode.A, KeyCode.F1 };

            inputObj.AddEnabledKeyCodes(keycodes);

            inputObj.Attach();
            var frameInputData = recorder.UseRecorder.FrameDataRecorder as FrameInputData;

            Assert.IsTrue(frameInputData.ContainsChildRecorder <KeyboardFrameInputData>());

            var inputData = frameInputData.GetChildRecorderEnumerable()
                            .Select(_t => _t.child)
                            .OfType <KeyboardFrameInputData>()
                            .FirstOrDefault();

            AssertionUtils.AssertEnumerableByUnordered(
                keycodes
                , inputData.ObservedKeyCodes
                , ""
                );
        }
コード例 #8
0
ファイル: TestKeyCodeDefines.cs プロジェクト: tositeru/hinode
 public void AlphabetKeyCodesPasses()
 {
     AssertionUtils.AssertEnumerableByUnordered(
         new KeyCode[] {
         KeyCode.A,
         KeyCode.B,
         KeyCode.C,
         KeyCode.D,
         KeyCode.E,
         KeyCode.F,
         KeyCode.G,
         KeyCode.H,
         KeyCode.I,
         KeyCode.J,
         KeyCode.K,
         KeyCode.L,
         KeyCode.M,
         KeyCode.N,
         KeyCode.O,
         KeyCode.P,
         KeyCode.Q,
         KeyCode.R,
         KeyCode.S,
         KeyCode.T,
         KeyCode.U,
         KeyCode.V,
         KeyCode.W,
         KeyCode.X,
         KeyCode.Y,
         KeyCode.Z
     }
         , KeyCodeDefines.AlphabetKeyCodes
         , ""
         );
 }
コード例 #9
0
        public IEnumerator Entry_Passes()
        {
            var manager = LayoutManagerComponent.Instance;

            var layoutTarget = CreateLayoutTargetComponent("__test");

            manager.Entry(layoutTarget);

            TestLayoutManager.AssertRootsInLayoutManagerGroup(manager.Manager
                                                              , new ILayoutTarget[] {
                layoutTarget.LayoutTarget
            }
                                                              );
            var group = manager.Manager.Groups.First(_g => _g.Root == layoutTarget.LayoutTarget);

            TestLayoutManager.AssertLayoutManagerGroup(group, layoutTarget.LayoutTarget, group.Priority, null, null,
                                                       new ILayoutTarget[] {
                layoutTarget.LayoutTarget
            }
                                                       );


            AssertionUtils.AssertEnumerableByUnordered(
                new LayoutTargetComponent[] {
                layoutTarget
            }
                , manager.Targets
                , ""
                );
            yield return(null);
        }
コード例 #10
0
ファイル: TestLabels.cs プロジェクト: tositeru/hinode
        public void Add_Passes()
        {
            var labels = new Labels();

            labels.Add("apple");
            AssertionUtils.AssertEnumerableByUnordered(
                new string[] { "apple" }
                , labels
                , ""
                );
        }
コード例 #11
0
ファイル: TestLabels.cs プロジェクト: tositeru/hinode
        public void AddRange_StringArray_Passes()
        {
            var labels = new Labels();

            labels.AddRange("apple", "orange", "grape");
            AssertionUtils.AssertEnumerableByUnordered(
                new string[] { "apple", "orange", "grape" }
                , labels
                , ""
                );
        }
コード例 #12
0
ファイル: TestKeyCodeDefines.cs プロジェクト: tositeru/hinode
 public void ArrowKeyCodesPasses()
 {
     AssertionUtils.AssertEnumerableByUnordered(
         new KeyCode[] {
         KeyCode.UpArrow,
         KeyCode.DownArrow,
         KeyCode.RightArrow,
         KeyCode.LeftArrow
     }
         , KeyCodeDefines.ArrowKeyCodes
         , ""
         );
 }
コード例 #13
0
        public void GetEnumeratorPasses()
        {
            var helper   = new HashSetHelper <int>();
            var testData = new int[] { 10, 20, 40 };

            helper.Add(testData);

            AssertionUtils.AssertEnumerableByUnordered(
                testData,
                helper,
                ""
                );
        }
コード例 #14
0
        public IEnumerator ClearEnabledKeyCodesPasses()
        {
            var inputObj = new GameObject().AddComponent <AppendKeyboardInputData>();
            var keycodes = new KeyCode[] { KeyCode.A, KeyCode.F1 };

            inputObj.AddEnabledKeyCodes(keycodes);
            inputObj.ClearEnabledKeyCodes();
            AssertionUtils.AssertEnumerableByUnordered(
                new KeyCode[] { }
                , inputObj.EnabledKeyCodes
                , ""
                );
            yield return(null);
        }
コード例 #15
0
ファイル: TestLabels.cs プロジェクト: tositeru/hinode
        public void Constructor_StringEnumerable_Passes()
        {
            var strs = new List <string>()
            {
                "apple", "orange", "grape"
            };
            var labels = new Labels(strs);

            AssertionUtils.AssertEnumerableByUnordered(
                strs
                , labels
                , ""
                );
        }
コード例 #16
0
        public IEnumerator ClearEnabledAxisButtonsPasses()
        {
            var inputObj = new GameObject().AddComponent <AppendAxisButtonInputData>();
            var names    = new string[] { "Horizontal", "Vertical" };

            inputObj.AddEnabledAxisButtons(names);
            inputObj.ClearEnabledAxisButton();
            AssertionUtils.AssertEnumerableByUnordered(
                new string[] { }
                , inputObj.EnabledAxisButtons
                , ""
                );
            yield return(null);
        }
コード例 #17
0
        public void CallMethods_Passes()
        {
            var inst = new CallMethodsTest();
            var type = inst.GetType();

            var methods = type.GetMethods()
                          .CallMethods(inst, typeof(string), 100);

            AssertionUtils.AssertEnumerableByUnordered(
                new object[] { "100" }
                , methods
                , ""
                );
        }
コード例 #18
0
        public void RemoveItemsPasses()
        {
            var helper   = new HashSetHelper <int>();
            var testData = Enumerable.Range(0, 10);

            helper.Add(testData);

            helper.Remove(testData);
            AssertionUtils.AssertEnumerableByUnordered(
                new int[] { },
                helper.Items,
                ""
                );
        }
コード例 #19
0
ファイル: TestLabels.cs プロジェクト: tositeru/hinode
        public void Remove_Passes()
        {
            var labels = new Labels();
            var str    = "str";

            labels.AddRange(str, "apple");

            labels.Remove(str);

            AssertionUtils.AssertEnumerableByUnordered(
                new string[] { "apple" }
                , labels
                , ""
                );
        }
コード例 #20
0
ファイル: TestLabels.cs プロジェクト: tositeru/hinode
        public void Add_IgnoreInvalid_Passes()
        {
            var strs = new List <string>()
            {
                "apple", "orange", "grape", "", null, "    "
            };
            var labels = new Labels();

            labels.AddRange(strs);
            AssertionUtils.AssertEnumerableByUnordered(
                strs.Where(_s => Labels.IsValid(_s))
                , labels
                , ""
                );
        }
コード例 #21
0
        public IEnumerator CreateInputDataPasses()
        {
            var inputObj = new GameObject().AddComponent <AppendKeyboardInputData>();
            var keycodes = new KeyCode[] { KeyCode.A, KeyCode.F1 };

            inputObj.AddEnabledKeyCodes(keycodes);

            var inputData = inputObj.CreateInputData() as KeyboardFrameInputData;

            AssertionUtils.AssertEnumerableByUnordered(
                keycodes
                , inputData.ObservedKeyCodes
                , ""
                );
            yield return(null);
        }
コード例 #22
0
        public IEnumerator CreateInputDataPasses()
        {
            var inputObj = new GameObject().AddComponent <AppendAxisButtonInputData>();
            var names    = new string[] { "Horizontal", "Vertical" };

            inputObj.AddEnabledAxisButtons(names);

            var axisButtonData = inputObj.CreateInputData() as AxisButtonFrameInputData;

            AssertionUtils.AssertEnumerableByUnordered(
                names
                , axisButtonData.ObservedButtonNames
                , ""
                );
            yield return(null);
        }
コード例 #23
0
ファイル: TestKeyCodeDefines.cs プロジェクト: tositeru/hinode
 public void MouseKeyCodesPasses()
 {
     AssertionUtils.AssertEnumerableByUnordered(
         new KeyCode[] {
         KeyCode.Mouse0,
         KeyCode.Mouse1,
         KeyCode.Mouse2,
         KeyCode.Mouse3,
         KeyCode.Mouse4,
         KeyCode.Mouse5,
         KeyCode.Mouse6
     }
         , KeyCodeDefines.MouseKeyCodes
         , ""
         );
 }
コード例 #24
0
        public void OnChangedCountInClearWhenOccurExceptionPasses()
        {
            var helper = new HashSetHelper <int>();

            helper.Add(1, 2, 3);
            helper.OnChangedCount.Add((_helper, _count) => {
                throw new System.NotImplementedException();
            });

            helper.Clear();

            AssertionUtils.AssertEnumerableByUnordered(
                new int[] { },
                helper.Items,
                ""
                );
        }
コード例 #25
0
        public void GetMatchArgsAndReturnType_InheritedType_Passes()
        {
            var type = typeof(GetMatchArgsAndReturnTypeTest);

            var methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance);

            {
                AssertionUtils.AssertEnumerableByUnordered(
                    new MethodInfo[]
                {
                    type.GetMethod("Func5")
                }
                    , methods.GetMatchArgsAndReturnType(typeof(GetMatchArgsAndReturnTypeTest.B), typeof(GetMatchArgsAndReturnTypeTest.A))
                    , "Fail Full Match Type..."
                    );

                AssertionUtils.AssertEnumerableByUnordered(
                    new MethodInfo[]
                {
                    type.GetMethod("Func5")
                }
                    , methods.GetMatchArgsAndReturnType(typeof(GetMatchArgsAndReturnTypeTest.B), typeof(GetMatchArgsAndReturnTypeTest.B))
                    , "Fail Inherited Type..."
                    );

                AssertionUtils.AssertEnumerableByUnordered(
                    new MethodInfo[]
                {
                    type.GetMethod("Func5")
                }
                    , methods.GetMatchArgsAndReturnType(typeof(GetMatchArgsAndReturnTypeTest.B), typeof(GetMatchArgsAndReturnTypeTest.I))
                    , "Fail Interface Type..."
                    );
            }
            Logger.Log(Logger.Priority.High, () => $"Success Enable Case!");

            {
                AssertionUtils.AssertEnumerableByUnordered(
                    new MethodInfo[] { }
                    , methods.GetMatchArgsAndReturnType(typeof(GetMatchArgsAndReturnTypeTest.A), typeof(GetMatchArgsAndReturnTypeTest.A))
                    , "Fail ..."
                    );
            }
            Logger.Log(Logger.Priority.High, () => $"Success Disable Case!");
        }
コード例 #26
0
        public void GetMatchArgsAndReturnType_Passes()
        {
            var type = typeof(GetMatchArgsAndReturnTypeTest);

            var methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance);

            AssertionUtils.AssertEnumerableByUnordered(
                new MethodInfo[]
            {
                type.GetMethod("Func1")
            }
                , methods.GetMatchArgsAndReturnType(typeof(void))
                , ""
                );
            AssertionUtils.AssertEnumerableByUnordered(
                new MethodInfo[]
            {
                type.GetMethod("Func2")
            }
                , methods.GetMatchArgsAndReturnType(typeof(int))
                , ""
                );
            AssertionUtils.AssertEnumerableByUnordered(
                new MethodInfo[]
            {
                type.GetMethod("Func3")
            }
                , methods.GetMatchArgsAndReturnType(typeof(void), typeof(int))
                , ""
                );
            AssertionUtils.AssertEnumerableByUnordered(
                new MethodInfo[]
            {
                type.GetMethod("Func4")
            }
                , methods.GetMatchArgsAndReturnType(typeof(string), typeof(int))
                , ""
                );

            AssertionUtils.AssertEnumerableByUnordered(
                new MethodInfo[] {}
                , methods.GetMatchArgsAndReturnType(typeof(void), typeof(string), typeof(string))
                , ""
                );
        }
コード例 #27
0
        public void OnChangedCountInRemoveWhenOccurExceptionPasses()
        {
            var helper = new HashSetHelper <int>();
            var value  = 1;

            helper.Add(value, 2, 3, 4);
            helper.OnChangedCount.Add((_helper, _count) => {
                throw new System.NotImplementedException();
            });

            helper.Remove(value);

            AssertionUtils.AssertEnumerableByUnordered(
                new int[] { 2, 3, 4 },
                helper.Items,
                ""
                );
        }
コード例 #28
0
        public void OnChangedCountInAddItemsWhenOccurExceptionPasses()
        {
            var helper = new HashSetHelper <int>();

            helper.OnChangedCount.Add((_helper, _count) => {
                throw new System.NotImplementedException();
            });

            var testData = new int[] { 1, 2, 3 };

            helper.Add(testData);

            AssertionUtils.AssertEnumerableByUnordered(
                testData,
                helper.Items,
                ""
                );
        }
コード例 #29
0
        public void TestUnityEventExtensionsSimplePasses()
        {
            UnityAction action  = () => { };
            UnityAction action2 = () => { };

            var events = new UnityEvent();

            events.AddListener(action);
            events.AddListener(action2);

            AssertionUtils.AssertEnumerableByUnordered(
                new System.Delegate[]
            {
                action, action2
            }
                , events.GetInvocationList()
                , ""
                );
        }
コード例 #30
0
ファイル: TestKeyCodeDefines.cs プロジェクト: tositeru/hinode
 public void SymbolKeyCodesPasses()
 {
     AssertionUtils.AssertEnumerableByUnordered(
         new KeyCode[] {
         KeyCode.Tab,
         KeyCode.Space,
         KeyCode.Exclaim,
         KeyCode.DoubleQuote,
         KeyCode.Hash,
         KeyCode.Dollar,
         KeyCode.Percent,
         KeyCode.Ampersand,
         KeyCode.Quote,
         KeyCode.LeftParen,
         KeyCode.RightParen,
         KeyCode.Asterisk,
         KeyCode.Plus,
         KeyCode.Comma,
         KeyCode.Minus,
         KeyCode.Period,
         KeyCode.Slash,
         KeyCode.Colon,
         KeyCode.Semicolon,
         KeyCode.Less,
         KeyCode.Equals,
         KeyCode.Greater,
         KeyCode.Question,
         KeyCode.At,
         KeyCode.LeftBracket,
         KeyCode.Backslash,
         KeyCode.RightBracket,
         KeyCode.Caret,
         KeyCode.Underscore,
         KeyCode.BackQuote,
         KeyCode.LeftCurlyBracket,
         KeyCode.Pipe,
         KeyCode.RightCurlyBracket,
         KeyCode.Tilde
     }
         , KeyCodeDefines.SymbolKeyCodes
         , ""
         );
 }