public void TestNotCovered()
        {
            var recorder = AssignRecorderInitializer.StartAssignRecorder();

            var testConfigurator = new TestConverterCollection <TestDataSource, TestDataDest>(pathFormatterCollection,
                                                                                              configurator =>
            {
                configurator.Target(x => x.C).Set(x => x.A);
                configurator.If(x => x.B == 10000).Target(x => x.D).Set(x => x.B);
            });

            var converter  = testConfigurator.GetConverter(MutatorsContext.Empty);
            var actualData = converter(new TestDataSource());

            recorder.Stop();

            Assert.AreEqual(12, actualData.C);
            Assert.AreEqual(2, actualData.D);

            var converterNode = recorder.GetRecords()[0];

            Assert.AreEqual(3, converterNode.CompiledCount);
            Assert.AreEqual(1, converterNode.ExecutedCount);
            Assert.AreEqual(1, converterNode.Records["TestDataDest"].Records["C"].ExecutedCount);
            Assert.AreEqual(0, converterNode.Records["TestDataDest"].Records["D"].ExecutedCount);
        }
        public void TestConvertWithDifferentArraySources()
        {
            var collection = new TestConverterCollection <AValue, BValue>(new PathFormatterCollection(), configurator =>
            {
                configurator.If(a => a.Condition)
                .Target(b => b.BOuterArray.Each().BInnerArray.Each().FirstValue)
                .Set(a => a.AOuterArray.Current().AFirstAFirstInnerArray.Current().Value);
                configurator.If(a => !a.Condition)
                .Target(b => b.BOuterArray.Each().BInnerArray.Each().FirstValue)
                .Set(a => a.AOuterArray.Current().ASecondASecondInnerArray.Current().Value);
            });
            var converter = collection.GetConverter(MutatorsContext.Empty);
            var from      = new AValue
            {
                AOuterArray = new[]
                {
                    new AOuterValue
                    {
                        AFirstAFirstInnerArray = new[]
                        {
                            new AFirstInnerValue {
                                Value = "123"
                            }
                        },
                        ASecondASecondInnerArray = new[]
                        {
                            new ASecondInnerValue {
                                Value = "321"
                            }
                        },
                    }
                },
                Condition = true,
            };

            Following.Code(() => converter(from))
            .Should().Throw <InvalidOperationException>()
            .Which.Message.Should().MatchRegex(@"^Method T Current\[T\].* cannot be invoked$");

            return;

#pragma warning disable 162
            var expected = new BValue
            {
                BOuterArray = new[]
                {
                    new BOuterValue
                    {
                        BInnerArray = new[]
                        {
                            new BInnerValue {
                                FirstValue = "123"
                            },
                        },
                    },
                },
            };
            converter(from).Should().BeEquivalentTo(expected);
#pragma warning restore 162
        }
        public void TestDoubleGettingConverter()
        {
            var converterCollection = new TestConverterCollection <TestDataSource, TestDataDest>(pathFormatterCollection,
                                                                                                 configurator =>
            {
                configurator.Target(x => x.C).Set(x => x.A);
                configurator.Target(x => x.D).Set(x => x.B);
            });
            var recorder = AssignRecorderInitializer.StartAssignRecorder();

            var converter = converterCollection.GetConverter(MutatorsContext.Empty);

            converter(new TestDataSource());
            recorder.Stop();

            var records = recorder.GetRecords();

            Assert.AreEqual(1, records.Count);
            Assert.AreEqual(3, records[0].CompiledCount);
            Assert.AreEqual(2, records[0].ExecutedCount);

            var newRecorder = AssignRecorderInitializer.StartAssignRecorder();

            Assert.AreNotSame(recorder, newRecorder);
            converter = converterCollection.GetConverter(MutatorsContext.Empty);
            converter(new TestDataSource());
            recorder.Stop();

            records = newRecorder.GetRecords();
            Assert.AreEqual(1, records.Count);
            Assert.AreEqual(2, records[0].CompiledCount);
            Assert.AreEqual(2, records[0].ExecutedCount);
        }
