| | 1 | | using DCL.SettingsPanelHUD.Controls; |
| | 2 | | using DCL.SettingsPanelHUD.Sections; |
| | 3 | | using DCL.SettingsPanelHUD.Widgets; |
| | 4 | | using NSubstitute; |
| | 5 | | using NUnit.Framework; |
| | 6 | | using System.Collections.Generic; |
| | 7 | | using UnityEngine; |
| | 8 | |
|
| | 9 | | namespace SettingsSectionTests |
| | 10 | | { |
| | 11 | | public class SettingsSectionShould_EditMode |
| | 12 | | { |
| | 13 | | [Test] |
| | 14 | | public void AddWidgetCorrectly() |
| | 15 | | { |
| | 16 | | // Arrange |
| 0 | 17 | | var newWidgetView = Substitute.For<ISettingsWidgetView>(); |
| 0 | 18 | | var newWidgetController = Substitute.For<ISettingsWidgetController>(); |
| 0 | 19 | | var newWidgetConfig = ScriptableObject.CreateInstance<SettingsWidgetModel>(); |
| 0 | 20 | | newWidgetConfig.title = "TestWidget"; |
| 0 | 21 | | newWidgetConfig.widgetPrefab = new GameObject().AddComponent<SettingsWidgetView>(); |
| 0 | 22 | | newWidgetConfig.widgetController = ScriptableObject.CreateInstance<SettingsWidgetController>(); |
| 0 | 23 | | newWidgetConfig.controlColumns = new SettingsControlGroupList(); |
| | 24 | |
|
| 0 | 25 | | SettingsSectionController sectionController = ScriptableObject.CreateInstance<SettingsSectionController>(); |
| | 26 | |
|
| | 27 | | // Act |
| 0 | 28 | | sectionController.AddWidget(newWidgetView, newWidgetController, newWidgetConfig); |
| | 29 | |
|
| | 30 | | // Assert |
| 0 | 31 | | newWidgetView.Received(1) |
| | 32 | | .Initialize( |
| | 33 | | newWidgetConfig.title, |
| | 34 | | newWidgetController, |
| | 35 | | Arg.Any<List<SettingsControlGroup>>()); |
| | 36 | |
|
| 0 | 37 | | Assert.Contains(newWidgetView, sectionController.widgets, "The new widget should be contained in the widget |
| 0 | 38 | | } |
| | 39 | | } |
| | 40 | | } |