public void NonImplementingWrapper()
        {
            IClass c = _emmiter.Class("NonImplemening").In(_namespace).Public;
            {
                CreateClassMembers(c);
            }
            var t   = _emmiter.Generate(c);
            var sut = t.GetConstructor(new[] { _interface }).Invoke(new object[] { _mock });
            var writeOnlyProperty = t.GetProperty(_propertyName);

            writeOnlyProperty.SetValue(sut, _expectedValue, null);
            _mock.AssertWasCalled(x => x.WriteOnlyProperty = _expectedValue);
        }
示例#2
0
        [Test] public void InvokeChokesOnNonExistentMethod()
        {
            IClass c = _emmiter.Class("Nonexistent").In(_namespace);
            {
                var f = c.Field(_interface, _wrappedFieldName);

                var m = c.Method(typeof(string), _methodName, _emmiter.Arg <int>("i")).Public;
                using (var code = m.Code())
                {
                    var e = Assert.Throws <ArgumentException>(() => f.Invoke("NonExistentMethod", m.Args[0]));
                    System.Diagnostics.Debug.WriteLine(e.Message);
                }
            }
        }
        public void NonImplementingWrapper()
        {
            IClass c = _emmiter.Class("NonImplemening").In(_namespace).Public;
            {
                CreateClassMembers(c, _emmiter);
            }
            var t   = _emmiter.Generate(c);
            var sut = t.GetConstructor(new[] { _interface }).Invoke(new object[] { _mock });
            var readWriteProperty = t.GetProperty(_propertyName);

            Assert.That(readWriteProperty.GetValue(sut, null), Is.EqualTo(_getValue));
            _mock.AssertWasCalled(x => x.ReadWriteProperty);
            readWriteProperty.SetValue(sut, _setValue, null);
            _mock.AssertWasCalled(x => x.ReadWriteProperty = _setValue);
        }
        public void InvokeChokesOnNonExistentMethod()
        {
            IClass c = _emmiter.Class("Nonexistent").In(_namespace);
            {
                var f = c.Field(_interface, _wrappedFieldName);

                var p = c.Property(typeof(string), _propertyName).Public;
                var m = p.Getter();
                using (m.Code())
                {
                    var e = Assert.Throws <ArgumentException>(() => f.Property("NonExistentProperty"));
                    System.Diagnostics.Debug.WriteLine(e.Message);
                }
            }
        }
        public void NonImplementingWrapper()
        {
            IClass c = _emmiter.Class("NonImplemening").In(_namespace).Public;
            {
                CreateClassMembers(c);
            }
            var t            = _emmiter.Generate(c);
            var sut          = t.GetConstructor(new[] { _interface }).Invoke(new object[] { _mock });
            var simpleMethod = t.GetMethod(_methodName, new[] { typeof(long).MakeByRefType() });

            object[] parameters = new object[] { _refParameter };
            simpleMethod.Invoke(sut, parameters);
            _refParameter = (long)parameters[0];
            Assert.That(_refParameter, Is.EqualTo(_expectedValue));
            _mock.AssertWasCalled(x => x.RefParamMethod(ref _refParameter));
        }
示例#6
0
        public void InvokeChokesOnNonExistentMethod()
        {
            var    g = _emmiter;
            IClass c = _emmiter.Class("Nonexistent").In(_namespace);
            {
                var f = c.Field(_interface, _wrappedFieldName);

                var p = c.Indexer(typeof(long), g.Arg <int>("i"), g.Arg <string>("s")).Public;
                var m = p.Getter();
                using (m.Code())
                {
                    var e = Assert.Throws <ArgumentException>(() => f.Indexer(m.Args[0]));
                    System.Diagnostics.Debug.WriteLine(e.Message);
                }
            }
        }