示例#1
0
    public void SphereTestSimplePasses()
    {
        var ray        = new Ray(new Vector3(0, 0, -10), new Vector3(0, 0, 1));
        var hit        = new HitRecord();
        var lambertian = new Lambertian(Vector3.one);
        var sphere     = new Sphere(Vector3.zero, 1.0f, lambertian);

        sphere.Hit(ray, hit);
        Assert.AreEqual(hit.t, 9.0f);
        Assert.AreEqual(hit.p, new Vector3(0, 0, -1));
        Assert.AreEqual(hit.normal, new Vector3(0, 0, -1));
    }
示例#2
0
    public void MessageTest1()
    {
        EventCall call  = new EventCall();
        int       count = 0;
        var       path  = call.Subscribe(TestEvent.Event1, () => count++);

        //イベントを発行
        Assert.IsTrue(call.Message(TestEvent.Event1));
        Assert.AreEqual(count, 1);
        //イベントを発行
        Assert.IsTrue(call.Message(TestEvent.Event1));
        Assert.AreEqual(count, 2);
        //登録していないイベント
        Assert.IsFalse(call.Message(TestEvent.Event2));
        Assert.AreEqual(count, 2);
        //パスを解除
        path.Dispose();
        Assert.IsFalse(call.Message(TestEvent.Event1));
        Assert.AreEqual(count, 2);
    }
示例#3
0
    public void QueueEntityMessagesCorrectly()
    {
        const string entityId_1 = "1";
        const string entityId_2 = "2";

        EntryPoint_World.SetEntityId(entityId_1);
        EntryPoint_World.CreateEntity();
        EntryPoint_World.SetEntityId(entityId_2);
        EntryPoint_World.CreateEntity();
        EntryPoint_World.SetEntityParent(entityId_1);

        EntryPoint_World.SetEntityId(entityId_1);
        EntryPoint_World.RemoveEntity();
        EntryPoint_World.SetEntityId(entityId_2);
        EntryPoint_World.RemoveEntity();

        string json1     = JsonConvert.SerializeObject(queueHandler.messagesList[0]);
        string json1base = @"{""method"":""CreateEntity"",""payload"":{""entityId"":""1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json1base, json1);

        string json2     = JsonConvert.SerializeObject(queueHandler.messagesList[1]);
        string json2base = @"{""method"":""CreateEntity"",""payload"":{""entityId"":""2""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json2base, json2);

        string json3     = JsonConvert.SerializeObject(queueHandler.messagesList[2]);
        string json3base = @"{""method"":""SetEntityParent"",""payload"":{""entityId"":""2"",""parentId"":""1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json3base, json3);

        string json4     = JsonConvert.SerializeObject(queueHandler.messagesList[3]);
        string json4base = @"{""method"":""RemoveEntity"",""payload"":{""entityId"":""1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json4base, json4);

        string json5     = JsonConvert.SerializeObject(queueHandler.messagesList[4]);
        string json5base = @"{""method"":""RemoveEntity"",""payload"":{""entityId"":""2""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json5base, json5);
    }
示例#4
0
    public IEnumerator MangedTest()
    {
        using (var tester = new Tester())
        {
            var       counter = new Counter();
            BootParam prm     = new BootParam();
            prm.BootContents.Add(new MainTestParam {
                Counter = counter
            });
            yield return(WrapTask(tester.Controller.Boot(prm)));

            var manded = tester.Controller.Get <IHasManagedHolder>();

            bool dispose = false;
            // disposed時にアクションを発火するように登録
            var action = manded.Manage(() => dispose = true);
            Assert.IsFalse(dispose);
            //Unmanageで解放される
            manded.Unmanage(action);
            Assert.IsTrue(dispose);

            //再登録
            dispose = false;
            manded.Manage(() => dispose = true);
            //非同期を登録
            var asyncDispose = new AsyncDispose();
            manded.ManageAsync(asyncDispose);
            tester.Message(MainTestContent.Event.Switch, counter);

            //直ぐには実行されない
            Assert.IsFalse(asyncDispose.Disposed);

            yield return(counter.Wait("Run", 2));

            yield return(tester.Close());

            Assert.IsTrue(dispose);
            Assert.IsTrue(asyncDispose.Disposed);
        }
    }