Ejemplo n.º 4
0
        public void SetUp()
        {
            converterCollectionFactory = new TestConverterCollectionFactory();
            pathFormatterCollection    = new PathFormatterCollection();
            var webDataToDataConverterCollection      = new TestConverterCollection <WebData, Data>(pathFormatterCollection, configurator => { configurator.Target(data => data.Items.Each().Id).Set(data => data.Items.Current().Id); });
            var modelDataToWebDataConverterCollection = new TestConverterCollection <ModelData, WebData>(pathFormatterCollection, configurator => { configurator.Target(data => data.Items.Each().Id).Set(data => data.Items.Current().Id); });

            converterCollectionFactory.Register(webDataToDataConverterCollection);
            converterCollectionFactory.Register(modelDataToWebDataConverterCollection);
        }
Ejemplo n.º 5
0
        public void MultithreadingTest()
        {
            var actualDataList = new ConcurrentBag <TestDataDest>();
            var threads        = new ConcurrentBag <Thread>();

            for (var i = 0; i < 10; i++)
            {
                var thread = new Thread(() =>
                {
                    while (!start)
                    {
                    }

                    try
                    {
                        var recorder  = AssignRecorderInitializer.StartAssignRecorder();
                        var converter = new TestConverterCollection <TestDataSource, TestDataDest>(pathFormatterCollection,
                                                                                                   configurator => { configurator.Target(x => x.C).Set(x => x.A); }).GetConverter(MutatorsContext.Empty);
                        actualDataList.Add(converter(new TestDataSource()));
                        recorder.Stop();
                        Assert.AreEqual(2, recorder.GetRecords()[0].CompiledCount);
                        Assert.AreEqual(1, recorder.GetRecords()[0].ExecutedCount);
                    }
                    catch (Exception e)
                    {
                        lastException = e;
                        Console.WriteLine(e);
                    }
                });
                thread.Start();
                threads.Add(thread);
            }

            start = true;

            foreach (var thread in threads)
            {
                thread.Join();
            }

            Assert.AreEqual(10, actualDataList.Count);
            foreach (var data in actualDataList)
            {
                Assert.AreEqual(12, data.C);
            }

            if (lastException != null)
            {
                throw lastException;
            }
        }
        private static void DoTestSetNull <TSource, TDest>(TestConverterCollection <TSource, TDest> converterCollection, TSource source, int expectedCompiledCount, int expectedExecutedCount) where TDest : new()
        {
            var recorder  = AssignRecorderInitializer.StartAssignRecorder();
            var converter = converterCollection.GetConverter(MutatorsContext.Empty);

            converter(source);
            recorder.Stop();

            var records = recorder.GetRecords();

            Assert.AreEqual(1, records.Count);
            Assert.AreEqual(expectedCompiledCount, records[0].CompiledCount);
            Assert.AreEqual(expectedExecutedCount, records[0].ExecutedCount);
        }
        public void TestSetNullToNullableInt()
        {
            var converterCollection = new TestConverterCollection <TestDataSourceNullableInt, TestDataDestNullableInt>(pathFormatterCollection,
                                                                                                                       configurator =>
            {
                configurator.Target(x => x.IntC).Set(x => x.IntA);
                configurator.Target(x => x.IntD).Set(x => x.IntB);
            });
            var source = new TestDataSourceNullableInt
            {
                IntA = 12
            };

            DoTestSetNull(converterCollection, source, 3, 1);
        }
        public void TestSetNullToNullableEnum()
        {
            var converterCollection = new TestConverterCollection <TestDataSourceNullableEnum, TestDataDestNullableEnum>(pathFormatterCollection,
                                                                                                                         configurator =>
            {
                configurator.Target(x => x.FieldC).Set(x => x.FieldA);
                configurator.Target(x => x.FieldD).Set(x => x.FieldB);
            });
            var source = new TestDataSourceNullableEnum
            {
                FieldA = TestEnum.Black
            };

            DoTestSetNull(converterCollection, source, 3, 1);
        }
        public void TestSetNullToString()
        {
            var converterCollection = new TestConverterCollection <TestDataSourceNullable, TestDataDestNullable>(pathFormatterCollection,
                                                                                                                 configurator =>
            {
                configurator.Target(x => x.StrC).Set(x => x.StrA);
                configurator.Target(x => x.StrD).Set(x => x.StrB);
            });
            var source = new TestDataSourceNullable
            {
                StrA = "qxx"
            };

            DoTestSetNull(converterCollection, source, 3, 1);
        }
