public void CalculateDuplicates_DoesNotIncludeSameBundleReferencedMultipleTimes()
        {
            //Setup
            var group1 = Settings.CreateGroup("CheckDupeDepencency1", false, false, false, null, typeof(BundledAssetGroupSchema));

            Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(k_CheckDupePrefabA), group1, false, false);

            var rule         = new CheckBundleDupeDependencies();
            var buildContext = rule.GetBuildContext(Settings);

            rule.CalculateInputDefinitions(Settings);
            rule.RefreshBuild(buildContext);

            var implicitGuids = rule.GetImplicitGuidToFilesMap();
            var key           = implicitGuids.Keys.First();

            implicitGuids[key].Add(implicitGuids[key][0]);

            //Test
            var results = rule.CalculateDuplicates(implicitGuids, buildContext).ToList();

            //Assert
            Assert.AreEqual(0, results.Count);

            //Cleanup
            Settings.RemoveGroup(group1);
        }
        public void RefreshBuild_ReturnsSuccess()
        {
            var rule = new CheckBundleDupeDependencies();
            AddressableAssetsBuildContext context = GetAddressableAssetsBuildContext(rule);

            Assert.AreEqual(ReturnCode.Success, rule.RefreshBuild(context));
        }
        public void BuildImplicitDuplicatedAssetsSet_BuildCorrectImplicitAssets()
        {
            //Setup
            var group1 = Settings.CreateGroup("CheckDupeDepencency1", false, false, false, null, typeof(BundledAssetGroupSchema));
            var group2 = Settings.CreateGroup("CheckDupeDepencency2", false, false, false, null, typeof(BundledAssetGroupSchema));

            Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(k_CheckDupePrefabA), group1, false, false);
            Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(k_CheckDupePrefabB), group2, false, false);

            GUID matGuid;
            var  matGuidString = AssetDatabase.AssetPathToGUID(k_CheckDupeMyMaterial);

            GUID.TryParse(matGuidString, out matGuid);

            var rule         = new CheckBundleDupeDependencies();
            var buildContext = rule.GetBuildContext(Settings);

            rule.CalculateInputDefinitions(Settings);
            rule.RefreshBuild(buildContext);

            var implicitGuids = rule.GetImplicitGuidToFilesMap();
            var results       = rule.CalculateDuplicates(implicitGuids, buildContext);

            //Test
            rule.BuildImplicitDuplicatedAssetsSet(results);

            //Assert
            Assert.AreEqual(1, rule.m_ImplicitAssets.Count);
            Assert.IsTrue(rule.m_ImplicitAssets.Contains(matGuid));

            //Cleanup
            Settings.RemoveGroup(group1);
            Settings.RemoveGroup(group2);
        }
        public void CalculateDuplicates_ReturnsCorrectCheckDupeResultList()
        {
            //Setup
            var group1 = Settings.CreateGroup("CheckDupeDepencency1", false, false, false, null, typeof(BundledAssetGroupSchema));
            var group2 = Settings.CreateGroup("CheckDupeDepencency2", false, false, false, null, typeof(BundledAssetGroupSchema));

            Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(k_CheckDupePrefabA), group1, false, false);
            Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(k_CheckDupePrefabB), group2, false, false);

            GUID matGuid;
            var  matGuidString = AssetDatabase.AssetPathToGUID(k_CheckDupeMyMaterial);

            GUID.TryParse(matGuidString, out matGuid);

            var rule = new CheckBundleDupeDependencies();

            var buildContext = rule.GetBuildContext(Settings);

            rule.CalculateInputDefinitions(Settings);
            rule.RefreshBuild(buildContext);
            var implicitGuids = rule.GetImplicitGuidToFilesMap();

            //Test
            var dupeResults = rule.CalculateDuplicates(implicitGuids, buildContext).ToList();

            //Assert
            Assert.AreEqual(2, dupeResults.Count);

            Assert.AreEqual(group1.Name, dupeResults[0].Group.Name);
            Assert.AreEqual(2, dupeResults[0].DuplicatedFiles.Count);
            Assert.AreEqual(k_CheckDupeMyMaterial, dupeResults[0].AssetPath);

            Assert.AreEqual(group2.Name, dupeResults[1].Group.Name);
            Assert.AreEqual(2, dupeResults[1].DuplicatedFiles.Count);
            Assert.AreEqual(k_CheckDupeMyMaterial, dupeResults[1].AssetPath);

            //Cleanup
            Settings.RemoveGroup(group1);
            Settings.RemoveGroup(group2);
        }