示例#5
0
    public void SubCallTest()
    {
        EventCall root  = new EventCall();
        EventCall call1 = root.SubCall();
        EventCall call2 = root.SubCall();
        EventCall call3 = root.SubCall();
        EventCall call4 = call1.SubCall();
        EventCall call5 = call4.SubCall();
        int       ret   = 0;
        var       path1 = call1.Subscribe(TestEvent.Event1, () => ret = 1);

        call2.Subscribe(TestEvent.Event1, () => ret = 2);
        call3.Subscribe(TestEvent.Event1, () => ret = 3);
        call4.Subscribe(TestEvent.Event1, () => ret = 4);
        call5.Subscribe(TestEvent.Event1, () => ret = 5);

        //メッセージが伝播してcall1優先される
        Assert.IsTrue(root.Message(TestEvent.Event1));
        Assert.AreEqual(ret, 1);

        //メッセージが優先される
        Assert.IsTrue(call2.Message(TestEvent.Event1));
        Assert.AreEqual(ret, 2);
        Assert.IsTrue(call3.Message(TestEvent.Event1));
        Assert.AreEqual(ret, 3);

        //パスがなくなったので、サブコールのイベントが呼ばれる
        path1.Dispose();
        Assert.IsTrue(root.Message(TestEvent.Event1));
        Assert.AreEqual(ret, 4);

        //子のサブコールも解放される
        call1.Dispose();
        Assert.IsFalse(call5.Message(TestEvent.Event1));
        Assert.AreEqual(ret, 4);

        Assert.IsTrue(root.Message(TestEvent.Event1));
        Assert.AreEqual(ret, 2);
    }
 public void TestSignedAngle()
 {
     {
         Vector3 v1    = Vector3.up;
         Vector2 v2    = Vector3.left;
         float   angle = UnityVectorExtensions.SignedAngle(v1, v2, Vector3.forward);
         Assert.AreApproximatelyEqual(angle, 90f);
         float angle2 = Vector2.SignedAngle(v1, v2);
         Assert.AreApproximatelyEqual(angle, angle2);
         float angle3 = UnityVectorExtensions.SignedAngle(v1, v2, Vector3.back);
         Assert.AreApproximatelyEqual(angle, -angle3);
     }
     {
         Vector3 v1    = Vector3.up;
         Vector2 v2    = Vector3.right;
         float   angle = UnityVectorExtensions.SignedAngle(v1, v2, Vector3.forward);
         Assert.AreApproximatelyEqual(angle, -90f);
         float angle2 = Vector2.SignedAngle(v1, v2);
         Assert.AreApproximatelyEqual(angle, angle2);
         float angle3 = UnityVectorExtensions.SignedAngle(v1, v2, Vector3.back);
         Assert.AreApproximatelyEqual(angle, -angle3);
     }
     {
         Vector3 v1    = Vector3.up;
         Vector2 v2    = new Vector3(-0.0001f, 1, 0);
         float   angle = UnityVectorExtensions.SignedAngle(v1, v2, Vector3.forward);
         Assert.AreApproximatelyEqual(angle, 0.00572958f);
         float angle3 = UnityVectorExtensions.SignedAngle(v1, v2, Vector3.back);
         Assert.AreApproximatelyEqual(angle, -angle3);
     }
     {
         Vector3 v1    = Vector3.up;
         Vector2 v2    = new Vector3(0.0001f, 1, 0);
         float   angle = UnityVectorExtensions.SignedAngle(v1, v2, Vector3.forward);
         Assert.AreApproximatelyEqual(angle, -0.00572958f);
         float angle3 = UnityVectorExtensions.SignedAngle(v1, v2, Vector3.back);
         Assert.AreApproximatelyEqual(angle, -angle3);
     }
 }
示例#7
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);
    }