Ejemplo n.º 10
0
        public void TestEnumCustomFieldWithWhereAndStringConverter()
        {
            var configuratorCollection = new TestDataConfiguratorCollection <SourceTestData>(null, null, pathFormatterCollection, configurator =>
            {
                var subConfigurator = configurator.GoTo(x => x.As.Each());
                subConfigurator.Target(x => x.EnumCustomField).Required(x => new TestText
                {
                    Text = x.Info
                });
            });
            IStringConverter enumStringConverter = new EnumStringConverter();
            var converterCollection = new TestConverterCollection <TargetTestData, SourceTestData>(pathFormatterCollection, configurator =>
            {
                var subConfigurator = configurator.GoTo(x => x.As.Each(), x => x.As.Where(y => y.IsRemoved != true).Current());
                subConfigurator.Target(x => x.Info).Set(x => x.Info);
            }, enumStringConverter);
            var mutatorsTree    = configuratorCollection.GetMutatorsTree(MutatorsContext.Empty);
            var migratedTree    = converterCollection.Migrate(mutatorsTree, MutatorsContext.Empty);
            var mutatorWithPath = migratedTree.GetAllMutatorsWithPathsForWeb(x => x).Single();

            // Should be: Expression<Func<TargetTestData, AEnum>> expectedPathToMutator = x => (AEnum)(x.As.Each().CustomFields["EnumCustomField"].Value ?? AEnum.Unknown);
            Expression <Func <TargetTestData, AEnum> > expectedPathToMutator = x => (AEnum)(enumStringConverter.ConvertFromString <AEnum>((string)x.As.Where(y => y.IsRemoved != true).Each().CustomFields["EnumCustomField"].Value) ?? (object)AEnum.Unknown);

            mutatorWithPath.PathToMutator.AssertEquivalentExpressions(expectedPathToMutator.Body.Simplify());
            Expression <Func <TargetTestData, object> > expectedPathToNode = x => x.As.Each().CustomFields["EnumCustomField"].Value;

            mutatorWithPath.PathToNode.AssertEquivalentExpressions(expectedPathToNode.Body);

            var requiredIfConfiguration = (RequiredIfConfiguration)mutatorWithPath.Mutator;
            // Should be: Expression<Func<TargetTestData, AEnum>> expectedMutatorPath = x => (AEnum)(x.As.Current().CustomFields["EnumCustomField"].Value ?? AEnum.Unknown);
            Expression <Func <TargetTestData, AEnum> > expectedMutatorPath = x => (AEnum)(enumStringConverter.ConvertFromString <AEnum>((string)x.As.Where(y => y.IsRemoved != true).Current().CustomFields["EnumCustomField"].Value) ?? AEnum.Unknown);

            requiredIfConfiguration.Path.AssertEquivalentExpressions(expectedMutatorPath.Simplify());

            // Should be: Expression<Func<TargetTestData, bool>> expectedMutatorCondition = x => x.As.Each().IsRemoved != true;
            Expression <Func <TargetTestData, bool> > expectedMutatorCondition = null;

            requiredIfConfiguration.Condition.AssertEquivalentExpressions(expectedMutatorCondition);

            // Should be: Expression<Func<TargetTestData, TestText>> expectedMutatorMessage = x => new TestText {Text = x.As.Each().Info};
            Expression <Func <TargetTestData, TestText> > expectedMutatorMessage = x => new TestText {
                Text = x.As.Where(y => y.IsRemoved != true).Current().Info
            };

            requiredIfConfiguration.Message.AssertEquivalentExpressions(expectedMutatorMessage);
        }
        public void TestStop()
        {
            var recorder = AssignRecorderInitializer.StartAssignRecorder();

            var testConfigurator = new TestConverterCollection <TestDataSource, TestDataDest>(pathFormatterCollection,
                                                                                              configurator =>
            {
                configurator.Target(x => x.C).Set(x => x.A);
                configurator.Target(x => x.D).Set(x => x.B);
            });

            recorder.Stop();
            var converter = testConfigurator.GetConverter(MutatorsContext.Empty);

            converter(new TestDataSource());

            Assert.IsEmpty(recorder.GetRecords());
        }
