< Summary

Class:SettingsPanelTests.SettingsPanelShould_PlayMode
Assembly:SettingsPanelHUDTests_PlayMode
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/SettingsPanelHUD/Tests/PlayMode/SettingsPanelTests_PlayMode.cs
Covered lines:28
Uncovered lines:0
Coverable lines:28
Total lines:77
Line coverage:100% (28 of 28)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SettingsPanelShould_PlayMode()0%110100%
SetUp()0%330100%
TearDown()0%550100%
GenerateSectionsIntoThePanelViewCorrectly()0%330100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/SettingsPanelHUD/Tests/PlayMode/SettingsPanelTests_PlayMode.cs

#LineLine coverage
 1using DCL.SettingsPanelHUD;
 2using DCL.SettingsPanelHUD.Sections;
 3using NSubstitute;
 4using System.Collections;
 5using UnityEngine;
 6using UnityEngine.TestTools;
 7
 8namespace SettingsPanelTests
 9{
 10    public class SettingsPanelShould_PlayMode
 11    {
 12        private const string SECTION_VIEW_PREFAB_PATH = "Sections/DefaultSettingsSectionTemplate";
 13        private const string MENU_BUTTON_PREFAB_PATH = "Sections/DefaultSettingsMenuButtonTemplate";
 14
 15        private SettingsPanelHUDView panelView;
 16        private IHUD hudController;
 17        private ISettingsPanelHUDController panelController;
 118        private SettingsSectionList sectionsToCreate = new SettingsSectionList();
 19
 20        [UnitySetUp]
 21        private IEnumerator SetUp()
 22        {
 123            panelView = SettingsPanelHUDView.Create();
 124            hudController = Substitute.For<IHUD>();
 125            panelController = Substitute.For<ISettingsPanelHUDController>();
 26
 127            yield return null;
 128        }
 29
 30        [UnityTearDown]
 31        private IEnumerator TearDown()
 32        {
 133            Object.Destroy(panelView.gameObject);
 34
 435            foreach (var section in sectionsToCreate)
 36            {
 137                Object.Destroy(section.icon);
 38            }
 139            sectionsToCreate.Clear();
 40
 141            yield return null;
 142        }
 43
 44        [UnityTest]
 45        public IEnumerator GenerateSectionsIntoThePanelViewCorrectly()
 46        {
 47            // Arrange
 148            SettingsSectionView sectionViewPrefab = ((GameObject)Resources.Load(SECTION_VIEW_PREFAB_PATH)).GetComponent<
 149            SettingsButtonEntry menuButtonPrefab = ((GameObject)Resources.Load(MENU_BUTTON_PREFAB_PATH)).GetComponent<Se
 50
 151            SettingsSectionModel newSectionConfig = ScriptableObject.CreateInstance<SettingsSectionModel>();
 152            newSectionConfig.icon = Sprite.Create(new Texture2D(10, 10), new Rect(), new Vector2());
 153            newSectionConfig.text = "TestSection";
 154            newSectionConfig.menuButtonPrefab = menuButtonPrefab;
 155            newSectionConfig.sectionPrefab = sectionViewPrefab;
 156            newSectionConfig.sectionController = ScriptableObject.CreateInstance<SettingsSectionController>();
 157            newSectionConfig.widgets = new SettingsWidgetList();
 58
 159            sectionsToCreate.Add(newSectionConfig);
 60
 61            // Act
 162            panelView.Initialize(hudController, panelController, sectionsToCreate);
 163            yield return null;
 64
 65            // Assert
 166            panelController.Received(1)
 67                           .AddSection(
 68                               Arg.Any<SettingsButtonEntry>(),
 69                               Arg.Any<ISettingsSectionView>(),
 70                               Arg.Any<ISettingsSectionController>(),
 71                               Arg.Any<SettingsSectionModel>());
 72
 173            panelController.Received(1).OpenSection(0);
 174            panelController.Received(1).MarkMenuButtonAsSelected(0);
 175        }
 76    }
 77}