< Summary

Class:AssetPromiseKeeper_Gif_Tests.BlockedAndMasterPromisesShould
Assembly:AssetPromiseKeeper_Gif_Tests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/AssetManager/Gif/Tests/BlockedAndMasterPromisesShould.cs
Covered lines:34
Uncovered lines:0
Coverable lines:34
Total lines:61
Line coverage:100% (34 of 34)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
FailCorrectlyWhenGivenWrongURL()0%550100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/AssetManager/Gif/Tests/BlockedAndMasterPromisesShould.cs

#LineLine coverage
 1using AssetPromiseKeeper_Tests;
 2using DCL;
 3using System.Collections;
 4using UnityEngine.Assertions;
 5using UnityEngine.TestTools;
 6
 7namespace AssetPromiseKeeper_Gif_Tests
 8{
 9    public class BlockedAndMasterPromisesShould : TestsBase_APK<AssetPromiseKeeper_Gif,
 10        AssetPromise_Gif,
 11        Asset_Gif,
 12        AssetLibrary_RefCounted<Asset_Gif>>
 13    {
 14        [UnityTest]
 15        public IEnumerator FailCorrectlyWhenGivenWrongURL()
 16        {
 117            var prom = new AssetPromise_Gif("123325");
 118            Asset_Gif asset = null;
 119            bool failEventCalled1 = false;
 120            prom.OnSuccessEvent += (x) => { asset = x; };
 321            prom.OnFailEvent += (x) => { failEventCalled1 = true; };
 22
 123            var prom2 = new AssetPromise_Gif("43254378");
 124            Asset_Gif asset2 = null;
 125            bool failEventCalled2 = false;
 126            prom2.OnSuccessEvent += (x) => { asset2 = x; };
 327            prom2.OnFailEvent += (x) => { failEventCalled2 = true; };
 28
 129            var prom3 = new AssetPromise_Gif("09898765");
 130            Asset_Gif asset3 = null;
 131            bool failEventCalled3 = false;
 132            prom3.OnSuccessEvent += (x) => { asset3 = x; };
 333            prom3.OnFailEvent += (x) => { failEventCalled3 = true; };
 34
 135            keeper.Keep(prom);
 136            keeper.Keep(prom2);
 137            keeper.Keep(prom3);
 38
 139            Assert.AreEqual(3, keeper.waitingPromisesCount);
 40
 141            yield return prom;
 142            yield return prom2;
 143            yield return prom3;
 44
 145            Assert.AreNotEqual(AssetPromiseState.FINISHED, prom.state);
 146            Assert.AreNotEqual(AssetPromiseState.FINISHED, prom2.state);
 147            Assert.AreNotEqual(AssetPromiseState.FINISHED, prom3.state);
 48
 149            Assert.IsTrue(failEventCalled1);
 150            Assert.IsTrue(failEventCalled2);
 151            Assert.IsTrue(failEventCalled3);
 52
 153            Assert.IsFalse(asset != null);
 154            Assert.IsFalse(asset2 != null);
 155            Assert.IsFalse(asset3 != null);
 56
 157            Assert.IsFalse(keeper.library.Contains(asset));
 158            Assert.AreNotEqual(1, keeper.library.masterAssets.Count);
 159        }
 60    }
 61}