Ejemplo n.º 12
0
        public void TestNormalFieldsWithWhere()
        {
            var configuratorCollection = new TestDataConfiguratorCollection <SourceTestData>(null, null, pathFormatterCollection, configurator =>
            {
                var subConfigurator = configurator.GoTo(x => x.As.Each());
                subConfigurator.Target(x => x.SomethingNormal).Required(x => new TestText
                {
                    Text = x.Info
                });
            });
            var converterCollection = new TestConverterCollection <TargetTestData, SourceTestData>(pathFormatterCollection, configurator =>
            {
                var subConfigurator = configurator.GoTo(x => x.As.Each(), x => x.As.Where(y => y.IsRemoved != true).Current());
                subConfigurator.Target(x => x.Info).Set(x => x.Info);
                subConfigurator.Target(x => x.SomethingNormal).Set(x => x.SomethingNormal);
            });
            var mutatorsTree = configuratorCollection.GetMutatorsTree(MutatorsContext.Empty);
            var migratedTree = converterCollection.Migrate(mutatorsTree, MutatorsContext.Empty);

            var mutatorWithPath = migratedTree.GetAllMutatorsWithPathsForWeb(x => x).Single();

            Expression <Func <TargetTestData, string> > expectedPathToMutator = x => x.As.Current().SomethingNormal;

            mutatorWithPath.PathToMutator.AssertEquivalentExpressions(expectedPathToMutator.Body);
            Expression <Func <TargetTestData, object> > expectedPathToNode = x => x.As.Each().SomethingNormal;

            mutatorWithPath.PathToNode.AssertEquivalentExpressions(expectedPathToNode.Body);

            var requiredIfConfiguration = (RequiredIfConfiguration)mutatorWithPath.Mutator;
            Expression <Func <TargetTestData, string> > expectedMutatorPath = x => x.As.Current().SomethingNormal;

            requiredIfConfiguration.Path.AssertEquivalentExpressions(expectedMutatorPath);
            Expression <Func <TargetTestData, bool> > expectedMutatorCondition = x => x.As.Current().IsRemoved != true;

            requiredIfConfiguration.Condition.AssertEquivalentExpressions(expectedMutatorCondition);
            Expression <Func <TargetTestData, TestText> > expectedMutatorMessage = x => new TestText {
                Text = x.As.Current().Info
            };

            requiredIfConfiguration.Message.AssertEquivalentExpressions(expectedMutatorMessage);
        }
        public void Test()
        {
            var recorder         = AssignRecorderInitializer.StartAssignRecorder();
            var testConfigurator = new TestConverterCollection <TestDataSource, TestDataDest>(pathFormatterCollection,
                                                                                              configurator =>
            {
                configurator.Target(x => x.C).Set(x => x.A);
                configurator.Target(x => x.D).Set(x => x.B);
            });
            var converter = testConfigurator.GetConverter(MutatorsContext.Empty);

            var testDataSource = new TestDataSource();
            var actualData     = converter(testDataSource);

            recorder.Stop();
            Assert.AreEqual(actualData.C, 12);

            Assert.IsNotEmpty(recorder.GetRecords());

            var converterNode = recorder.GetRecords()[0];

            Assert.AreEqual(1, converterNode.Records.Count);
            Assert.AreEqual("TestConverterCollection`2", converterNode.Name);

            var objectTypeNode = converterNode.Records["TestDataDest"];

            Assert.AreEqual(2, objectTypeNode.Records.Count);
            Assert.AreEqual("TestDataDest", objectTypeNode.Name);

            var dataCNode = objectTypeNode.Records["C"];

            Assert.AreEqual("C", dataCNode.Name);
            Assert.AreEqual(1, dataCNode.Records.Count);
            Assert.AreEqual("source.A", dataCNode.Records["source.A"].Name);

            var dataDNode = objectTypeNode.Records["D"];

            Assert.AreEqual("D", dataDNode.Name);
            Assert.AreEqual(1, dataDNode.Records.Count);
            Assert.AreEqual("source.B", dataDNode.Records["source.B"].Name);
        }
        public void TestCacheConverter()
        {
            var converterCollection = new TestConverterCollection <TestDataSource, TestDataDest>(pathFormatterCollection,
                                                                                                 configurator =>
            {
                configurator.Target(x => x.C).Set(x => x.A);
                configurator.Target(x => x.D).Set(x => x.B);
            });

            var converter = converterCollection.GetConverter(MutatorsContext.Empty);

            Assert.AreSame(converter, converterCollection.GetConverter(MutatorsContext.Empty));

            var recorder = AssignRecorderInitializer.StartAssignRecorder();
            var converterWhileRecording = converterCollection.GetConverter(MutatorsContext.Empty);

            Assert.AreSame(converterWhileRecording, converter);

            recorder.Stop();
            Assert.AreSame(converter, converterCollection.GetConverter(MutatorsContext.Empty));
        }
        public void TestRecordsAreDistinct()
        {
            var recorder = AssignRecorderInitializer.StartAssignRecorder();

            var testConfigurator = new TestConverterCollection <TestDataSource, TestDataDest>(pathFormatterCollection,
                                                                                              configurator =>
            {
                configurator.Target(x => x.C).Set(x => x.A);
                configurator.Target(x => x.D).Set(x => x.B);
            });

            var converter = testConfigurator.GetConverter(MutatorsContext.Empty);

            converter(new TestDataSource());
            converter(new TestDataSource());
            recorder.Stop();

            var converterNode = recorder.GetRecords()[0];

            Assert.AreEqual(3, converterNode.CompiledCount);
            Assert.AreEqual(4, converterNode.ExecutedCount);
        }