示例#8
0
    private IEnumerator VerifyCompressionSupport(string url)
    {
        yield return(new WaitForEndOfFrame());

        var request = (HttpWebRequest)WebRequest.Create(url);

        request.AutomaticDecompression = DecompressionMethods.GZip;
        var result = request.BeginGetResponse(null, null);

        yield return(new WaitForIAsyncResult(result));

        NAssert.DoesNotThrow(() =>
        {
            using (var response = (HttpWebResponse)request.EndGetResponse(result))
            {
                Assert.AreEqual(response.StatusCode, HttpStatusCode.OK, "Unexpected HTTP response code");
                var encoding = response.ContentEncoding.ToLower();
                Assert.IsTrue(encoding.Contains("gzip"), string.Format("Expected: {0}, Actual: {1}", "gzip", encoding));
            }
        });
        yield return(new WaitForEndOfFrame());
    }
示例#9
0
    public void MessageTest3()
    {
        EventCall call   = new EventCall();
        int       count1 = 0;
        int       count2 = 0;
        int       count3 = 0;
        var       path1  = call.Subscribe(TestEvent.Event1, () => count1++);
        var       path2  = call.Subscribe(TestEvent.Event1, () => count2++);
        var       path3  = call.Subscribe(TestEvent.Event1, () => count3++);

        //メッセージは一番最初に登録された物が優先される
        for (int i = 0; i < 5; i++)
        {
            Assert.IsTrue(call.Message(TestEvent.Event1));
            Assert.AreEqual(count1, 1 + i);
            Assert.AreEqual(count2, 0);
            Assert.AreEqual(count3, 0);
        }
        //一つ解除する
        path1.Dispose();
        //ブロードキャストは全ての登録イベントに発火する
        for (int i = 0; i < 5; i++)
        {
            Assert.IsTrue(call.Broadcast(TestEvent.Event1));
            Assert.AreEqual(count1, 5);
            Assert.AreEqual(count2, 1 + i);
            Assert.AreEqual(count3, 1 + i);
        }
        path2.Dispose();
        path3.Dispose();
        //全て解除すると発火されない
        for (int i = 0; i < 5; i++)
        {
            Assert.IsFalse(call.Broadcast(TestEvent.Event1));
            Assert.AreEqual(count1, 5);
            Assert.AreEqual(count2, 5);
            Assert.AreEqual(count3, 5);
        }
    }
    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());
    }
示例#11
0
    public void QueueSharedComponentMessagesCorrectly()
    {
        const string entityId       = "1";
        const string componentId    = "component-1";
        const int    componentClass = 1;

        EntryPoint_World.SetEntityId(entityId);
        EntryPoint_World.CreateEntity();
        EntryPoint_World.SharedComponentCreate(componentClass, componentId);
        EntryPoint_World.SharedComponentAttach(componentId, null);
        EntryPoint_World.SharedComponentUpdate(componentId, "{}");
        EntryPoint_World.SharedComponentDispose(componentId);

        string json1     = JsonConvert.SerializeObject(queueHandler.messagesList[0]);
        string json1base = @"{""method"":""CreateEntity"",""payload"":{""entityId"":""1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json1base, json1);

        string json2     = JsonConvert.SerializeObject(queueHandler.messagesList[1]);
        string json2base = @"{""method"":""ComponentCreated"",""payload"":{""id"":""component-1"",""classId"":1,""name"":null},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json2base, json2);

        string json3     = JsonConvert.SerializeObject(queueHandler.messagesList[2]);
        string json3base = @"{""method"":""AttachEntityComponent"",""payload"":{""entityId"":""1"",""id"":""component-1"",""name"":null},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json3base, json3);

        string json4     = JsonConvert.SerializeObject(queueHandler.messagesList[3]);
        string json4base = @"{""method"":""ComponentUpdated"",""payload"":{""componentId"":""component-1"",""json"":""{}""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json4base, json4);

        string json5     = JsonConvert.SerializeObject(queueHandler.messagesList[4]);
        string json5base = @"{""method"":""ComponentDisposed"",""payload"":{""id"":""component-1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json5base, json5);
    }
示例#12
0
    public IEnumerator InjectMonoBehaviourTest()
    {
        GameObject obj = new GameObject("Test");

        try
        {
            //ServiceBehaviourは勝手に登録される
            var serv = obj.AddComponent <TestServiceBehaviour>();
            Assert.AreEqual(ServInjector.Resolve <ITestService>(), serv);
            //AddComponent時にインジェクト
            var client = ServInjector.AddComponent <TestClientBehaviour>(obj);
            Assert.AreEqual(ServInjector.Resolve <ITestService>(), client.Service);
            Component.Destroy(serv);
            //OnDestroyを待つ
            yield return(null);

            Assert.IsNull(ServInjector.Resolve <ITestService>());
        }
        finally
        {
            GameObject.Destroy(obj);
        }
    }
