< Summary

Class:LoadWrapperShould
Assembly:LoadWrapperTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/LoadableShapes/LoadWrapper/Tests/LoadWrapperShould.cs
Covered lines:18
Uncovered lines:0
Coverable lines:18
Total lines:49
Line coverage:100% (18 of 18)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CreatePlatformContext()0%110100%
UnloadWhenEntityDestroyedBeforeFinishing()0%550100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/LoadableShapes/LoadWrapper/Tests/LoadWrapperShould.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using DCL;
 4using DCL.Components;
 5using DCL.Helpers;
 6using DCL.Models;
 7using NSubstitute;
 8using NSubstitute.ReceivedExtensions;
 9using Tests;
 10using UnityEngine;
 11using UnityEngine.TestTools;
 12using Assert = UnityEngine.Assertions.Assert;
 13using Object = UnityEngine.Object;
 14
 15public class LoadWrapperShould : IntegrationTestSuite
 16{
 117    protected override PlatformContext CreatePlatformContext() { return DCL.Tests.PlatformContextFactory.CreateWithGener
 18
 19    [UnityTest]
 20    public IEnumerator UnloadWhenEntityDestroyedBeforeFinishing()
 21    {
 122        GameObject meshRootGameObject = new GameObject();
 23
 124        string url = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb";
 25
 126        IDCLEntity entity = Substitute.For<IDCLEntity>();
 127        entity.meshRootGameObject.Returns(meshRootGameObject);
 28
 129        LoadWrapper_GLTF wrapper = Substitute.ForPartsOf<LoadWrapper_GLTF>();
 130        wrapper.entity = entity;
 131        wrapper.customContentProvider = new ContentProvider();
 32
 133        bool loaded = false;
 134        bool failed = false;
 135        bool unloaded = false;
 36
 337        wrapper.WhenForAnyArgs(x => x.Unload()).Do((info) => unloaded = true);
 38
 139        wrapper.Load(url, loadWrapper => loaded = true, loadWrapper => failed = true );
 40
 141        entity.OnCleanupEvent?.Invoke(entity);
 42
 243        yield return new WaitUntil(() => loaded || failed || unloaded);
 44
 145        Object.Destroy(meshRootGameObject);
 46
 147        Assert.IsTrue(unloaded, "Unload should be called if entity is cleaned up while loading mesh");
 148    }
 49}