// Read inventory contents and arrange screen elements to display that
    public void UpdateGuiElements(Inventory inv)
    {
        int slot = 0;

        foreach (var item in inv.items)
        {
            var itemBox = transform.FindChild(slot.ToString());
            Assert.IsNotNull(itemBox);

            Image itemBoxImage = itemBox.GetComponent <Image> ();
            Assert.IsNotNull(itemBoxImage);

            itemBoxImage.sprite = item.GetSprite();
            UpdateCount(itemBox, item);

            slot++;
        }
        for (; slot < MAX_ITEMS; slot++)
        {
            var itemBox = transform.FindChild(slot.ToString());
            Assert.IsNotNull(itemBox);

            Image itemBoxImage = itemBox.GetComponent <Image> ();
            Assert.IsNotNull(itemBoxImage);

            itemBoxImage.sprite = null;
        }
    }
Example #2
0
 public CacheUIntString
 (
     Func <uint, uint> hashFunction,
     Func <uint, string> hashToString,
     uint initMin,
     uint initMax,
     uint initStep
 )
     : base(hashFunction, hashToString, Convert.ToInt32(initStep != 0 ? (initMax - initMin) / initStep : 0))
 {
     if (initStep != 0)
     {
         for (uint key = initMin; key <= initMax; key += initStep)
         {
             uint   hash = hashFunction(key);
             string str  = hashToString(hash);
             Assert.IsNotNull(str);
             if (_table.ContainsKey(hash) == false)
             {
                 _table.Add(hash, str);
             }
             else
             {
                 Debug.LogWarning($"Redundant key: { key }, where hash: { hash }");
             }
         }
     }
 }
    // Diff チェック関数
    private void DiffChecker(string taskStr, string inputStr, List <Diff> expectedDiffs)
    {
        var lsClass = typeof(LongSentenceScript);

        Assert.IsNotNull(lsClass);
        MethodInfo diffParser = lsClass.GetMethod("GetDiff", BindingFlags.NonPublic | BindingFlags.Static);

        Assert.IsNotNull(diffParser);

        // diff 取得
        var diffList = (List <Diff>)diffParser.Invoke(this, new object[] { taskStr, inputStr });

        // debug 用
        for (int i = 0; i < diffList.Count; ++i)
        {
            var actual = diffList[i];
            Debug.Log("[" + actual.op + ", " + actual.before + ", " + actual.after + "]");
        }
        Assert.AreEqual(diffList.Count, expectedDiffs.Count);

        // 個別に diff をチェック
        for (int i = 0; i < diffList.Count; ++i)
        {
            var expected = expectedDiffs[i];
            var actual   = diffList[i];
            Debug.Log("op : [" + expected.op + ", " + actual.op + "]");
            Debug.Log("before : [" + expected.before + ", " + actual.before + "]");
            Debug.Log("after : [" + expected.after + ", " + actual.after + "]");
            Assert.IsTrue((expected.op).Equals(actual.op));
            Assert.IsTrue((expected.before).Equals(actual.before));
            Assert.IsTrue((expected.after).Equals(actual.after));
        }
    }
Example #4
0
 public CacheStrings(Func <KEY, HASH> hashFunction, Func <HASH, string> hashToString, int initialDictCapacity)
 {
     Assert.IsNotNull(hashFunction);
     Assert.IsNotNull(hashToString);
     _table        = new Dictionary <HASH, string>(initialDictCapacity);
     _hashFunction = hashFunction;
     _hashToString = hashToString;
 }
    private string LoadTaskData(string fileName)
    {
        var cls = typeof(LongSentenceScript);

        Assert.IsNotNull(cls);
        MethodInfo loader = cls.GetMethod("LoadSentenceData", BindingFlags.NonPublic | BindingFlags.Static);
        var        ret    = (string)loader.Invoke(this, new object[] { fileName });

        return(ret);
    }
    void Start()
    {
        anim = GetComponent <Animator>();

        inventory = new Inventory();
        inventory.AddNoStack(Item.Create(Item.PresetId.OldStonePick));

        Assert.IsNotNull(guiInventory);
        guiInventory.UpdateGuiElements(inventory);
    }
Example #7
0
    protected override void Awake()
    {
        base.Awake();

        IsClicking       = false;
        IsDragging       = false;
        CurrentlyClicked = null;

        Assert.IsNotNull(MainCam, "'MainCam' field in InputManager");
    }
