예제 #1
0
        protected void AssertMissingSymbolExceptionThrown <TException>(
            string fullSymbolName,
            Action <TException> customAssertions,
            [CallerMemberName] string testName = null)
            where TException : MissingSymbolException
        {
            YeetIfNull(testName, nameof(testName));

            var exception = Assert.Throws <TException>(
                () => _weaverTestFacade.CompileAndWeave(GetType(), testName));

            Assert.That(exception.SymbolName, Is.EqualTo(fullSymbolName));
            customAssertions?.Invoke(exception);
        }
        private static void WeaveAssemblyForSingleTest()
        {
            var popup = ScriptableObject.CreateInstance <CompileTestPopUp>();

            popup.Setup((type, testName) =>
            {
                using (var facade = new WeaverTestFacade())
                {
                    var path = facade.CompileAndWeave(type, testName);
                    Debug.Log(path);
                    EditorUtility.DisplayDialog("Weaved", path, "Ok");
                }
            });
            popup.ShowUtility();
        }
        public void OneWay_CallUsingCorrectBindingTargetType()
        {
            var weavedAssembly = _facade.CompileAndWeave(typeof(Positive_E2E_AbstractTests), nameof(Positive_E2E_AbstractTests.OneWay_CallToCorrectBindingTargetType));

            using (var assembly = ModuleDefinition.ReadModule(weavedAssembly))
            {
                var sourceType      = assembly.Types.First(definition => definition.Name == "BaseSource");
                var bindingProperty = sourceType.GetProperty("Text");
                var fromSetter      = bindingProperty.GetSetMethodOrYeet();

                foreach (var instruction in fromSetter.Body.Instructions)
                {
                    if (instruction.OpCode == OpCodes.Callvirt)
                    {
                        var toSetter     = (MethodDefinition)instruction.Operand;
                        var toSetterType = toSetter.DeclaringType;

                        Assert.That(toSetterType.FullName, Is.EqualTo("UnitsUnderTest.Positive_E2E_AbstractTests.OneWay_CallToCorrectBindingTargetType.BaseTarget"));
                    }
                }
            }
        }