示例#13
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);
        }
    }
示例#14
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();
 }
示例#15
0
 public static void HardAssert(bool isTrue, string message = "")
 {
     if (!Debug.isDebugBuild)
     {
         UAssert.raiseExceptions = true;
     }
     if (message != "")
     {
         UAssert.IsTrue(isTrue, message);
     }
     else
     {
         UAssert.IsTrue(isTrue);
     }
     if (!isTrue)
     {
         Debug.Break();
     }
     if (!Debug.isDebugBuild)
     {
         UAssert.raiseExceptions = false;
     }
 }
示例#16
0
    public IEnumerator SwitchTest2()
    {
        using (var tester = new Tester())
        {
            var       counter = new Counter();
            BootParam prm     = new BootParam();
            prm.BootContents.Add(new MainTestParam {
                Counter = counter
            });
            yield return(WrapTask(tester.Controller.Boot(prm)));

            //Refからのスイッチ
            yield return(WrapTask(tester.Controller.Get <MainTestContent>().Switch(new MainTestParam {
                Counter = counter, BootWait = 0.5f
            })));

            //ちゃんと待てる
            Assert.AreEqual(counter.Get("Boot"), 2);
            Assert.AreEqual(counter.Get("Enable"), 2);
            Assert.AreEqual(counter.Get("Run"), 2);
            yield return(tester.Close());
        }
    }
示例#17
0
    public void Test2()
    {
        //データクラスのセーブ
        using (var ctx = new Context("Test2"))
        {
            TestData data = null;
            for (int i = 0; i < 2; i++)
            {
                ctx.Save.TryGet(out data);
                Assert.IsTrue(string.IsNullOrEmpty(data.TestString));
                Assert.IsTrue(data.InitCheck);
                Assert.AreEqual(data.OldVersion, 0);
                data.TestString = "Test";
            }
            data.SetDitry();

            ctx.Save.TryGet(out data);
            Assert.IsFalse(string.IsNullOrEmpty(data.TestString));
            Assert.IsFalse(data.InitCheck);
            Assert.AreEqual(data.OldVersion, 0);
            data.SetDitry(true);

            TestData.TestVersion = 2;
            ctx.Save.TryGet(out data);
            Assert.AreEqual(data.TestString, "Test");
            Assert.IsFalse(data.InitCheck);
            Assert.AreEqual(data.OldVersion, 1);

            data.TestString = "TestTest";

            data.SetDitry(true);
            ctx.Save.TryGet(out data);
            Assert.AreEqual(data.TestString, "TestTest");
            Assert.IsFalse(data.InitCheck);
            Assert.AreEqual(data.OldVersion, 0);
        }
    }
示例#18
0
    public void MessageTest2()
    {
        EventCall call  = new EventCall();
        int       ret   = 0;
        int       count = 0;
        var       path  = call.Subscribe(TestEvent.Event1, (int val) => { ret = val; count++; });

        //イベントを発行
        Assert.IsTrue(call.Message(TestEvent.Event1, 5));
        Assert.AreEqual(ret, 5);
        Assert.AreEqual(count, 1);

        //イベントを発行
        Assert.IsTrue(call.Message(TestEvent.Event1, 7));
        Assert.AreEqual(ret, 7);
        Assert.AreEqual(count, 2);

        //単発イベントでは発火しない
        Assert.IsFalse(call.Message(TestEvent.Event1));
        Assert.AreEqual(ret, 7);
        Assert.AreEqual(count, 2);

        //違う方のイベントでは発火しない
        Assert.IsFalse(call.Message(TestEvent.Event1, 0.4f));
        Assert.AreEqual(ret, 7);
        Assert.AreEqual(count, 2);

        //登録していないイベント
        Assert.IsFalse(call.Message(TestEvent.Event2, 4));
        Assert.AreEqual(count, 2);

        //パスを解除
        path.Dispose();
        Assert.IsFalse(call.Message(TestEvent.Event1, 22));
        Assert.AreEqual(ret, 7);
        Assert.AreEqual(count, 2);
    }
