コード例 #1
0
        public void SetsReturnEnum()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnEnum));
            IStuntBehavior behavior = new DefaultValueBehavior();

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

            Assert.Equal(default(PlatformID), result.ReturnValue);
        }
コード例 #2
0
        public void SetsReturnNullableEnum()
        {
            var method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnNullableEnum));
            var behavior = new DefaultValueBehavior();

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

            Assert.Null(result.ReturnValue);
        }
コード例 #3
0
        public void SetsReturnGenericEnumerable()
        {
            var method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnGenericEnumerable));
            var behavior = new DefaultValueBehavior();

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

            Assert.NotNull(result.ReturnValue);
            Assert.True(result.ReturnValue is IEnumerable <object>);
        }
コード例 #4
0
        public void SetsReturnGenericTask()
        {
            var method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnGenericTask));
            var behavior = new DefaultValueBehavior();

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

            Assert.NotNull(result.ReturnValue);
            Assert.True(result.ReturnValue is Task <object>);
            Assert.True(((Task)result.ReturnValue).IsCompleted);
        }
コード例 #5
0
        public void SetsReturnArray()
        {
            var method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnArray));
            var behavior = new DefaultValueBehavior();

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

            Assert.NotNull(result.ReturnValue);
            Assert.True(result.ReturnValue is object[]);
            Assert.Equal(0, ((Array)result.ReturnValue).Length);
        }
コード例 #6
0
        public void SetsOutValue()
        {
            var method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.VoidWithOut));
            var behavior = new DefaultValueBehavior();

            var result = behavior.Invoke(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 DoesNotSetsRefEnumValue()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.VoidWithRefEnum));
            IStuntBehavior behavior = new DefaultValueBehavior();
            var            platform = PlatformID.Xbox;

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

            Assert.Equal(1, result.Outputs.Count);
            Assert.NotNull(result.Outputs[0]);
            Assert.Equal(platform, result.Outputs[0]);
        }
コード例 #8
0
        public void SetsReturnGenericTaskEnum()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.ReturnGenericTaskEnum));
            IStuntBehavior behavior = new DefaultValueBehavior();

            var result = behavior.Invoke(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(PlatformID), ((Task <PlatformID>)result.ReturnValue).Result);
        }
コード例 #9
0
        public void DoesNotSetRefValue()
        {
            var            method   = typeof(IDefaultValues).GetMethod(nameof(IDefaultValues.VoidWithRef));
            IStuntBehavior behavior = new DefaultValueBehavior();
            var            value    = new object();

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

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