public Given_a_reference_without_path_not_in_global_references_list()
            {
                this.reference = new BinaryReference
                {
                    Name = "mscorlib",
                    Referrer = "project"
                };

                this.check = new ProjectIntegrityCheck(Mock.Of<IFileSystem>(), ReferenceRegistry.Empty(), "libs");
            }
            public Given_a_reference_path_not_within_defined_libs_directory()
            {
                this.reference = new BinaryReference
                {
                    Name = "test",
                    Path = "somewhere\\test",
                    FullPath = "somewhere\\test",
                    Referrer = "project",
                };

                this.check = new BinaryReferenceInExternalLibrariesDirectoryCheck("lib");
            }
            public Given_a_non_existent_reference()
            {
                this.reference = new BinaryReference
                {
                    Name = "test",
                    Path = "test.dll",
                    FullPath = "test.dll",
                    Referrer = "project"
                };

                var fileSystemMock = new MockFileSystem(new Dictionary<string, MockFileData>
                {
                    {"another.dll", new MockFileData(String.Empty)}
                });

                this.check = new ReferenceExistsCheck(fileSystemMock);
            }
Example #4
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            SerializedProperty assetGuidProp = prop.FindPropertyRelative("assetGuid");
            SerializedProperty val0          = assetGuidProp.FindPropertyRelative("val0");
            SerializedProperty val1          = assetGuidProp.FindPropertyRelative("val1");
            SerializedProperty val2          = assetGuidProp.FindPropertyRelative("val2");
            SerializedProperty val3          = assetGuidProp.FindPropertyRelative("val3");

            BinaryReference binaryRef = new BinaryReference(val0.intValue, val1.intValue, val2.intValue, val3.intValue);

            Asset  asset        = null;
            string assetGuidStr = "";

            if (binaryRef.IsSet())
            {
                assetGuidStr = binaryRef.assetGuid.GetGuidStr();
                string assetPath = AssetDatabase.GUIDToAssetPath(assetGuidStr);
                asset = AssetDatabase.LoadAssetAtPath <Asset>(assetPath);
            }

            string labelStr = asset == null ? label.text : label.text + " (" + assetGuidStr + ")";

            pos = EditorGUI.PrefixLabel(pos, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(labelStr));
            Asset newAsset = EditorGUI.ObjectField(pos, asset, typeof(Asset), false) as Asset;

            if (newAsset != asset)
            {
                BinaryReference newBinaryRef = new BinaryReference();
                if (newAsset != null)
                {
                    newBinaryRef = newAsset.GetBinaryReference();
                    assetGuidStr = newBinaryRef.assetGuid.GetGuidStr();
                }

                val0.intValue = newBinaryRef.assetGuid.val0;
                val1.intValue = newBinaryRef.assetGuid.val1;
                val2.intValue = newBinaryRef.assetGuid.val2;
                val3.intValue = newBinaryRef.assetGuid.val3;
            }
        }
 public Given_a_reference_which_is_not_in_registry()
 {
     this.reference = new BinaryReference("mscorlib") {Referrer = "project"};
     var registry = ReferenceRegistry.Empty();
     this.check = new BinaryReferenceIsGlobalCheck(registry);
 }
 public Given_a_reference_which_is_in_registry_with_differing_case()
 {
     this.reference = new BinaryReference("MSCORLIB");
     var registry = ReferenceRegistry.FromReferenceNames(new[] { "mscorlib" });
     this.check = new BinaryReferenceIsGlobalCheck(registry);
 }
 public Given_a_reference_which_is_in_registry()
 {
     this.reference = new BinaryReference("mscorlib");
     var registry = ReferenceRegistry.FromReferenceNames(new[] {"mscorlib"});
     this.check = new BinaryReferenceIsGlobalCheck(registry);
 }
 public Given_a_reference_with_empty_path_which_is_in_global_references_list()
 {
     this.reference = new BinaryReference { Name = "mscorlib", Path = String.Empty };
     this.check = new ProjectIntegrityCheck(
         Mock.Of<IFileSystem>(), ReferenceRegistry.FromReferenceNames(new[] { "mscorlib" }), "libs");
 }
            public Given_a_reference_with_existing_path_not_in_external_libs_dir()
            {
                this.reference = new BinaryReference
                {
                    Name = "what", 
                    Path = "wrong\\what.dll", 
                    FullPath = "wrong\\what.dll",
                    Referrer = "project"
                };

                this.check = new ProjectIntegrityCheck(
                    new MockFileSystem(new Dictionary<string, MockFileData>
                    {
                        { "wrong\\what.dll", new MockFileData(String.Empty) }
                    }), ReferenceRegistry.Empty(), "libs");
            }
            public Given_a_reference_with_path_which_does_not_exist()
            {
                this.reference = new BinaryReference
                {
                    Name = "what", 
                    Path = "libs\\what.dll",
                    Referrer = "project",
                };

                this.check = new ProjectIntegrityCheck(
                    new MockFileSystem(new Dictionary<string, MockFileData>
                    {
                        { "any.dll", new MockFileData(String.Empty) }
                    }), ReferenceRegistry.Empty(), "libs");
            }
            public void It_should_not_be_satisfied()
            {
                var reference = new BinaryReference
                {
                    Name = "system",
                    Path = null,
                    FullPath = null
                };

                var fileSystemMock = new MockFileSystem(new Dictionary<string, MockFileData>());
                var check = new ReferenceExistsCheck(fileSystemMock);

                Assert.IsFalse(check.IsSatisfiedBy(reference));
            }
            public void It_should_be_satisfied()
            {
                var reference = new BinaryReference
                {
                    Name = "test",
                    Path = Path.Combine("..", "test.dll"),
                    FullPath = Path.GetFullPath(Path.Combine("root", "test.dll"))
                };

                var fileSystemMock = new MockFileSystem(new Dictionary<string, MockFileData>
                {
                    {Path.GetFullPath(Path.Combine("root", "test.dll")), new MockFileData(String.Empty)}
                });

                var check = new ReferenceExistsCheck(fileSystemMock);

                Assert.IsTrue(check.IsSatisfiedBy(reference));
            }