示例#19
0
    public void TriggerTest5()
    {
        //複数の結果をまとめる
        int[] input    = new int[] { 1, 5, 7, 3, 5, 7 };
        var   triggers = new List <Trigger <int> >();

        for (int i = 0; i < input.Length; i++)
        {
            triggers.Add(new Trigger <int>());
        }
        var combine = Trigger.Combine(triggers.Select(x => x.Action).ToArray());

        //まだ発火していない。
        Assert.IsFalse(combine.Fired);
        combine.Add(x =>
        {
            for (int i = 0; i < input.Length; i++)
            {
                Assert.AreEqual(x[i], input[i], "入力と同じ");
            }
        });
        for (int i = 0; i < input.Length; i++)
        {
            triggers[i].Fire(input[i]);
            if (i == input.Length - 1)
            {
                Assert.IsTrue(combine.Fired);
            }
            else
            {
                Assert.IsFalse(combine.Fired);
            }
        }
        //引数がなければすぐに発火される
        Assert.IsTrue(Trigger.Combine().Fired);
        Assert.IsTrue(Trigger.Combine <bool>().Fired);
    }
示例#20
0
    /// <summary>
    /// Adds the given item to this priority queue with the given weight.
    /// </summary>
    public void Add(T item, float weight)
    {
        Assert.IsTrue(!itemWeights.ContainsKey(item) && !sortedItems.Contains(item));

        itemWeights.Add(item, weight);

        //Insert the item based on weight.
        int i;

        for (i = 0; i < sortedItems.Count; ++i)
        {
            float tempWeight = itemWeights[sortedItems[i]];
            if ((IsAscending && tempWeight < weight) ||
                (!IsAscending && tempWeight > weight))
            {
                sortedItems.Insert(i, item);
                break;
            }
        }
        if (i == sortedItems.Count)
        {
            sortedItems.Add(item);
        }
    }
    public void WordsetCheckerJISKana(string fileName)
    {
        var sectionRegex = @"\{__[\w|_]+__\}";
        var jsonStr      = AssetDatabase.LoadAssetAtPath <TextAsset>($"Assets/Wordset/Short/{fileName}.json");
        var problemData  = JsonUtility.FromJson <SentenceData>(jsonStr.text);
        var wordSetDict  = new Dictionary <string, List <(string originSentence, string typeSentence)> >();

        foreach (var word in problemData.words)
        {
            var wordSection = word.wordSection;
            var wordInfo    = (word.sentence, word.typeString);
            if (wordSetDict.ContainsKey(wordSection))
            {
                wordSetDict[wordSection].Add(wordInfo);
            }
            else
            {
                wordSetDict[wordSection] = new List <(string, string)>()
                {
                    wordInfo
                };
            }
        }
        foreach (var key in wordSetDict.Keys)
        {
            var dictCache = wordSetDict[key];
            foreach (var wordInfo in dictCache)
            {
                var tSentence = Regex.Replace(wordInfo.typeSentence, sectionRegex, "");
                foreach (var ch in tSentence)
                {
                    Assert.IsTrue(jisKanaValidChar.Contains(ch.ToString()));
                }
            }
        }
    }
示例#22
0
 public void TriggerEnterTest(Collider other)
 {
     Assert.AreEqual(other.tag, "Player");
 }
示例#23
0
 public void UpdateRepositorySingleThreaded_OnAssetDatabaseRefreshEmptyUpdateNotCalled_UpdateRepositoryNotCalled()
 {
     AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
     ForceGitUpdate();
     Assert.AreEqual(updateRepositoryCalled, 0);
 }
示例#24
0
    public void CreateUniqueKeyArgumentTest()
    {
        var uniqueKey = _task_v.CreateUniqueKey(_taskList);

        Assert.AreEqual(uniqueKey, 3);
    }
示例#25
0
    public IEnumerator EnumeratorPasses()
    {
        yield return(null);

        Assert.AreEqual(2, 1 + 1);
    }