Ejemplo n.º 16
0
        public void TestProperty()
        {
            var configuratorCollection = new TestDataConfiguratorCollection <SourceTestData>(null, null, pathFormatterCollection, configurator =>
            {
                var subConfigurator = configurator.GoTo(x => x.As.Each());
                subConfigurator.Target(x => x.Bs).Required(x => new TestText
                {
                    Text = x.Info
                });
            });
            var converterCollection = new TestConverterCollection <TargetTestData, SourceTestData>(pathFormatterCollection, configurator =>
            {
                var subConfigurator = configurator.GoTo(x => x.As.Each(), x => x.As.Where(y => y.IsRemoved != true).Current());
                subConfigurator.Target(x => x.Bs.Each().Value).Set(x => x.Bs.Current());
                subConfigurator.Target(x => x.Info).Set(x => x.Info);
            });
            var mutatorsTree = configuratorCollection.GetMutatorsTree(MutatorsContext.Empty);
            var migratedTree = converterCollection.Migrate(mutatorsTree, MutatorsContext.Empty);

            var mutatorWithPath = migratedTree.GetAllMutatorsWithPaths().Single();

            ((RequiredIfConfiguration)mutatorWithPath.Mutator).Condition.Compile();
            ((RequiredIfConfiguration)mutatorWithPath.Mutator).Message.Compile();
        }
