Esempio n. 1
0
        public void GetPoseWrapper_Generates_Method_With_Specific_Options_When_Provided_On_Wrapper_With_Return()
        {
            var a          = new InstanceTestClass();
            var methodInfo = a.GetType().GetMethod("VoidMethod");
            var wrapper    = Shimmer.GetPoseWrapper(methodInfo, a, WrapperOptions.ShimSpecialNames);

            Assert.AreEqual(WrapperOptions.ShimSpecialNames, wrapper.Options);
        }
Esempio n. 2
0
        public void GetPoseWrapper_Generates_Wrapper_From_Instance_Expression()
        {
            var a       = new InstanceTestClass();
            var wrapper = Shimmer.GetPoseWrapper(() => a.VoidMethod());

            Assert.IsNotNull(wrapper);
            wrapper.Execute();
            Assert.IsNotNull(wrapper.LastExecutionResults);
            Assert.AreEqual(1, wrapper.LastExecutionResults.Count);
        }
Esempio n. 3
0
        public void GetPoseWrapper_Generates_Wrapper_From_Instance_Method()
        {
            var a          = new InstanceTestClass();
            var methodInfo = a.GetType().GetMethod("VoidMethod");
            var wrapper    = Shimmer.GetPoseWrapper(methodInfo, a);

            Assert.IsNotNull(wrapper);
            wrapper.Execute();
            Assert.IsNotNull(wrapper.LastExecutionResults);
            Assert.AreEqual(1, wrapper.LastExecutionResults.Count);
        }
Esempio n. 4
0
        public void GetPoseWrapper_Generates_Wrapper_From_Instance_Expression_With_Parameters()
        {
            var a       = new InstanceTestClass();
            var wrapper = Shimmer.GetPoseWrapper(() => a.MethodWithValueTypeParam(default(int)));

            Assert.IsNotNull(wrapper);
            wrapper.Execute(5);
            Assert.IsNotNull(wrapper.LastExecutionResults);
            Assert.AreEqual(1, wrapper.LastExecutionResults.Count);
            Assert.AreEqual(5, wrapper.LastExecutionResults.First().Value[0].Parameters[0]);
        }
Esempio n. 5
0
        public void GetPoseWrapper_Generates_Wrapper_From_Instance_Method_With_Parameters()
        {
            var a          = new InstanceTestClass();
            var methodInfo = a.GetType().GetMethod("MethodWithValueTypeParam");
            var wrapper    = Shimmer.GetPoseWrapper(methodInfo, a);

            Assert.IsNotNull(wrapper);
            wrapper.Execute(5);
            Assert.IsNotNull(wrapper.LastExecutionResults);
            Assert.AreEqual(1, wrapper.LastExecutionResults.Count);
            Assert.AreEqual(5, wrapper.LastExecutionResults.First().Value[0].Parameters[0]);
        }
Esempio n. 6
0
        public void GetPoseWrapper_Generates_Wrapper_From_Instance_Expression_With_Return()
        {
            var a       = new InstanceTestClass();
            var wrapper = Shimmer.GetPoseWrapper <int>(() => a.MethodWithReturn());

            Assert.IsNotNull(wrapper);
            var result = wrapper.Execute();

            Assert.AreEqual(0, result);
            Assert.IsNotNull(wrapper.LastExecutionResults);
            Assert.AreEqual(1, wrapper.LastExecutionResults.Count);
        }
Esempio n. 7
0
        public void GetPoseWrapper_Generates_Wrapper_From_Instance_Method_With_Return()
        {
            var a          = new InstanceTestClass();
            var methodInfo = a.GetType().GetMethod("MethodWithReturn");
            var wrapper    = Shimmer.GetPoseWrapper <int>(methodInfo, a);

            Assert.IsNotNull(wrapper);
            var result = wrapper.Execute();

            Assert.AreEqual(0, result);
            Assert.IsNotNull(wrapper.LastExecutionResults);
            Assert.AreEqual(1, wrapper.LastExecutionResults.Count);
        }
Esempio n. 8
0
        public void GetPoseWrapper_Generates_Wrapper_From_Instance_Expression_With_Parameters_And_Return()
        {
            var a       = new InstanceTestClass();
            var wrapper = Shimmer.GetPoseWrapper <int>(() => a.MethodWithParamAndReturn(5));

            Assert.IsNotNull(wrapper);
            var result = wrapper.Execute(5);

            Assert.AreEqual(0, result);
            Assert.IsNotNull(wrapper.LastExecutionResults);
            Assert.AreEqual(1, wrapper.LastExecutionResults.Count);
            Assert.AreEqual(5, wrapper.LastExecutionResults.First().Value[0].Parameters[0]);
        }
Esempio n. 9
0
        public void GetInstance_Returns_The_Result_Of_Func_Each_time()
        {
            //arrange
            var dummyObject = new InstanceTestClass();
            var func        = new Func <InstanceTestClass>(() => dummyObject);
            var sut         = GetSut(func);
            var expected    = sut.GetInstance();
            //act
            var instance1 = sut.GetInstance();
            var instance2 = sut.GetInstance();
            var instance3 = sut.GetInstance();

            //assert
            Assert.That(expected, Is.EqualTo(instance1));
            Assert.That(expected, Is.EqualTo(instance2));
            Assert.That(expected, Is.EqualTo(instance3));
        }