Пример #1
0
        public void DoesNotFailWithNonMethodInfo()
        {
            var             ctor     = typeof(Foo).GetConstructors().First();
            IAvatarBehavior behavior = new DefaultValueBehavior();

            behavior.Execute(MethodInvocation.Create(new object(), ctor, PlatformID.Win32NT), null !);
        }
Пример #2
0
        public void DoesNotFailWithNonMethodInfo()
        {
            var            ctor     = typeof(Foo).GetConstructors().First();
            IStuntBehavior behavior = new DefaultValueBehavior();

            behavior.Execute(new MethodInvocation(new object(), ctor, new object[1]), () => null);
        }
Пример #3
0
        public void SetsReturnEnum()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnEnum));
            IStuntBehavior behavior = new DefaultValueBehavior();

            var result = behavior.Execute(new MethodInvocation(new object(), method, new object[0]), () => null);

            Assert.Equal(default(PlatformID), result.ReturnValue);
        }
Пример #4
0
        public void SetsReturnEnum()
        {
            var             method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnEnum)) !;
            IAvatarBehavior behavior = new DefaultValueBehavior();

            var result = behavior.Execute(MethodInvocation.Create(new object(), method), null !);

            Assert.Equal(default(PlatformID), result.ReturnValue);
        }
        public void SetsReturnGenericEnumerable()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnGenericEnumerable));
            IStuntBehavior behavior = new DefaultValueBehavior();

            var result = behavior.Execute(new MethodInvocation(new object(), method, new object[0]), () => null);

            Assert.NotNull(result.ReturnValue);
            Assert.True(result.ReturnValue is IEnumerable <object>);
        }
Пример #6
0
        public void SetsOutValue()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.VoidWithOut));
            IStuntBehavior behavior = new DefaultValueBehavior();

            var result = behavior.Execute(new MethodInvocation(new object(), method, new object[1]), () => null);

            Assert.Equal(1, result.Outputs.Count);
            Assert.NotNull(result.Outputs[0]);
            Assert.True(result.Outputs[0] is object[]);
        }
Пример #7
0
        public void SetsOutValue()
        {
            var             method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.VoidWithOut)) !;
            IAvatarBehavior behavior = new DefaultValueBehavior();

            var result = behavior.Execute(MethodInvocation.Create(new object(), method, Array.Empty <object>()), null !);

            Assert.Equal(1, result.Outputs.Count);
            Assert.NotNull(result.Outputs.GetValue(0));
            Assert.True(result.Outputs.GetValue(0) is object[]);
        }
Пример #8
0
        public void SetsReturnTask()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnTask));
            IStuntBehavior behavior = new DefaultValueBehavior();

            var result = behavior.Execute(new MethodInvocation(new object(), method, new object[0]), () => null);

            Assert.NotNull(result.ReturnValue);
            Assert.True(result.ReturnValue is Task);
            Assert.True(((Task)result.ReturnValue).IsCompleted);
        }
Пример #9
0
        public void SetsReturnArray()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnArray));
            IStuntBehavior behavior = new DefaultValueBehavior();

            var result = behavior.Execute(new MethodInvocation(new object(), method, new object[0]), () => null);

            Assert.NotNull(result.ReturnValue);
            Assert.True(result.ReturnValue is object[]);
            Assert.Empty(((Array)result.ReturnValue));
        }
Пример #10
0
        public void SetsReturnGenericTaskEnum()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnGenericTaskEnum));
            IStuntBehavior behavior = new DefaultValueBehavior();

            var result = behavior.Execute(new MethodInvocation(new object(), method, new object[0]), () => null);

            Assert.NotNull(result.ReturnValue);
            Assert.True(result.ReturnValue is Task <PlatformID>);
            Assert.True(((Task)result.ReturnValue).IsCompleted);
            Assert.Equal(default, ((Task <PlatformID>)result.ReturnValue).Result);
Пример #11
0
        public void DoesNotSetsRefEnumValue()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.VoidWithRefEnum));
            IStuntBehavior behavior = new DefaultValueBehavior();
            var            platform = PlatformID.Xbox;

            var result = behavior.Execute(new MethodInvocation(new object(), method, platform), () => null);

            Assert.Equal(1, result.Outputs.Count);
            Assert.NotNull(result.Outputs[0]);
            Assert.Equal(platform, result.Outputs[0]);
        }
Пример #12
0
        public void DoesNotSetRefValue()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.VoidWithRef));
            IStuntBehavior behavior = new DefaultValueBehavior();
            var            value    = new object();

            var result = behavior.Execute(new MethodInvocation(new object(), method, value), () => null);

            Assert.Equal(1, result.Outputs.Count);
            Assert.NotNull(result.Outputs[0]);
            Assert.Same(result.Outputs[0], value);
        }
Пример #13
0
        public void DoesNotSetRefValue()
        {
            var             method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.VoidWithRef)) !;
            IAvatarBehavior behavior = new DefaultValueBehavior();
            var             value    = new object[] { new object() };

            var result = behavior.Execute(MethodInvocation.Create(new object(), method, value), null !);

            Assert.Equal(1, result.Outputs.Count);
            Assert.NotNull(result.Outputs.GetValue(0));
            Assert.Same(result.Outputs.GetValue(0), value);
        }