< Summary

Class:BIWSearchBarShould
Assembly:BuildModeHUDTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuildModeHUD/Tests/BIWSearchBarShould.cs
Covered lines:58
Uncovered lines:0
Coverable lines:58
Total lines:164
Line coverage:100% (58 of 58)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%110100%
TearDown()0%220100%
AddNewSceneObjectCategoryToFilterCorrectly()0%110100%
FilterByName()0%110100%
FilterByNameNoResult()0%110100%
FilterByCategory()0%110100%
FilterByCategoryNoResult()0%110100%
FilterByTag()0%110100%
FilterByTagNoResult()0%110100%
FilterBySmartItem()0%110100%
FilterBySmartItemNoResult()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuildModeHUD/Tests/BIWSearchBarShould.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using NSubstitute;
 4using NUnit.Framework;
 5using UnityEngine;
 6
 7public class BIWSearchBarShould : MonoBehaviour
 8{
 9    private SceneCatalogController sceneCatalogController;
 10    private BIWSearchBarController biwSearchBarController;
 11    private GameObject gameObjectToUse;
 12
 13    [SetUp]
 14    public void SetUp()
 15    {
 916        BIWCatalogManager.Init();
 917        sceneCatalogController = new SceneCatalogController();
 918        sceneCatalogController.Initialize(
 19            Substitute.For<ISceneCatalogView>(),
 20            Substitute.For<IQuickBarController>());
 921        biwSearchBarController = sceneCatalogController.biwSearchBarController;
 922        gameObjectToUse = new GameObject("_TestObject");
 923        gameObjectToUse.AddComponent<AssetCatalogBridge>();
 924    }
 25
 26    [TearDown]
 27    public void TearDown()
 28    {
 929        AssetCatalogBridge.i.ClearCatalog();
 930        BIWCatalogManager.ClearCatalog();
 931        BIWCatalogManager.Dispose();
 932        sceneCatalogController.Dispose();
 933        if (gameObjectToUse != null)
 934            GameObject.Destroy(gameObjectToUse);
 935    }
 36
 37    [Test]
 38    public void AddNewSceneObjectCategoryToFilterCorrectly()
 39    {
 40        // Arrange
 141        string testCategory = "testCategory";
 42
 143        CatalogItem testCatalogItem = new CatalogItem { category = testCategory };
 144        biwSearchBarController.filterObjects.Clear();
 45
 46        // Act
 147        biwSearchBarController.AddNewSceneObjectCategoryToFilter(testCatalogItem);
 48
 49        // Assert
 150        Assert.AreEqual(1, biwSearchBarController.filterObjects.Count, "The number of filter objects does not match!");
 151        Assert.IsTrue(biwSearchBarController.filterObjects[0].ContainsKey(testCategory), "The test category has not been
 152    }
 53
 54    [Test]
 55    public void FilterByName()
 56    {
 57        // Arrange
 158        string nameToFilter = "dirt";
 159        BuilderInWorldTestHelper.CreateTestCatalogLocalSingleObject();
 60
 61        // Act
 162        biwSearchBarController.FilterAssets(nameToFilter);
 63
 64        // Assert
 165        Assert.AreEqual(1, biwSearchBarController.filterObjects.Count, "The number of filter objects does not match!");
 166    }
 67
 68    [Test]
 69    public void FilterByNameNoResult()
 70    {
 71        // Arrange
 172        string nameToFilter = "sand";
 173        BuilderInWorldTestHelper.CreateTestCatalogLocalSingleObject();
 74
 75        // Act
 176        biwSearchBarController.FilterAssets(nameToFilter);
 77
 78        // Assert
 179        Assert.AreEqual(0, biwSearchBarController.filterObjects.Count, "The number of filter objects does not match!");
 180    }
 81
 82    [Test]
 83    public void FilterByCategory()
 84    {
 85        // Arrange
 186        string nameToFilter = "decorations";
 187        BuilderInWorldTestHelper.CreateTestCatalogLocalSingleObject();
 88
 89        // Act
 190        biwSearchBarController.FilterAssets(nameToFilter);
 91
 92        // Assert
 193        Assert.AreEqual(1, biwSearchBarController.filterObjects.Count, "The number of filter objects does not match!");
 194    }
 95
 96    [Test]
 97    public void FilterByCategoryNoResult()
 98    {
 99        // Arrange
 1100        string nameToFilter = "structure";
 1101        BuilderInWorldTestHelper.CreateTestCatalogLocalSingleObject();
 102
 103        // Act
 1104        biwSearchBarController.FilterAssets(nameToFilter);
 105
 106        // Assert
 1107        Assert.AreEqual(0, biwSearchBarController.filterObjects.Count, "The number of filter objects does not match!");
 1108    }
 109
 110    [Test]
 111    public void FilterByTag()
 112    {
 113        // Arrange
 1114        string nameToFilter = "fantasy";
 1115        BuilderInWorldTestHelper.CreateTestCatalogLocalSingleObject();
 116
 117        // Act
 1118        biwSearchBarController.FilterAssets(nameToFilter);
 119
 120        // Assert
 1121        Assert.AreEqual(1, biwSearchBarController.filterObjects.Count, "The number of filter objects does not match!");
 1122    }
 123
 124    [Test]
 125    public void FilterByTagNoResult()
 126    {
 127        // Arrange
 1128        string nameToFilter = "wood";
 1129        BuilderInWorldTestHelper.CreateTestCatalogLocalSingleObject();
 130
 131        // Act
 1132        biwSearchBarController.FilterAssets(nameToFilter);
 133
 134        // Assert
 1135        Assert.AreEqual(0, biwSearchBarController.filterObjects.Count, "The number of filter objects does not match!");
 1136    }
 137
 138    [Test]
 139    public void FilterBySmartItem()
 140    {
 141        // Arrange
 1142        BuilderInWorldTestHelper.CreateTestSmartItemCatalogLocalSingleObject();
 143
 144        // Act
 1145        biwSearchBarController.ChangeSmartItemFilter();
 146
 147        //TODO: SmartItems implement again the test after kernel implement smart items
 148        // Assert
 149        //Assert.AreEqual(1, biwSearchBarController.filterObjects.Count, "The number of filter objects does not match!")
 1150    }
 151
 152    [Test]
 153    public void FilterBySmartItemNoResult()
 154    {
 155        // Arrange
 1156        BuilderInWorldTestHelper.CreateTestCatalogLocalSingleObject();
 157
 158        // Act
 1159        biwSearchBarController.ChangeSmartItemFilter();
 160
 161        // Assert
 1162        Assert.AreEqual(0, biwSearchBarController.filterObjects.Count, "The number of filter objects does not match!");
 1163    }
 164}