Example #8
0
    public IEnumerator ModalTest2()
    {
        using (var tester = new Tester())
        {
            BootParam prm     = new BootParam();
            var       counter = new Counter();
            prm.BootContents.Add(new MainTestParam {
                Counter = counter
            });
            yield return(WrapTask(tester.Controller.Boot(prm)));


            var content  = tester.Controller.Get <MainTestContent>();
            var modalRet = content.RunModal(() => true);

            Exception error = null;
            bool      ret   = false;
            try
            {
                content.Append <SubContent1>(new SubParam1
                {
                    Counter = counter
                }).ContinueWith(x => ret = true);
            }
            catch (Exception ex)
            {
                error = ex;
            }
            //モーダル中の追加はエラーになる
            Assert.IsNotNull(error);
            Assert.IsFalse(ret);

            error = null;

            try
            {
                content.Switch <SubContent1>(new SubParam1
                {
                    Counter = counter
                }).ContinueWith(x => ret = true);
            }
            catch (Exception ex)
            {
                error = ex;
            }
            //モーダル中の変更はエラーになる
            Assert.IsNotNull(error);
            Assert.IsFalse(ret);

            yield return(WrapTask(modalRet));

            Assert.AreEqual(true, modalRet.Result);
        }
    }
Example #9
0
    private void Awake()
    {
        audioSource = GetComponent <AudioSource>();
        rigidbody   = GetComponent <Rigidbody>();

        Assert.IsNotNull(audioSource);
        Assert.IsNotNull(rigidbody);
        Assert.IsNotNull(dropSound);
        Assert.IsNotNull(successSound);
        Assert.IsNotNull(throwSound);
    }
    // Use this for initialization
    private void Awake()
    {
        _influenceMapComponent = FindObjectOfType <InfluenceMapComponent>();
        _levelController       = FindObjectOfType <LevelController>();
        _pathfindingGrid       = FindObjectOfType <PathfindingGrid>();
        _influenceTexture      = GameObject.FindGameObjectWithTag("InfluenceTexture").GetComponent <RawImage>();

        Assert.IsNotNull(_influenceTexture);
        Assert.IsNotNull(_influenceMapComponent);
        Assert.IsNotNull(_levelController);
        Assert.IsNotNull(_pathfindingGrid);
    }
Example #11
0
    private void Validate(string path)
    {
        var fileName = Path.GetFileName(path);
        var asset    = AssetDatabase.LoadAssetAtPath <QuestAsset>(path);

        Assert.IsNotNull(asset, $"{fileName} => asset is null");

        Assert.IsFalse(string.IsNullOrEmpty(asset.id),
                       $"{fileName} => ID is null or empty");

        Assert.IsFalse(asset.id.IndexOf("A", StringComparison.Ordinal) != 0,
                       $"{fileName} => The naming conventions are different. : {asset.id}");
    }
Example #12
0
    private void BeforeTest()
    {
        TP = new TypingPerformance();
        var type = TP.GetType();

        Assert.IsNotNull(TP);
        // テストデータを挿入
        for (int i = 0; i < TEST_SENTENCE_NUM; ++i)
        {
            TP.AddOriginSentence(testSentenceOriginList[i]);
            TP.AddTypedSentenceList(testSentenceTypeList[i]);
            TP.AddTypeJudgeList(testJudgeList[i]);
            TP.AddTypeTimeList(testTypeTimeList[i]);
        }

        // 正しく挿入されてるかチェック
        var prop1  = type.GetProperty("OriginSentenceList");
        var value1 = (List <string>)prop1.GetValue(TP);

        for (int i = 0; i < TEST_SENTENCE_NUM; ++i)
        {
            Assert.IsTrue(value1[i].Equals(testSentenceOriginList[i]));
        }
        var prop2  = type.GetProperty("TypedSentenceList");
        var value2 = (List <string>)prop2.GetValue(TP);

        for (int i = 0; i < TEST_SENTENCE_NUM; ++i)
        {
            Assert.IsTrue(value2[i].Equals(testSentenceTypeList[i]));
        }
        var prop3  = type.GetProperty("TypeJudgeList");
        var value3 = (List <List <int> >)prop3.GetValue(TP);

        for (int i = 0; i < TEST_SENTENCE_NUM; ++i)
        {
            for (int j = 0; j < testJudgeList[i].Count(); ++j)
            {
                Assert.IsTrue(value3[i][j] == testJudgeList[i][j]);
            }
        }
        var prop4  = type.GetProperty("TypeTimeList");
        var value4 = (List <List <double> >)prop4.GetValue(TP);

        for (int i = 0; i < TEST_SENTENCE_NUM; ++i)
        {
            for (int j = 0; j < testTypeTimeList[i].Count(); ++j)
            {
                Assert.IsTrue(value4[i][j] == testTypeTimeList[i][j]);
            }
        }
    }
