| | 1 | | using DCL.SettingsControls; |
| | 2 | | using DCL.SettingsPanelHUD.Controls; |
| | 3 | | using DCL.SettingsPanelHUD.Widgets; |
| | 4 | | using NSubstitute; |
| | 5 | | using NUnit.Framework; |
| | 6 | | using System.Collections.Generic; |
| | 7 | | using UnityEngine; |
| | 8 | |
|
| | 9 | | namespace SettingsWidgetTests |
| | 10 | | { |
| | 11 | |
|
| | 12 | | public class SettingsWidgetShould_EditMode |
| | 13 | | { |
| | 14 | | [Test] |
| | 15 | | public void AddControlCorrectly() |
| | 16 | | { |
| | 17 | | // Arrange |
| 0 | 18 | | var newControlView = Substitute.For<ISettingsControlView>(); |
| 0 | 19 | | var newControlController = ScriptableObject.CreateInstance<SettingsControlController>(); |
| 0 | 20 | | var newControlConfig = ScriptableObject.CreateInstance<SettingsControlModel>(); |
| 0 | 21 | | newControlConfig.title = "TestControl"; |
| 0 | 22 | | newControlConfig.controlPrefab = new GameObject().AddComponent<SettingsControlView>(); |
| 0 | 23 | | newControlConfig.controlController = ScriptableObject.CreateInstance<SettingsControlController>(); |
| 0 | 24 | | newControlConfig.flagsThatDeactivateMe = new List<BooleanVariable>(); |
| 0 | 25 | | newControlConfig.flagsThatDisableMe = new List<BooleanVariable>(); |
| 0 | 26 | | newControlConfig.isBeta = false; |
| | 27 | |
|
| 0 | 28 | | SettingsWidgetController widgetController = ScriptableObject.CreateInstance<SettingsWidgetController>(); |
| | 29 | |
|
| | 30 | | // Act |
| 0 | 31 | | widgetController.AddControl(newControlView, newControlController, newControlConfig); |
| | 32 | |
|
| | 33 | | // Assert |
| 0 | 34 | | newControlView.Received(1) |
| | 35 | | .Initialize( |
| | 36 | | newControlConfig, |
| | 37 | | newControlController); |
| | 38 | |
|
| 0 | 39 | | Assert.Contains(newControlView, widgetController.controls, "The new control should be contained in the contr |
| 0 | 40 | | Assert.IsTrue(SettingsPanelDataStore.i.controls.controlControllers.Contains(newControlController)); |
| 0 | 41 | | } |
| | 42 | | } |
| | 43 | | } |