Ejemplo n.º 17
0
        public void TestWebDataToDataConverter()
        {
            var webDataToDataConverterCollection = new TestConverterCollection <WebData, Data>(pathFormatterCollection, configurator =>
            {
                configurator.Target(x => x.Items.Each().Id).Set(x => x.Items.Current().Id);
                configurator.Target(x => x.F).Set(x => x.F);
            });
            var converter = webDataToDataConverterCollection.GetConverter(MutatorsContext.Empty);
            var data      = converter(new WebData
            {
                F            = "qxx",
                CustomFields = new Lazy <Dictionary <string, CustomFieldValue> >(() => new Dictionary <string, CustomFieldValue>
                {
                    { "S", new CustomFieldValue {
                          TypeCode = TypeCode.String, Value = "zzz"
                      } },
                    { "F", new CustomFieldValue {
                          TypeCode = TypeCode.String, Value = "zzz"
                      } },
                    { "StrArr", new CustomFieldValue {
                          TypeCode = TypeCode.String, Value = new[] { "zzz", "qxx" }, IsArray = true
                      } },
                    { "Q", new CustomFieldValue {
                          TypeCode = TypeCode.Decimal, Value = 2.0m
                      } },
                    { "Qq", new CustomFieldValue {
                          TypeCode = TypeCode.Double, Value = 10.0
                      } },
                    { "E", new CustomFieldValue {
                          TypeCode = TypeCode.String, Value = "ZZZ"
                      } },
                    { "ComplexFieldёX", new CustomFieldValue {
                          TypeCode = TypeCode.Int32, Value = 123
                      } },
                    { "ComplexFieldёZёS", new CustomFieldValue {
                          TypeCode = TypeCode.String, Value = "qzz"
                      } },
                    {
                        "ComplexArr", new CustomFieldValue
                        {
                            TypeCode  = TypeCode.Object,
                            IsArray   = true,
                            TypeCodes = new Dictionary <string, TypeCode> {
                                { "X", TypeCode.Int32 }, { "ZёS", TypeCode.String }, { "ZёE", TypeCode.String }
                            },
                            Value = new[] { new Hashtable {
                                                { "X", 314 }, { "ZёS", "qzz" }
                                            }, new Hashtable {
                                                { "X", 271 }, { "ZёS", "xxx" }, { "ZёE", "QXX" }
                                            } }
                        }
                    }
                })
            });

            Assert.AreEqual("zzz", data.S);
            Assert.AreEqual("qxx", data.F);
            Assert.AreEqual(2.0m, data.Q);
            Assert.AreEqual(10.0, data.Qq);
            Assert.AreEqual(TestEnum.Zzz, data.E);
            Assert.IsNotNull(data.ComplexField);
            Assert.AreEqual(123, data.ComplexField.X);
            Assert.IsNotNull(data.ComplexField.Z);
            Assert.AreEqual("qzz", data.ComplexField.Z.S);
            Assert.AreEqual(TestEnum.Zzz, data.ComplexField.Z.E);
            Assert.IsNotNull(data.StrArr);
            Assert.AreEqual(2, data.StrArr.Length);
            Assert.AreEqual("zzz", data.StrArr[0]);
            Assert.AreEqual("qxx", data.StrArr[1]);
            Assert.IsNotNull(data.ComplexArr);
            Assert.AreEqual(2, data.ComplexArr.Length);
            Assert.IsNotNull(data.ComplexArr[0]);
            Assert.AreEqual(314, data.ComplexArr[0].X);
            Assert.IsNotNull(data.ComplexArr[0].Z);
            Assert.AreEqual("qzz", data.ComplexArr[0].Z.S);
            Assert.AreEqual(TestEnum.Zzz, data.ComplexArr[0].Z.E);
            Assert.IsNotNull(data.ComplexArr[1]);
            Assert.AreEqual(271, data.ComplexArr[1].X);
            Assert.IsNotNull(data.ComplexArr[1].Z);
            Assert.AreEqual("xxx", data.ComplexArr[1].Z.S);
            Assert.AreEqual(TestEnum.Qxx, data.ComplexArr[1].Z.E);
        }