示例#26
0
 public void OnRepositoryLoad_OnRepositoryDirtyShouldCallRepositoryLoad_OnRepositoryLoadCalled()
 {
     gitManager.MarkDirty(true);
     ForceGitUpdate();
     Assert.AreEqual(onRepositoryLoadedCalled, 1);
 }
 void Awake()
 {
     Assert.IsTrue(XRSettings.enabled);
     Assert.AreEqual("lumin", XRSettings.loadedDeviceName);
     IsTestFinished = true;
 }
    public void FindIntersectionTests()
    {
        {
            var l1_p1            = new Vector2(0, 1);
            var l1_p2            = new Vector2(0, -1);
            var l2_p1            = new Vector2(-1, 0);
            var l2_p2            = new Vector2(1, 0);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 2);
            Assert.IsTrue(AreApproximatelyEqual(intersection, Vector2.zero));
        }
        {
            var l1_p1            = new Vector2(0, 1);
            var l1_p2            = new Vector2(0, 0);
            var l2_p1            = new Vector2(-1, 0);
            var l2_p2            = new Vector2(1, 0);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 2);
            Assert.IsTrue(AreApproximatelyEqual(intersection, Vector2.zero));
        }
        {
            var l1_p1            = new Vector2(0, 2);
            var l1_p2            = new Vector2(0, 1);
            var l2_p1            = new Vector2(-1, 0);
            var l2_p2            = new Vector2(1, 0);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 1);
            Assert.IsTrue(AreApproximatelyEqual(intersection, Vector2.zero));
        }
        {
            var l1_p1            = new Vector2(0, 2);
            var l1_p2            = new Vector2(0, 1);
            var l2_p1            = new Vector2(1, 2);
            var l2_p2            = new Vector2(1, 1);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 0);
            Assert.IsTrue(float.IsInfinity(intersection.x) && float.IsInfinity(intersection.y));
        }
        {
            var l1_p1            = new Vector2(1, 2);
            var l1_p2            = new Vector2(1, 1);
            var l2_p1            = new Vector2(1, -2);
            var l2_p2            = new Vector2(1, -1);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 3);
            Assert.IsTrue(float.IsInfinity(intersection.x) && float.IsInfinity(intersection.y));
        }
        {
            var l1_p1            = new Vector2(1, 2);
            var l1_p2            = new Vector2(1, -2);
            var l2_p1            = new Vector2(1, 3);
            var l2_p2            = new Vector2(1, 1);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 4);
            Assert.IsTrue(float.IsInfinity(intersection.x) && float.IsInfinity(intersection.y));
        }
        {
            var l1_p1            = new Vector2(1, 2);
            var l1_p2            = new Vector2(1, -2);
            var l2_p1            = new Vector2(1, 2);
            var l2_p2            = new Vector2(1, -2);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 4);
            Assert.IsTrue(float.IsInfinity(intersection.x) && float.IsInfinity(intersection.y));
        }
        {
            var l1_p1            = new Vector2(1, 2);
            var l1_p2            = new Vector2(1, -2);
            var l2_p1            = new Vector2(1, -2);
            var l2_p2            = new Vector2(1, 2);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 4);
            Assert.IsTrue(float.IsInfinity(intersection.x) && float.IsInfinity(intersection.y));
        }
        {
            var l1_p1            = new Vector2(0, 1);
            var l1_p2            = new Vector2(0, 1);
            var l2_p1            = new Vector2(1, 0);
            var l2_p2            = new Vector2(1, 0);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 4);
            Assert.IsTrue(float.IsInfinity(intersection.x) && float.IsInfinity(intersection.y));
        }
        {
            var l1_p1            = new Vector2(0, 0);
            var l1_p2            = new Vector2(2, 0);
            var l2_p1            = new Vector2(0, 1);
            var l2_p2            = new Vector2(1, 0);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 2);
            Assert.IsTrue(AreApproximatelyEqual(intersection, l2_p2));
        }
        {
            var l1_p1            = new Vector2(0, 0);
            var l1_p2            = new Vector2(2, 0);
            var l2_p1            = new Vector2(1, 0);
            var l2_p2            = new Vector2(0, 1);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 2);
            Assert.IsTrue(AreApproximatelyEqual(intersection, l2_p1));
        }

        // Parallel segments touching at one point
        {
            var l1_p1            = new Vector2(0, 3);
            var l1_p2            = new Vector2(0, 5);
            var l2_p1            = new Vector2(0, 5);
            var l2_p2            = new Vector2(0, 9);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 4);
            Assert.IsTrue(AreApproximatelyEqual(intersection, l2_p1));
        }
        {
            var l1_p1            = new Vector2(0, 5);
            var l1_p2            = new Vector2(0, 3);
            var l2_p1            = new Vector2(0, 5);
            var l2_p2            = new Vector2(0, 9);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 4);
            Assert.IsTrue(AreApproximatelyEqual(intersection, l2_p1));
        }
        {
            var l1_p1            = new Vector2(0, 3);
            var l1_p2            = new Vector2(0, 5);
            var l2_p1            = new Vector2(0, 9);
            var l2_p2            = new Vector2(0, 5);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 4);
            Assert.IsTrue(AreApproximatelyEqual(intersection, l2_p2));
        }
        {
            var l1_p1            = new Vector2(0, 5);
            var l1_p2            = new Vector2(0, 3);
            var l2_p1            = new Vector2(0, 9);
            var l2_p2            = new Vector2(0, 5);
            int intersectionType = UnityVectorExtensions.FindIntersection(l1_p1, l1_p2, l2_p1, l2_p2,
                                                                          out Vector2 intersection);
            Assert.IsTrue(intersectionType == 4);
            Assert.IsTrue(AreApproximatelyEqual(intersection, l2_p2));
        }
    }