Example #13
0
 public string this [KEY key]
 {
     get
     {
         string result;
         HASH   hash = _hashFunction(key);
         if (_table.TryGetValue(hash, out result) == false)              //fail safe
         {
             result = _hashToString(hash);
             Assert.IsNotNull(result);
             _table.Add(hash, result);
         }
         return(result);
     }
 }
Example #14
0
    public IEnumerator Test3()
    {
        using (var tester = new Tester())
        {
            //エラーのハンドリング
            var       routine = tester.Routine(Error());
            bool      ret     = false;
            Exception ex      = null;
            routine.Observe((x, y) => { ret = x; ex = y; });
            yield return(routine);

            Assert.IsFalse(ret);
            Assert.IsNotNull(ex);
            Assert.IsTrue(!routine.IsRunning);
        }
    }
Example #15
0
    public IEnumerator Test5()
    {
        using (var tester = new Tester())
        {
            //ネストしていてもエラーを拾える
            var       routine = tester.Routine(Nest2(true));
            bool      ret     = false;
            Exception ex      = null;
            routine.Observe((x, y) => { ret = x; ex = y; });
            yield return(routine);

            Assert.IsFalse(ret);
            Assert.IsNotNull(ex);
            Assert.IsTrue(!routine.IsRunning);
        }
    }
Example #16
0
    public void InjectDelayTest()
    {
        ServInjector.Clear();
        ServInjector.Bind <ITestService>(new TestService1());
        //型情報がメタ情報が作成される
        var client = ServInjector.Create <TestClient>();

        Assert.IsNotNull(client.Service);
        Assert.IsNull(client.Delay);

        //メタ情報が出来た後でも後からでもバインド出来る
        ServInjector.Bind <IDelayService>(new DelayService());
        client = ServInjector.Create <TestClient>();
        Assert.IsNotNull(client.Service);
        Assert.IsNotNull(client.Delay);
    }
Example #17
0
    public IEnumerator Test8()
    {
        using (var tester = new Tester())
        {
            //型が違うと受け取れない
            var       routine = tester.TaskRoutine <int>(GetResults());
            string    ret     = "";
            Exception ex      = null;
            routine.Observe((x, y) => { ret += x; ex = y; });
            yield return(routine);

            Assert.AreNotEqual(ret, "result1");
            Assert.IsTrue(!routine.IsRunning);
            Assert.IsNotNull(ex);
        }
    }
Example #18
0
    public IEnumerator TimeTest4()
    {
        Trigger <string> trigger = new Trigger <string>();
        var       action         = trigger.Time(2f);
        var       val            = "";
        Exception ex             = null;

        action.Add(x => val    = x);
        action.AddFail(x => ex = x);
        yield return(new WaitForSeconds(0.5f));

        //エラーはすぐに発火される。
        trigger.Error(new Exception("error"));
        Assert.IsTrue(action.Fired);
        Assert.AreEqual(val, "");
        Assert.IsNotNull(ex);
    }
Example #19
0
    // Start is called before the first frame update
    void Start()
    {
        _radioController = FindObjectOfType <RobotRadioController>();
        Assert.IsNotNull(_radioController);
        receivedPackets = new List <Guid>();
        _signalWrapper  = ScriptableObject.CreateInstance <RobotIRSignalWrapper>();
        _signalWrapper.RegisterRobot(this);
        _signalWrapper.RegisterListener(_lightController);
        _signalWrapper.RegisterListener(_motionController);

        _motionController.HitTarget += OnHitTarget;

        IsReceivingIR = true;
        if (ShouldEmit)
        {
            StartCoroutine(EmitIR());
        }
    }
    public void GenerateSentenceTestRoman(string testStr, int[] expectedPattern)
    {
        int LEN     = expectedPattern.Length;
        var gsClass = typeof(GenerateSentence);

        Assert.IsNotNull(gsClass);
        MethodInfo builder = gsClass.GetMethod("ConstructTypeSentence", BindingFlags.NonPublic | BindingFlags.Static);

        Assert.IsNotNull(builder);

        // 生成した判定のチェック
        var matrix = (List <List <string> >)builder.Invoke(this, new object[] { testStr });

        Assert.AreEqual(LEN, matrix.Count);
        for (int i = 0; i < matrix.Count; ++i)
        {
            Assert.AreEqual(expectedPattern[i], matrix[i].Count);
        }
    }