Ejemplo n.º 18
0
        public void TestDataToWebDataConverter()
        {
            var dataToWebDataConverterCollection = new TestConverterCollection <Data, WebData>(pathFormatterCollection, configurator =>
            {
                configurator.Target(x => x.Items.Each().Id).Set(x => x.Items.Current().Id);
                configurator.Target(x => x.F).Set(x => x.F);
            });
            var converter = dataToWebDataConverterCollection.GetConverter(MutatorsContext.Empty);
            var data      = converter(new Data
            {
                S            = "zzz",
                F            = "qxx",
                E            = TestEnum.Qxx,
                StrArr       = new[] { "zzz", "qxx" },
                ComplexField = new ComplexCustomField {
                    X = 123
                },
                ComplexArr = new[] { new ComplexCustomField {
                                         X = 314, Z = new ComplexCustomFieldSubClass {
                                             S = "qzz", E = TestEnum.Qxx
                                         }
                                     }, new ComplexCustomField {
                                         X = 271, Z = new ComplexCustomFieldSubClass {
                                             S = "xxx"
                                         }
                                     } }
            });

            Assert.IsNotNull(data.CustomFields);
            Assert.IsFalse(data.CustomFields.Value.ContainsKey("F"));
            Assert.AreEqual("qxx", data.F);
            Assert.That(data.CustomFields.Value.ContainsKey("S"));
            Assert.IsNotNull(data.CustomFields.Value["S"]);
            Assert.AreEqual("zzz", data.CustomFields.Value["S"].Value);
            Assert.AreEqual(TypeCode.String, data.CustomFields.Value["S"].TypeCode);
            Assert.That(data.CustomFields.Value.ContainsKey("E"));
            Assert.IsNotNull(data.CustomFields.Value["E"]);
            Assert.AreEqual("QXX", data.CustomFields.Value["E"].Value);
            Assert.AreEqual(TypeCode.String, data.CustomFields.Value["E"].TypeCode);
            Assert.That(data.CustomFields.Value.ContainsKey("ComplexFieldёX"));
            Assert.IsNotNull(data.CustomFields.Value["ComplexFieldёX"]);
            Assert.AreEqual(123, data.CustomFields.Value["ComplexFieldёX"].Value);
            Assert.AreEqual(TypeCode.Int32, data.CustomFields.Value["ComplexFieldёX"].TypeCode);
            Assert.That(data.CustomFields.Value.ContainsKey("ComplexFieldёZёE"));
            Assert.IsNotNull(data.CustomFields.Value["ComplexFieldёZёE"]);
            Assert.AreEqual("ZZZ", data.CustomFields.Value["ComplexFieldёZёE"].Value);
            Assert.AreEqual(TypeCode.String, data.CustomFields.Value["ComplexFieldёZёE"].TypeCode);
            Assert.That(data.CustomFields.Value.ContainsKey("StrArr"));
            Assert.AreEqual(TypeCode.String, data.CustomFields.Value["StrArr"].TypeCode);
            Assert.IsTrue(data.CustomFields.Value["StrArr"].IsArray);
            var strArr = data.CustomFields.Value["StrArr"].Value as string[];

            Assert.IsNotNull(strArr);
            Assert.AreEqual(2, strArr.Length);
            Assert.AreEqual("zzz", strArr[0]);
            Assert.AreEqual("qxx", strArr[1]);
            Assert.That(data.CustomFields.Value.ContainsKey("ComplexArr"));
            Assert.AreEqual(TypeCode.Object, data.CustomFields.Value["ComplexArr"].TypeCode);
            Assert.IsTrue(data.CustomFields.Value["ComplexArr"].IsArray);
            var typeCodes = data.CustomFields.Value["ComplexArr"].TypeCodes;

            Assert.IsNotNull(typeCodes);
            Assert.That(typeCodes.ContainsKey("X"));
            Assert.AreEqual(TypeCode.Int32, typeCodes["X"]);
            Assert.That(typeCodes.ContainsKey("ZёS"));
            Assert.AreEqual(TypeCode.String, typeCodes["ZёS"]);
            Assert.That(typeCodes.ContainsKey("ZёE"));
            Assert.AreEqual(TypeCode.String, typeCodes["ZёE"]);
            var complexArr = data.CustomFields.Value["ComplexArr"].Value as object[];

            Assert.IsNotNull(complexArr);
            Assert.AreEqual(2, complexArr.Length);
            var hashtable = complexArr[0] as Hashtable;

            Assert.IsNotNull(hashtable);
            Assert.AreEqual(hashtable["X"], 314);
            Assert.AreEqual(hashtable["ZёS"], "qzz");
            Assert.AreEqual(hashtable["ZёE"], "QXX");
            hashtable = complexArr[1] as Hashtable;
            Assert.IsNotNull(hashtable);
            Assert.AreEqual(hashtable["X"], 271);
            Assert.AreEqual(hashtable["ZёS"], "xxx");
            Assert.AreEqual(hashtable["ZёE"], "ZZZ");
        }
        public void TestExcludeTypesFromCoverage()
        {
            var recorder = AssignRecorderInitializer.StartAssignRecorder()
                           .ExcludingType <TestDataSource>()
                           .ExcludingInterface <ITestInterface>()
                           .ExcludingProperty((TestComplexDataDest x) => x.FieldY)
                           .ExcludingGenericProperty((IGenericTestInterface <object> x) => x.IntA);
            var converterCollection = new TestConverterCollection <TestComplexDataSource, TestComplexDataDest>(pathFormatterCollection,
                                                                                                               configurator =>
            {
                configurator.Target(x => x.FieldC.A).Set(x => x.FieldA.B);
                configurator.Target(x => x.FieldC.B).Set(x => x.FieldA.A);
                configurator.Target(x => x.FieldD.StrB).Set(x => x.FieldB.StrA);
                configurator.Target(x => x.FieldD.StrA).Set(x => x.FieldB.StrB);
                configurator.Target(x => x.FieldY).If(x => x.FieldA.A > 10).Set(x => x.FieldX);
                configurator.Target(x => x.IntField.IntA).Set(x => x.IntField.IntA);
                configurator.Target(x => x.IntField.IntB).Set(x => x.IntField.IntB);
                configurator.Target(x => x.TestProperty).Set(x => x.TestProperty.S);
            });
            var source = new TestComplexDataSource
            {
                FieldA = new TestDataSource(),
                FieldB = new TestDataSourceNullable
                {
                    StrA = "a",
                    StrB = "b"
                },
                FieldX   = "aba",
                IntField = new TestDataSourceNullableInt
                {
                    IntA = 1
                },
                TestProperty = new TestInterfaceImpl {
                    S = "GRobas"
                }
            };
            var converter = converterCollection.GetConverter(MutatorsContext.Empty);

            converter(source);
            recorder.Stop();

            var records = recorder.GetRecords()[0].Records;
            var record  = records["TestComplexDataDest"];

            Assert.AreEqual("TestComplexDataDest", record.Name);
            Assert.IsFalse(record.IsExcludedFromCoverage);

            records = record.Records;
            record  = records["FieldC"];

            Assert.AreEqual("FieldC", record.Name);
            Assert.IsTrue(record.IsExcludedFromCoverage);
            Assert.AreEqual("A", record.Records["A"].Name);
            Assert.IsTrue(record.Records["A"].IsExcludedFromCoverage);
            Assert.AreEqual("B", record.Records["B"].Name);
            Assert.IsTrue(record.Records["B"].IsExcludedFromCoverage);

            record = records["FieldD"];
            Assert.AreEqual("FieldD", record.Name);
            Assert.IsFalse(record.IsExcludedFromCoverage);
            Assert.AreEqual("StrB", record.Records["StrB"].Name);
            Assert.IsFalse(record.Records["StrB"].IsExcludedFromCoverage);
            Assert.AreEqual("StrA", record.Records["StrA"].Name);
            Assert.IsFalse(record.Records["StrA"].IsExcludedFromCoverage);

            record = records["FieldY"];
            Assert.AreEqual("FieldY", record.Name);
            Assert.IsTrue(record.IsExcludedFromCoverage);

            record = records["IntField"];
            Assert.AreEqual("IntField", record.Name);
            Assert.IsFalse(record.IsExcludedFromCoverage);
            Assert.AreEqual("IntA", record.Records["IntA"].Name);
            Assert.IsTrue(record.Records["IntA"].IsExcludedFromCoverage);
            Assert.AreEqual("IntB", record.Records["IntB"].Name);
            Assert.IsFalse(record.Records["IntB"].IsExcludedFromCoverage);

            record = records["TestProperty"];
            Assert.AreEqual("TestProperty", record.Name);
            Assert.IsTrue(record.IsExcludedFromCoverage);
        }