示例#29
0
    public IEnumerator EntityBasicMaterialUpdate()
    {
        string entityId   = "1";
        string materialID = "a-material";

        Assert.IsFalse(scene.disposableComponents.ContainsKey(materialID));

        // Instantiate entity with default material
        TestHelpers.InstantiateEntityWithMaterial(scene, entityId, new Vector3(8, 1, 8),
                                                  new BasicMaterial.Model(), materialID);

        var meshObject = scene.entities[entityId].meshRootGameObject;

        Assert.IsTrue(meshObject != null,
                      "Every entity with a shape should have the mandatory 'Mesh' object as a child");

        var meshRenderer      = meshObject.GetComponent <MeshRenderer>();
        var materialComponent = scene.disposableComponents[materialID] as BasicMaterial;

        yield return(materialComponent.routine);

        // Check if material initialized correctly
        {
            Assert.IsTrue(meshRenderer != null, "MeshRenderer must exist");

            var assignedMaterial = meshRenderer.sharedMaterial;
            Assert.IsTrue(meshRenderer != null, "MeshRenderer.sharedMaterial must be the same as assignedMaterial");

            Assert.AreEqual(assignedMaterial, materialComponent.material, "Assigned material");
        }

        // Check default properties
        {
            Assert.IsTrue(materialComponent.material.GetTexture("_BaseMap") == null);
            Assert.AreApproximatelyEqual(1.0f, materialComponent.material.GetFloat("_AlphaClip"));
        }

        DCLTexture dclTexture = TestHelpers.CreateDCLTexture(
            scene,
            Utils.GetTestsAssetsPath() + "/Images/atlas.png",
            DCLTexture.BabylonWrapMode.MIRROR,
            FilterMode.Bilinear);

        // Update material
        scene.SharedComponentUpdate(materialID, JsonUtility.ToJson(new BasicMaterial.Model
        {
            texture   = dclTexture.id,
            alphaTest = 0.5f,
        }));

        yield return(materialComponent.routine);

        // Check updated properties
        {
            Texture mainTex = materialComponent.material.GetTexture("_BaseMap");
            Assert.IsTrue(mainTex != null);
            Assert.AreApproximatelyEqual(0.5f, materialComponent.material.GetFloat("_Cutoff"));
            Assert.AreApproximatelyEqual(1.0f, materialComponent.material.GetFloat("_AlphaClip"));
            Assert.AreEqual(TextureWrapMode.Mirror, mainTex.wrapMode);
            Assert.AreEqual(FilterMode.Bilinear, mainTex.filterMode);
        }
    }
示例#30
0
 public void SimplePasses()
 {
     Assert.IsTrue(1 == 1);
 }