Example #21
0
    public void Test2()
    {
        CLParser  parser  = new CLParser();
        bool      success = false;
        Exception error   = null;

        try
        {
            var config = parser.Run <TestRequiredConfig>(GetArgs().ToArray());
            success = true;
            config  = parser.Run <TestRequiredConfig>(new string[] { });
        }
        catch (Exception ex)
        {
            error = ex;
        }
        Assert.IsTrue(success);
        Assert.IsNotNull(error);
    }
Example #22
0
    public void ServiceLocaterClearTest()
    {
        ServInjector.Clear();

        //複数のサービスを登録
        var serv1 = new TestService1();

        ServInjector.Bind <ITestService>(serv1);
        ServInjector.Bind <TestService1>(serv1);
        ServInjector.Bind <TestService2>(new TestService2());
        //取り出せる
        Assert.IsNotNull(ServInjector.Resolve <ITestService>());
        Assert.IsNotNull(ServInjector.Resolve <TestService1>());
        Assert.IsNotNull(ServInjector.Resolve <TestService2>());
        //Clearですべてにcacheが削除される
        ServInjector.Clear();
        Assert.IsNull(ServInjector.Resolve <ITestService>());
        Assert.IsNull(ServInjector.Resolve <TestService1>());
        Assert.IsNull(ServInjector.Resolve <TestService2>());
    }
    public void GenerateSentenceTestJisKana(string testStr, string expectedStr)
    {
        var gsClass = typeof(GenerateSentence);

        Assert.IsNotNull(gsClass);
        MethodInfo builder = gsClass.GetMethod("ConstructJISKanaTypeSentence", BindingFlags.NonPublic | BindingFlags.Static);

        Assert.IsNotNull(builder);

        // 生成した判定のチェック
        var matrix     = (List <List <string> >)builder.Invoke(this, new object[] { testStr });
        var strBuilder = new StringBuilder();

        for (int i = 0; i < matrix.Count; ++i)
        {
            for (int j = 0; j < matrix[i].Count; ++j)
            {
                strBuilder.Append(matrix[i][j]);
            }
        }
        Assert.AreEqual(expectedStr, strBuilder.ToString());
    }
Example #24
0
    public static Item Create(PresetId id)
    {
        if (allSprites == null)
        {
            allSprites = Resources.LoadAll <Sprite> ("items");
        }
        var preset = itemPresets [(int)id];

        Item item = new Item();

        item.group   = preset.group;
        item.type    = preset.type;
        item.name    = preset.name;
        item.quality = preset.quality;
        item.preset  = preset;
        item.stack   = 1;

        Assert.IsTrue(preset.spriteId < allSprites.Length);
        item.sprite = allSprites[preset.spriteId];
        Assert.IsNotNull(item.sprite);
        return(item);
    }
Example #25
0
 public void ResolveAsyncTest()
 {
     Task.Run(async() =>
     {
         ServInjector.Clear();
         _ = Task.Run(async() =>
         {
             await Task.Delay(2000);
             ServInjector.Bind <ITestService>(new TestService1());
         });
         Exception error = null;
         try
         {
             var cancel = await ServInjector.ResolveAsync <ITestService>(new CancellationTokenSource(500).Token);
             Assert.IsNull(cancel);
         }
         catch (Exception ex) { error = ex; }
         Assert.IsNotNull(error);
         Assert.IsNull(ServInjector.Resolve <ITestService>());
         var service = await ServInjector.ResolveAsync <ITestService>();
         Assert.IsNotNull(service);
     }).Wait();
 }
Example #26
0
    public IEnumerator ModalTest1()
    {
        using (var tester = new Tester())
        {
            BootParam prm     = new BootParam();
            var       counter = new Counter();
            prm.BootContents.Add(new MainTestParam {
                Counter = counter
            });
            yield return(WrapTask(tester.Controller.Boot(prm)));

            var content  = tester.Controller.Get <MainTestContent>();
            var modalRet = content.RunModal(() => 124);
            yield return(WrapTask(modalRet));

            Assert.AreEqual(124, modalRet.Result);

            modalRet = content.RunModal <int>(() => throw new Exception("error"));
            yield return(WrapTask(modalRet));

            Assert.IsNotNull(modalRet.Exception);
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     Assert.IsNotNull(otherPlayer, "otherPlayer can't be null");
     _rb = GetComponent <Rigidbody>();
     _otherPlayerTransform = otherPlayer.GetComponent <Transform>();
 }