示例#1
0
        private RecordedMethod CloneRecordedMethod(RecordedMethod source)
        {
            var serializer = new SerializationHelper();
            var serVal     = serializer.Serialize(source).SerializedValue.Value;

            return(serializer.Deserialize <RecordedMethod>(serVal));
        }
示例#2
0
        private void _methodManager_MethodRecordingComplete(object sender, MethodRecordingCompleteEventArgs e)
        {
            var recordingMethod = e.Method;
            var recordedMethod  = new RecordedMethod(recordingMethod);

            _dataHelper.AddRecordedMethod(recordedMethod);
        }
        public void Recorded_Method_Model_Test_Recording_Method_Id_Init()
        {
            var guid      = Guid.NewGuid();
            var recMethod = new RecordedMethod(guid);

            Assert.IsTrue(guid == recMethod.Identifier);
        }
        public void Recorded_Method_Model_Test_Recording_Method_Init()
        {
            var guid       = Guid.NewGuid();
            var targetType = TestClass.Method1Entry.TargetType;
            var methodName = TestClass.Method1Entry.Method.Name;
            var serTarget  = "blah";
            var arg        = new List <object>()
            {
                2.0,
                "blah"
            };
            var methodBase = TestClass.Method1Entry.Method;
            var returnVal  = "foo";
            var serValue   = new SerializedValue(targetType, serTarget);

            var recordingMethod = new RecordingMethod(guid, serValue, arg, methodBase);

            recordingMethod.CloseOutMethodWithReturnVal(returnVal);

            var SUT = new RecordedMethod(recordingMethod);

            for (int i = 0; i < SUT.Args.Count; i++)
            {
                Assert.IsTrue(SUT.Args[i].Equals(arg[i]));
            }
            Assert.IsTrue(SUT.Identifier.Equals(guid));
            Assert.IsTrue(SUT.InstanceAtExecutionTime.Value.Equals(serTarget));
            Assert.IsTrue(SUT.MethodException == null);
            Assert.IsTrue(SUT.MethodData.MethodName == methodName);
            Assert.IsTrue(SUT.ReturnVal.GetType().Equals(returnVal.GetType()));
            Assert.IsTrue(SUT.ReturnVal.Equals(returnVal));
            Assert.IsTrue(SUT.SubMethods != null);
            Assert.IsTrue(SUT.TargetType.Equals(targetType));
        }
示例#5
0
        public SingleTest(RecordedMethod method) : this()
        {
            this.TestName        = $"{method.TargetType.Name}_{method.MethodData.MethodName}_{this.GenRandIntString()}";
            this.ObjectInstance  = method.InstanceAtExecutionTime.Value;
            this.InstanceType    = method.InstanceAtExecutionTime.Type;
            this.ThrownException = method.MethodException;
            this.ReturnVal       = method.ReturnVal;
            this.MethodData      = method.MethodData;

            if (!this.WasExceptionThrown)
            {
                this.SerializedReturnVal = JsonConvert.SerializeObject(method.ReturnVal);
            }

            this.Args = new List <SerializedArg>();
            for (int i = 0; i < method.Args.Count; i++)
            {
                var arg    = method.Args[i];
                var name   = $"arg_{arg?.GetType().Name}_{i}";
                var serVal = JsonConvert.SerializeObject(arg);
                this.Args.Add(new SerializedArg(arg?.GetType(), name, serVal));
            }

            this.Dependencies = new List <DependencyData>();
            var groupings = method.SubMethods.GroupBy(x => x.TargetType);

            foreach (var grouping in groupings)
            {
                var dependency = new DependencyData(grouping.ToList());
                this.Dependencies.Add(dependency);
            }
        }
示例#6
0
        public void AddRecordedMethod(RecordedMethod method)
        {
            var existingMethod = GetMethodWithId(method.Identifier);

            if (existingMethod != null)
            {
                _dal.Remove <RecordedMethod>(existingMethod);
            }

            _dal.Create <RecordedMethod>(CloneRecordedMethod(method));
            _dal.CommitChanges();
        }
        public void Recorded_Method_Model_Test_Equality_Override()
        {
            var guid       = Guid.NewGuid();
            var targetType = TestClass.Method1Entry.TargetType;
            var methodName = TestClass.Method1Entry.Method.Name;
            var serTarget  = "blah";
            var arg        = new List <object>()
            {
                2.0,
                "blah"
            };
            var methodBase = TestClass.Method1Entry.Method;
            var returnVal  = "foo";
            var serValue   = new SerializedValue(targetType, serTarget);

            var recordingMethod = new RecordingMethod(guid, serValue, arg, methodBase);
            var recordedMethod  = new RecordedMethod(recordingMethod);

            Assert.IsTrue(recordedMethod.Equals(recordedMethod));
            Assert.IsFalse(recordedMethod.Equals(new RecordedMethod(Guid.NewGuid())));
            Assert.IsTrue(recordedMethod.Equals(new RecordedMethod(guid)));
        }