< Summary

Class:SettingsPanelTests.SettingsPanelShould_EditMode
Assembly:SettingsPanelTests_EditMode
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/SettingsPanelHUD/Tests/EditMode/SettingsPanelTests_EditMode.cs
Covered lines:0
Uncovered lines:28
Coverable lines:28
Total lines:80
Line coverage:0% (0 of 28)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%2100%
TearDown()0%2100%
AddSectionCorrectly()0%2100%
OpenSectionCorrectly()0%2100%
OpenSectionByIndexCorrectly()0%2100%

File(s)

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

#LineLine coverage
 1using DCL.SettingsPanelHUD;
 2using DCL.SettingsPanelHUD.Sections;
 3using DCL.SettingsPanelHUD.Widgets;
 4using NSubstitute;
 5using NUnit.Framework;
 6using System.Collections.Generic;
 7using UnityEngine;
 8
 9namespace SettingsPanelTests
 10{
 11    public class SettingsPanelShould_EditMode
 12    {
 13        private SettingsPanelHUDController panelController;
 14        private ISettingsSectionView newSectionView;
 15        private ISettingsSectionController newSectionController;
 16        private SettingsSectionModel newSectionConfig;
 17        private Sprite testSprite;
 18
 19        [SetUp]
 20        public void SetUp()
 21        {
 022            panelController = new SettingsPanelHUDController();
 023            newSectionView = Substitute.For<ISettingsSectionView>();
 024            newSectionController = Substitute.For<ISettingsSectionController>();
 025            testSprite = Sprite.Create(new Texture2D(10, 10), new Rect(), new Vector2());
 026            newSectionConfig = ScriptableObject.CreateInstance<SettingsSectionModel>();
 027            newSectionConfig.icon = testSprite;
 028            newSectionConfig.text = "TestSection";
 029            newSectionConfig.menuButtonPrefab = new GameObject().AddComponent<SettingsButtonEntry>();
 030            newSectionConfig.sectionPrefab = new GameObject().AddComponent<SettingsSectionView>();
 031            newSectionConfig.sectionController = ScriptableObject.CreateInstance<SettingsSectionController>();
 032            newSectionConfig.widgets = new SettingsWidgetList();
 033        }
 34
 35        [TearDown]
 36        public void TearDown()
 37        {
 038            Object.DestroyImmediate(testSprite);
 039            panelController.sections.Clear();
 040        }
 41
 42        [Test]
 43        public void AddSectionCorrectly()
 44        {
 45            // Act
 046            panelController.AddSection(null, newSectionView, newSectionController, newSectionConfig);
 47
 48            // Assert
 049            newSectionView.Received(1).Initialize(newSectionController, Arg.Any<List<SettingsWidgetModel>>());
 050            newSectionView.Received(1).SetActive(false);
 051            Assert.Contains(newSectionView, panelController.sections, "The new section should be contained in the sectio
 052        }
 53
 54        [Test]
 55        public void OpenSectionCorrectly()
 56        {
 57            //Arrange
 058            panelController.AddSection(null, newSectionView, newSectionController, newSectionConfig);
 59
 60            // Act
 061            panelController.OpenSection(newSectionView);
 62
 63            // Assert
 064            newSectionView.Received(1).SetActive(true);
 065        }
 66
 67        [Test]
 68        public void OpenSectionByIndexCorrectly()
 69        {
 70            //Arrange
 071            panelController.AddSection(null, newSectionView, newSectionController, newSectionConfig);
 72
 73            // Act
 074            panelController.OpenSection(panelController.sections.Count - 1);
 75
 76            // Assert
 077            newSectionView.Received(1).SetActive(true);
 078        }
 79    }
 80}