| | 1 | | using DCL.Controllers; |
| | 2 | | using NSubstitute; |
| | 3 | | using NSubstitute.Extensions; |
| | 4 | | using NUnit.Framework; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using UnityEngine; |
| | 7 | |
|
| | 8 | | namespace Tests.BuildModeHUDControllers |
| | 9 | | { |
| | 10 | | public class BuildModeHUDControllerShould |
| | 11 | | { |
| | 12 | | private BuildModeHUDController buildModeHUDController; |
| | 13 | |
|
| | 14 | | [SetUp] |
| | 15 | | public void SetUp() |
| | 16 | | { |
| 45 | 17 | | BuildModeHUDInitializationModel testControllers = new BuildModeHUDInitializationModel |
| | 18 | | { |
| | 19 | | tooltipController = Substitute.For<ITooltipController>(), |
| | 20 | | sceneCatalogController = Substitute.For<ISceneCatalogController>(), |
| | 21 | | quickBarController = Substitute.For<IQuickBarController>(), |
| | 22 | | entityInformationController = Substitute.For<IEntityInformationController>(), |
| | 23 | | firstPersonModeController = Substitute.For<IFirstPersonModeController>(), |
| | 24 | | shortcutsController = Substitute.For<IShortcutsController>(), |
| | 25 | | publishPopupController = Substitute.For<IPublishPopupController>(), |
| | 26 | | dragAndDropSceneObjectController = Substitute.For<IDragAndDropSceneObjectController>(), |
| | 27 | | publishBtnController = Substitute.For<IPublishBtnController>(), |
| | 28 | | inspectorBtnController = Substitute.For<IInspectorBtnController>(), |
| | 29 | | catalogBtnController = Substitute.For<ICatalogBtnController>(), |
| | 30 | | inspectorController = Substitute.For<IInspectorController>(), |
| | 31 | | buildModeConfirmationModalController = Substitute.For<IBuildModeConfirmationModalController>(), |
| | 32 | | topActionsButtonsController = Substitute.For<ITopActionsButtonsController>(), |
| | 33 | | saveHUDController = Substitute.For<ISaveHUDController>(), |
| | 34 | | newProjectDetailsController = Substitute.For<IPublicationDetailsController>(), |
| | 35 | | publicationDetailsController = Substitute.For<IPublicationDetailsController>() |
| | 36 | | }; |
| | 37 | |
|
| 45 | 38 | | buildModeHUDController = Substitute.ForPartsOf<BuildModeHUDController>(); |
| 91 | 39 | | buildModeHUDController.Configure().CreateView().Returns(info => Substitute.For<IBuildModeHUDView>()); |
| 45 | 40 | | buildModeHUDController.Initialize(testControllers); |
| 45 | 41 | | } |
| | 42 | |
|
| | 43 | | [TearDown] |
| 45 | 44 | | public void TearDown() { } |
| | 45 | |
|
| | 46 | | [Test] |
| | 47 | | public void CreateBuildModeControllersCorrectly() |
| | 48 | | { |
| | 49 | | // Arrange |
| 1 | 50 | | buildModeHUDController.controllers.tooltipController = null; |
| 1 | 51 | | buildModeHUDController.controllers.sceneCatalogController = null; |
| 1 | 52 | | buildModeHUDController.controllers.quickBarController = null; |
| 1 | 53 | | buildModeHUDController.controllers.entityInformationController = null; |
| 1 | 54 | | buildModeHUDController.controllers.firstPersonModeController = null; |
| 1 | 55 | | buildModeHUDController.controllers.shortcutsController = null; |
| 1 | 56 | | buildModeHUDController.controllers.publishPopupController = null; |
| 1 | 57 | | buildModeHUDController.controllers.dragAndDropSceneObjectController = null; |
| 1 | 58 | | buildModeHUDController.controllers.publishBtnController = null; |
| 1 | 59 | | buildModeHUDController.controllers.inspectorBtnController = null; |
| 1 | 60 | | buildModeHUDController.controllers.catalogBtnController = null; |
| 1 | 61 | | buildModeHUDController.controllers.inspectorController = null; |
| 1 | 62 | | buildModeHUDController.controllers.topActionsButtonsController = null; |
| 1 | 63 | | buildModeHUDController.controllers.saveHUDController = null; |
| 1 | 64 | | buildModeHUDController.controllers.newProjectDetailsController = null; |
| 1 | 65 | | buildModeHUDController.controllers.publicationDetailsController = null; |
| | 66 | |
|
| | 67 | | // Act |
| 1 | 68 | | buildModeHUDController.CreateBuildModeControllers(); |
| | 69 | |
|
| | 70 | | // Assert |
| 1 | 71 | | Assert.NotNull(buildModeHUDController.controllers.tooltipController, "The tooltipController is null!"); |
| 1 | 72 | | Assert.NotNull(buildModeHUDController.controllers.sceneCatalogController, "The sceneCatalogController is nul |
| 1 | 73 | | Assert.NotNull(buildModeHUDController.controllers.quickBarController, "The quickBarController is null!"); |
| 1 | 74 | | Assert.NotNull(buildModeHUDController.controllers.entityInformationController, "The entityInformationControl |
| 1 | 75 | | Assert.NotNull(buildModeHUDController.controllers.firstPersonModeController, "The firstPersonModeController |
| 1 | 76 | | Assert.NotNull(buildModeHUDController.controllers.shortcutsController, "The shortcutsController is null!"); |
| 1 | 77 | | Assert.NotNull(buildModeHUDController.controllers.publishPopupController, "The publishPopupController is nul |
| 1 | 78 | | Assert.NotNull(buildModeHUDController.controllers.dragAndDropSceneObjectController, "The dragAndDropSceneObj |
| 1 | 79 | | Assert.NotNull(buildModeHUDController.controllers.publishBtnController, "The publishBtnController is null!") |
| 1 | 80 | | Assert.NotNull(buildModeHUDController.controllers.inspectorBtnController, "The inspectorBtnController is nul |
| 1 | 81 | | Assert.NotNull(buildModeHUDController.controllers.catalogBtnController, "The catalogBtnController is null!") |
| 1 | 82 | | Assert.NotNull(buildModeHUDController.controllers.inspectorController, "The inspectorController is null!"); |
| 1 | 83 | | Assert.NotNull(buildModeHUDController.controllers.topActionsButtonsController, "The topActionsButtonsControl |
| 1 | 84 | | Assert.NotNull(buildModeHUDController.controllers.saveHUDController, "The saveHUDController is null!"); |
| 1 | 85 | | Assert.NotNull(buildModeHUDController.controllers.newProjectDetailsController, "The newProjectDetailsControl |
| 1 | 86 | | Assert.NotNull(buildModeHUDController.controllers.publicationDetailsController, "The publicationDetailsContr |
| 1 | 87 | | } |
| | 88 | |
|
| | 89 | | [Test] |
| | 90 | | public void CreateMainViewCorrectly() |
| | 91 | | { |
| | 92 | | // Arrange |
| 1 | 93 | | buildModeHUDController.view = null; |
| | 94 | |
|
| | 95 | | // Act |
| 1 | 96 | | buildModeHUDController.CreateMainView(); |
| | 97 | |
|
| | 98 | | // Assert |
| 1 | 99 | | Assert.NotNull(buildModeHUDController.view, "The view is null!"); |
| 1 | 100 | | buildModeHUDController.view.Received(1).Initialize(buildModeHUDController.controllers); |
| 1 | 101 | | } |
| | 102 | |
|
| | 103 | | [Test] |
| | 104 | | [TestCase("")] |
| | 105 | | [TestCase("Test name")] |
| | 106 | | public void SetBuilderProjectInfoCorrectly(string projectName) |
| | 107 | | { |
| | 108 | | // Arrange |
| 2 | 109 | | string testDesc = "Test name"; |
| | 110 | |
|
| | 111 | | // Act |
| 2 | 112 | | buildModeHUDController.SetBuilderProjectInfo(projectName, testDesc); |
| | 113 | |
|
| | 114 | | // Assert |
| 2 | 115 | | if (!string.IsNullOrEmpty(projectName)) |
| | 116 | | { |
| 1 | 117 | | buildModeHUDController.controllers.newProjectDetailsController.Received(1).SetCustomPublicationInfo(proj |
| 1 | 118 | | buildModeHUDController.controllers.publicationDetailsController.Received(1).SetCustomPublicationInfo(pro |
| 1 | 119 | | } |
| | 120 | | else |
| | 121 | | { |
| 1 | 122 | | buildModeHUDController.controllers.newProjectDetailsController.Received(1).SetDefaultPublicationInfo(); |
| 1 | 123 | | buildModeHUDController.controllers.publicationDetailsController.Received(1).SetDefaultPublicationInfo(); |
| | 124 | | } |
| 1 | 125 | | } |
| | 126 | |
|
| | 127 | | [Test] |
| | 128 | | public void StartNewProjectFlowCorrectly() |
| | 129 | | { |
| | 130 | | // Arrange |
| 1 | 131 | | Texture2D testScreenshot = new Texture2D(10, 10); |
| | 132 | |
|
| | 133 | | // Act |
| 1 | 134 | | buildModeHUDController.NewProjectStart(testScreenshot); |
| | 135 | |
|
| | 136 | | // Assert |
| 1 | 137 | | buildModeHUDController.controllers.newProjectDetailsController.Received(1).SetPublicationScreenshot(testScre |
| | 138 | |
|
| | 139 | | // TODO: This is temporal until we add the Welcome panel where the user will be able to edit the project inf |
| | 140 | | //buildModeHUDController.controllers.newProjectDetailsController.Received(1).SetActive(true); |
| 1 | 141 | | } |
| | 142 | |
|
| | 143 | | [Test] |
| | 144 | | public void ConfirmNewProjectDetailsCorrectly() |
| | 145 | | { |
| | 146 | | // Arrange |
| 1 | 147 | | bool newProjectDetailsConfirmed = false; |
| 1 | 148 | | buildModeHUDController.OnSaveSceneInfoAction += (name, desc, image) => |
| | 149 | | { |
| 1 | 150 | | newProjectDetailsConfirmed = true; |
| 1 | 151 | | }; |
| | 152 | |
|
| | 153 | | // Act |
| 1 | 154 | | buildModeHUDController.SaveSceneInfo(); |
| | 155 | |
|
| | 156 | | // Assert |
| 1 | 157 | | buildModeHUDController.controllers.newProjectDetailsController.Received(1).GetSceneScreenshotTexture(); |
| 1 | 158 | | buildModeHUDController.controllers.newProjectDetailsController.Received(1).GetSceneName(); |
| 1 | 159 | | buildModeHUDController.controllers.newProjectDetailsController.Received(1).GetSceneDescription(); |
| 1 | 160 | | buildModeHUDController.controllers.publicationDetailsController.Received(1).SetCustomPublicationInfo(Arg.Any |
| 1 | 161 | | buildModeHUDController.controllers.newProjectDetailsController.Received(1).SetActive(false); |
| 1 | 162 | | Assert.IsTrue(newProjectDetailsConfirmed); |
| 1 | 163 | | } |
| | 164 | |
|
| | 165 | | [Test] |
| | 166 | | public void CancelNewProjectDetailsCorrectly() |
| | 167 | | { |
| | 168 | | // Act |
| 1 | 169 | | buildModeHUDController.CancelNewProjectDetails(); |
| | 170 | |
|
| | 171 | | // Assert |
| 1 | 172 | | buildModeHUDController.controllers.newProjectDetailsController.Received(1).SetActive(false); |
| 1 | 173 | | } |
| | 174 | |
|
| | 175 | | [Test] |
| | 176 | | public void PublishStartCorrectly() |
| | 177 | | { |
| | 178 | | // Act |
| 1 | 179 | | buildModeHUDController.PublishStart(); |
| | 180 | |
|
| | 181 | | // Assert |
| 1 | 182 | | buildModeHUDController.controllers.publicationDetailsController.Received(1).SetActive(true); |
| 1 | 183 | | } |
| | 184 | |
|
| | 185 | | [Test] |
| | 186 | | public void ConfirmPublicationDetailsCorrectly() |
| | 187 | | { |
| | 188 | | // Act |
| 1 | 189 | | buildModeHUDController.ConfirmPublicationDetails(); |
| | 190 | |
|
| | 191 | | // Assert |
| 1 | 192 | | buildModeHUDController.controllers.buildModeConfirmationModalController.Received(1) |
| | 193 | | .Configure( |
| | 194 | | Arg.Any<string>(), |
| | 195 | | Arg.Any<string>(), |
| | 196 | | Arg.Any<string>(), |
| | 197 | | Arg.Any<string>()); |
| 1 | 198 | | buildModeHUDController.controllers.buildModeConfirmationModalController.Received(1).SetActive(true, BuildMod |
| 1 | 199 | | } |
| | 200 | |
|
| | 201 | | [Test] |
| | 202 | | public void CancelPublicationDetailsCorrectly() |
| | 203 | | { |
| | 204 | | // Act |
| 1 | 205 | | buildModeHUDController.CancelPublishModal(BuildModeModalType.PUBLISH); |
| | 206 | |
|
| | 207 | | // Assert |
| 1 | 208 | | buildModeHUDController.controllers.buildModeConfirmationModalController.Received(1).SetActive(false, BuildMo |
| 1 | 209 | | buildModeHUDController.controllers.publicationDetailsController.Received(1).SetActive(true); |
| 1 | 210 | | } |
| | 211 | |
|
| | 212 | | [Test] |
| | 213 | | public void CancelPublishModalCorrectly() |
| | 214 | | { |
| | 215 | | // Act |
| 1 | 216 | | buildModeHUDController.CancelPublicationDetails(); |
| | 217 | |
|
| | 218 | | // Assert |
| 1 | 219 | | buildModeHUDController.controllers.publicationDetailsController.Received(1).SetActive(false); |
| 1 | 220 | | } |
| | 221 | |
|
| | 222 | | [Test] |
| | 223 | | public void ConfirmPublishModalCorrectly() |
| | 224 | | { |
| | 225 | | // Arrange |
| 1 | 226 | | bool publishConfirmed = false; |
| 3 | 227 | | buildModeHUDController.OnConfirmPublishAction += (sceneName, sceneDesc, sceneScreenshot) => { publishConfirm |
| | 228 | |
|
| | 229 | | // Act |
| 1 | 230 | | buildModeHUDController.ConfirmPublishModal(BuildModeModalType.PUBLISH); |
| | 231 | |
|
| | 232 | | // Assert |
| 1 | 233 | | buildModeHUDController.controllers.publishPopupController.Received(1).PublishStart(); |
| 1 | 234 | | Assert.IsTrue(publishConfirmed, "publishConfirmed is false!"); |
| 1 | 235 | | } |
| | 236 | |
|
| | 237 | | [Test] |
| | 238 | | public void ExitStartCorrectly() |
| | 239 | | { |
| | 240 | | // Act |
| 1 | 241 | | buildModeHUDController.ExitStart(); |
| | 242 | |
|
| | 243 | | // Assert |
| 1 | 244 | | buildModeHUDController.controllers.buildModeConfirmationModalController.Received(1).SetActive(true, BuildMod |
| 1 | 245 | | } |
| | 246 | |
|
| | 247 | | [Test] |
| | 248 | | public void CancelExitModalCorrectly() |
| | 249 | | { |
| | 250 | | // Act |
| 1 | 251 | | buildModeHUDController.CancelExitModal(BuildModeModalType.EXIT); |
| | 252 | |
|
| | 253 | | // Assert |
| 1 | 254 | | buildModeHUDController.controllers.buildModeConfirmationModalController.Received(1).SetActive(false, BuildMo |
| 1 | 255 | | } |
| | 256 | |
|
| | 257 | | [Test] |
| | 258 | | public void ConfirmExitModalCorrectly() |
| | 259 | | { |
| | 260 | | // Arrange |
| 1 | 261 | | bool exitConfirmed = false; |
| 3 | 262 | | buildModeHUDController.OnLogoutAction += () => { exitConfirmed = true; }; |
| | 263 | |
|
| | 264 | | // Act |
| 1 | 265 | | buildModeHUDController.ConfirmExitModal(BuildModeModalType.EXIT); |
| | 266 | |
|
| | 267 | | // Assert |
| 1 | 268 | | Assert.IsTrue(exitConfirmed, "exitConfirmed is false!"); |
| 1 | 269 | | buildModeHUDController.controllers.publicationDetailsController.Received().SetDefaultPublicationInfo(); |
| 1 | 270 | | } |
| | 271 | |
|
| | 272 | | [Test] |
| | 273 | | [TestCase(true)] |
| | 274 | | [TestCase(false)] |
| | 275 | | public void PublishEndCorrectly(bool isOk) |
| | 276 | | { |
| | 277 | | // Arrange |
| 2 | 278 | | string testErrorMessage = "Test text"; |
| | 279 | |
|
| | 280 | | // Act |
| 2 | 281 | | buildModeHUDController.PublishEnd(isOk, testErrorMessage); |
| | 282 | |
|
| | 283 | | // Assert |
| 2 | 284 | | buildModeHUDController.controllers.publishPopupController.Received(1).PublishEnd(isOk, testErrorMessage); |
| 2 | 285 | | } |
| | 286 | |
|
| | 287 | | [Test] |
| | 288 | | public void SetParcelSceneCorrectly() |
| | 289 | | { |
| | 290 | | // Arrange |
| 1 | 291 | | ParcelScene testParcelScene = new GameObject("_ParcelScene").AddComponent<ParcelScene>(); |
| | 292 | |
|
| | 293 | | // Act |
| 1 | 294 | | buildModeHUDController.SetParcelScene(testParcelScene); |
| | 295 | |
|
| | 296 | | // Assert |
| 1 | 297 | | buildModeHUDController.controllers.inspectorController.sceneLimitsController.Received(1).SetParcelScene(test |
| 1 | 298 | | } |
| | 299 | |
|
| | 300 | | [Test] |
| | 301 | | [TestCase(true)] |
| | 302 | | [TestCase(false)] |
| | 303 | | public void SetPublishBtnAvailabilityCorrectly(bool isAvailable) |
| | 304 | | { |
| | 305 | | // Act |
| 2 | 306 | | buildModeHUDController.SetPublishBtnAvailability(isAvailable); |
| | 307 | |
|
| | 308 | | // Assert |
| 2 | 309 | | buildModeHUDController.view.Received(1).SetPublishBtnAvailability(isAvailable); |
| 2 | 310 | | } |
| | 311 | |
|
| | 312 | | [Test] |
| | 313 | | public void RefreshCatalogAssetPackCorrectly() |
| | 314 | | { |
| | 315 | | // Act |
| 1 | 316 | | buildModeHUDController.RefreshCatalogAssetPack(); |
| | 317 | |
|
| | 318 | | // Assert |
| 1 | 319 | | buildModeHUDController.view.Received(1).RefreshCatalogAssetPack(); |
| 1 | 320 | | } |
| | 321 | |
|
| | 322 | | [Test] |
| | 323 | | public void RefreshCatalogContentCorrectly() |
| | 324 | | { |
| | 325 | | // Act |
| 1 | 326 | | buildModeHUDController.RefreshCatalogContent(); |
| | 327 | |
|
| | 328 | | // Assert |
| 1 | 329 | | buildModeHUDController.view.Received(1).RefreshCatalogContent(); |
| 1 | 330 | | } |
| | 331 | |
|
| | 332 | | [Test] |
| | 333 | | public void CatalogItemSelectedCorrectly() |
| | 334 | | { |
| | 335 | | // Arrange |
| 1 | 336 | | CatalogItem returnedCatalogItem = null; |
| 1 | 337 | | CatalogItem testCatalogItem = new CatalogItem(); |
| 3 | 338 | | buildModeHUDController.OnCatalogItemSelected += (item) => { returnedCatalogItem = item; }; |
| | 339 | |
|
| | 340 | | // Act |
| 1 | 341 | | buildModeHUDController.CatalogItemSelected(testCatalogItem); |
| | 342 | |
|
| | 343 | | // Assert |
| 1 | 344 | | Assert.AreEqual(testCatalogItem, returnedCatalogItem, "The catalog item does not march!"); |
| 1 | 345 | | } |
| | 346 | |
|
| | 347 | | [Test] |
| | 348 | | [TestCase(true)] |
| | 349 | | [TestCase(false)] |
| | 350 | | public void SetVisibilityOfCatalogCorrectly(bool isVisible) |
| | 351 | | { |
| | 352 | | // Arrange |
| 2 | 353 | | bool catalogOpened = false; |
| 2 | 354 | | buildModeHUDController.isCatalogOpen = !isVisible; |
| 4 | 355 | | buildModeHUDController.OnCatalogOpen += () => { catalogOpened = true; }; |
| | 356 | |
|
| | 357 | | // Act |
| 2 | 358 | | buildModeHUDController.SetVisibilityOfCatalog(isVisible); |
| | 359 | |
|
| | 360 | | // Assert |
| 2 | 361 | | Assert.AreEqual(isVisible, buildModeHUDController.isCatalogOpen, "The isCatalogOpen does not match!"); |
| 2 | 362 | | buildModeHUDController.view.Received(1).SetVisibilityOfCatalog(buildModeHUDController.isCatalogOpen); |
| | 363 | |
|
| 2 | 364 | | if (isVisible) |
| 1 | 365 | | Assert.IsTrue(catalogOpened, "catalogOpened is false!"); |
| 2 | 366 | | } |
| | 367 | |
|
| | 368 | | [Test] |
| | 369 | | public void ChangeVisibilityOfCatalogCorrectly() |
| | 370 | | { |
| | 371 | | // Arrange |
| 1 | 372 | | buildModeHUDController.isCatalogOpen = buildModeHUDController.controllers.sceneCatalogController.IsCatalogOp |
| | 373 | |
|
| | 374 | | // Act |
| 1 | 375 | | buildModeHUDController.ChangeVisibilityOfCatalog(); |
| | 376 | |
|
| | 377 | | // Assert |
| 1 | 378 | | Assert.AreEqual( |
| | 379 | | !buildModeHUDController.controllers.sceneCatalogController.IsCatalogOpen(), |
| | 380 | | buildModeHUDController.isCatalogOpen, |
| | 381 | | "The isCatalogOpen does not match!"); |
| 1 | 382 | | } |
| | 383 | |
|
| | 384 | | [Test] |
| | 385 | | public void UpdateSceneLimitInfoCorrectly() |
| | 386 | | { |
| | 387 | | // Act |
| 1 | 388 | | buildModeHUDController.UpdateSceneLimitInfo(); |
| | 389 | |
|
| | 390 | | // Assert |
| 1 | 391 | | buildModeHUDController.controllers.inspectorController.sceneLimitsController.Received(1).UpdateInfo(); |
| 1 | 392 | | } |
| | 393 | |
|
| | 394 | | [Test] |
| | 395 | | [TestCase(true)] |
| | 396 | | [TestCase(false)] |
| | 397 | | public void ChangeVisibilityOfSceneInfoCorrectly(bool shouldBeVisible) |
| | 398 | | { |
| | 399 | | // Arrange |
| 2 | 400 | | buildModeHUDController.isSceneLimitInfoVisibile = !shouldBeVisible; |
| | 401 | |
|
| | 402 | | // Act |
| 2 | 403 | | buildModeHUDController.ChangeVisibilityOfSceneInfo(shouldBeVisible); |
| | 404 | |
|
| | 405 | | // Assert |
| 2 | 406 | | Assert.AreEqual(shouldBeVisible, buildModeHUDController.isSceneLimitInfoVisibile, "The isSceneLimitInfoVisib |
| 2 | 407 | | buildModeHUDController.view.Received(1).SetVisibilityOfSceneInfo(buildModeHUDController.isSceneLimitInfoVisi |
| 2 | 408 | | } |
| | 409 | |
|
| | 410 | | [Test] |
| | 411 | | public void ChangeVisibilityOfSceneInfoCorrectly() |
| | 412 | | { |
| | 413 | | // Arrange |
| 1 | 414 | | buildModeHUDController.isSceneLimitInfoVisibile = false; |
| | 415 | |
|
| | 416 | | // Act |
| 1 | 417 | | buildModeHUDController.ChangeVisibilityOfSceneInfo(); |
| | 418 | |
|
| | 419 | | // Assert |
| 1 | 420 | | Assert.IsTrue(buildModeHUDController.isSceneLimitInfoVisibile, "The isSceneLimitInfoVisibile is false!"); |
| 1 | 421 | | buildModeHUDController.view.Received(1).SetVisibilityOfSceneInfo(buildModeHUDController.isSceneLimitInfoVisi |
| 1 | 422 | | } |
| | 423 | |
|
| | 424 | | [Test] |
| | 425 | | public void ActivateFirstPersonModeUICorrectly() |
| | 426 | | { |
| | 427 | | // Act |
| 1 | 428 | | buildModeHUDController.ActivateFirstPersonModeUI(); |
| | 429 | |
|
| | 430 | | // Assert |
| 1 | 431 | | buildModeHUDController.view.Received(1).SetFirstPersonView(); |
| 1 | 432 | | } |
| | 433 | |
|
| | 434 | | [Test] |
| | 435 | | public void ActivateGodModeUICorrectly() |
| | 436 | | { |
| | 437 | | // Act |
| 1 | 438 | | buildModeHUDController.ActivateGodModeUI(); |
| | 439 | |
|
| | 440 | | // Assert |
| 1 | 441 | | buildModeHUDController.view.Received(1).SetGodModeView(); |
| 1 | 442 | | } |
| | 443 | |
|
| | 444 | | [Test] |
| | 445 | | public void EntityInformationSetEntityCorrectly() |
| | 446 | | { |
| | 447 | | // Arrange |
| 1 | 448 | | DCLBuilderInWorldEntity testEntity = new GameObject("_DCLBuilderInWorldEntity").AddComponent<DCLBuilderInWor |
| 1 | 449 | | ParcelScene testScene = new GameObject("_ParcelScene").AddComponent<ParcelScene>(); |
| | 450 | |
|
| | 451 | | // Act |
| 1 | 452 | | buildModeHUDController.EntityInformationSetEntity(testEntity, testScene); |
| | 453 | |
|
| | 454 | | // Assert |
| 1 | 455 | | buildModeHUDController.controllers.entityInformationController.Received(1).SetEntity(testEntity, testScene); |
| 1 | 456 | | } |
| | 457 | |
|
| | 458 | | [Test] |
| | 459 | | [TestCase(true)] |
| | 460 | | [TestCase(false)] |
| | 461 | | public void ShowEntityInformationCorrectly(bool activateTransparencyMode) |
| | 462 | | { |
| | 463 | | // Act |
| 2 | 464 | | buildModeHUDController.ShowEntityInformation(activateTransparencyMode); |
| | 465 | |
|
| | 466 | | // Assert |
| 2 | 467 | | buildModeHUDController.controllers.entityInformationController.Received(1).Enable(); |
| 2 | 468 | | buildModeHUDController.controllers.entityInformationController.Received(1).SetTransparencyMode(activateTrans |
| 2 | 469 | | buildModeHUDController.controllers.sceneCatalogController.Received(1).CloseCatalog(); |
| 2 | 470 | | buildModeHUDController.controllers.tooltipController.Received(1).HideTooltip(); |
| | 471 | |
|
| 2 | 472 | | if (activateTransparencyMode) |
| 1 | 473 | | buildModeHUDController.controllers.catalogBtnController.Received(1).SetActive(false); |
| 2 | 474 | | } |
| | 475 | |
|
| | 476 | | [Test] |
| | 477 | | public void HideEntityInformationCorrectly() |
| | 478 | | { |
| | 479 | | // Act |
| 1 | 480 | | buildModeHUDController.HideEntityInformation(); |
| | 481 | |
|
| | 482 | | // Assert |
| 1 | 483 | | buildModeHUDController.controllers.entityInformationController.Received(1).Disable(); |
| 1 | 484 | | buildModeHUDController.controllers.catalogBtnController.Received(1).SetActive(true); |
| | 485 | |
|
| 1 | 486 | | if (buildModeHUDController.isCatalogOpen) |
| 0 | 487 | | buildModeHUDController.controllers.sceneCatalogController.Received(1).SetActive(true); |
| 1 | 488 | | } |
| | 489 | |
|
| | 490 | | [Test] |
| | 491 | | public void SetEntityListCorrectly() |
| | 492 | | { |
| | 493 | | // Arrange |
| 1 | 494 | | List<DCLBuilderInWorldEntity> testEntityList = new List<DCLBuilderInWorldEntity>(); |
| 1 | 495 | | testEntityList.Add(new GameObject("_DCLBuilderInWorldEntity1").AddComponent<DCLBuilderInWorldEntity>()); |
| 1 | 496 | | testEntityList.Add(new GameObject("_DCLBuilderInWorldEntity2").AddComponent<DCLBuilderInWorldEntity>()); |
| 1 | 497 | | testEntityList.Add(new GameObject("_DCLBuilderInWorldEntity3").AddComponent<DCLBuilderInWorldEntity>()); |
| | 498 | |
|
| | 499 | | // Act |
| 1 | 500 | | buildModeHUDController.SetEntityList(testEntityList); |
| | 501 | |
|
| | 502 | | // Assert |
| 1 | 503 | | buildModeHUDController.controllers.inspectorController.Received(1).SetEntityList(testEntityList); |
| 1 | 504 | | } |
| | 505 | |
|
| | 506 | | [Test] |
| | 507 | | [TestCase(true)] |
| | 508 | | [TestCase(false)] |
| | 509 | | public void ChangeVisibilityOfEntityListCorrectly(bool isVisible) |
| | 510 | | { |
| | 511 | | // Arrange |
| 2 | 512 | | bool isEntityListVisible = false; |
| 2 | 513 | | buildModeHUDController.isEntityListVisible = isVisible; |
| 4 | 514 | | buildModeHUDController.OnEntityListVisible += () => { isEntityListVisible = true; }; |
| | 515 | |
|
| | 516 | | // Act |
| 2 | 517 | | buildModeHUDController.ChangeVisibilityOfEntityList(); |
| | 518 | |
|
| | 519 | | // Assert |
| 2 | 520 | | if (buildModeHUDController.isEntityListVisible) |
| | 521 | | { |
| 1 | 522 | | Assert.IsTrue(isEntityListVisible, "isEntityListVisible is false!"); |
| 1 | 523 | | buildModeHUDController.controllers.inspectorController.Received(1).OpenEntityList(); |
| 1 | 524 | | } |
| | 525 | | else |
| | 526 | | { |
| 1 | 527 | | buildModeHUDController.controllers.inspectorController.Received(1).CloseList(); |
| | 528 | | } |
| 1 | 529 | | } |
| | 530 | |
|
| | 531 | | [Test] |
| | 532 | | public void ClearEntityListCorrectly() |
| | 533 | | { |
| | 534 | | // Act |
| 1 | 535 | | buildModeHUDController.ClearEntityList(); |
| | 536 | |
|
| | 537 | | // Assert |
| 1 | 538 | | buildModeHUDController.controllers.inspectorController.Received(1).ClearList(); |
| 1 | 539 | | } |
| | 540 | |
|
| | 541 | | [Test] |
| | 542 | | public void ChangeVisibilityOfControlsCorrectly() |
| | 543 | | { |
| | 544 | | // Arrange |
| 1 | 545 | | buildModeHUDController.isControlsVisible = false; |
| | 546 | |
|
| | 547 | | // Act |
| 1 | 548 | | buildModeHUDController.ChangeVisibilityOfControls(); |
| | 549 | |
|
| | 550 | | // Assert |
| 1 | 551 | | Assert.IsTrue(buildModeHUDController.isControlsVisible, "The isControlsVisible is false!"); |
| 1 | 552 | | buildModeHUDController.view.Received(1).SetVisibilityOfControls(buildModeHUDController.isControlsVisible); |
| 1 | 553 | | } |
| | 554 | |
|
| | 555 | | [Test] |
| | 556 | | public void ChangeVisibilityOfExtraBtnsCorrectly() |
| | 557 | | { |
| | 558 | | // Arrange |
| 1 | 559 | | buildModeHUDController.areExtraButtonsVisible = false; |
| | 560 | |
|
| | 561 | | // Act |
| 1 | 562 | | buildModeHUDController.ChangeVisibilityOfExtraBtns(); |
| | 563 | |
|
| | 564 | | // Assert |
| 1 | 565 | | Assert.IsTrue(buildModeHUDController.areExtraButtonsVisible, "The areExtraButtonsVisible is false!"); |
| 1 | 566 | | buildModeHUDController.view.Received(1).SetVisibilityOfExtraBtns(buildModeHUDController.areExtraButtonsVisib |
| 1 | 567 | | } |
| | 568 | |
|
| | 569 | | [Test] |
| | 570 | | [TestCase(true)] |
| | 571 | | [TestCase(false)] |
| | 572 | | public void SetVisibilityOfInspectorCorrectly(bool isVisible) |
| | 573 | | { |
| | 574 | | // Act |
| 2 | 575 | | buildModeHUDController.SetVisibilityOfInspector(isVisible); |
| | 576 | |
|
| | 577 | | // Assert |
| 2 | 578 | | Assert.AreEqual(isVisible, buildModeHUDController.isEntityListVisible); |
| 2 | 579 | | buildModeHUDController.view.Received(1).SetVisibilityOfInspector(isVisible); |
| 2 | 580 | | } |
| | 581 | |
|
| | 582 | | [Test] |
| | 583 | | public void ConfigureConfirmationModalCorrectly() |
| | 584 | | { |
| | 585 | | // Arrange |
| 1 | 586 | | string testTitle = "test title"; |
| 1 | 587 | | string testSubTitle = "test subTitle"; |
| 1 | 588 | | string testCancelText = "test cancel"; |
| 1 | 589 | | string testConfirmText = "test confirm"; |
| | 590 | |
|
| | 591 | | // Act |
| 1 | 592 | | buildModeHUDController.ConfigureConfirmationModal(testTitle, testSubTitle, testCancelText, testConfirmText); |
| | 593 | |
|
| | 594 | | // Assert |
| 1 | 595 | | buildModeHUDController.controllers.buildModeConfirmationModalController.Received(1).Configure(testTitle, tes |
| 1 | 596 | | } |
| | 597 | | } |
| | 598 | | } |