public static void LoadData()
    {
        HtmlRedirectTemplate = "<html><head><meta http-equiv=\"refresh\" content=\"0;" +
                               "url=http://localhost:8005/article/{0}\"></head></html>";

        //var file = HostingEnvironment.MapPath(@"/App_Code/CheckMarxMapping.xml");
        var file = AppDomain.CurrentDomain.BaseDirectory + @"App_Code\CheckMarxMapping.xml";

        string xmlResult;
        xmlResult = string.Empty;
        using (var fs = new FileStream(file, FileMode.Open))
        {
            var sw = new StreamReader(fs);
            xmlResult = sw.ReadToEnd();
        }
        var checkMarxDataMapping = new CheckMarxDataMapping();
        var serializer = new XmlSerializer(typeof(CheckMarxDataMapping));
        if (xmlResult != null)
        {
            using (var reader = new StringReader(xmlResult))
                checkMarxDataMapping = (CheckMarxDataMapping) serializer.Deserialize(reader);
        }
        //Loading a Dictionary
        if (checkMarxDataMapping != null)
            checkMarxDataMapping.Mapping.ForEach(x => Tm_QueryId_Mappings.Add(x.QueryId, x.Guid));
    }
        public void Serialization_And_Deserialization_Works_Ok()
        {
            var DataMapping = new CheckMarxDataMapping {Mapping = GetData()};

            var serializer = new XmlSerializer(DataMapping.GetType());
            string xmlResult;

            using (var ms = new MemoryStream())
            {
                using (var sw = new StreamWriter(ms))
                {
                    serializer.Serialize(sw, DataMapping);
                    xmlResult = Encoding.UTF8.GetString(ms.ToArray());
                }
            }

            CheckMarxDataMapping deserializedResult;
            using (var reader = new StringReader(xmlResult))
            {
                deserializedResult = (CheckMarxDataMapping) serializer.Deserialize(reader);
            }

            Assert.IsTrue(deserializedResult!=null);
            Assert.IsTrue(deserializedResult.Mapping.Count() == 114);
        }
    public static void LoadData()
    {
        HtmlRedirectTemplate = "<html><head><meta http-equiv=\"refresh\" content=\"0;" +
                               "url=http://localhost:8005/article/{0}\"></head></html>";

        //var file = HostingEnvironment.MapPath(@"/App_Code/CheckMarxMapping.xml");
        var file = AppDomain.CurrentDomain.BaseDirectory + @"App_Code\CheckMarxMapping.xml";

        string xmlResult;

        xmlResult = string.Empty;
        using (var fs = new FileStream(file, FileMode.Open))
        {
            var sw = new StreamReader(fs);
            xmlResult = sw.ReadToEnd();
        }
        var checkMarxDataMapping = new CheckMarxDataMapping();
        var serializer           = new XmlSerializer(typeof(CheckMarxDataMapping));

        if (xmlResult != null)
        {
            using (var reader = new StringReader(xmlResult))
                checkMarxDataMapping = (CheckMarxDataMapping)serializer.Deserialize(reader);
        }
        //Loading a Dictionary
        if (checkMarxDataMapping != null)
        {
            checkMarxDataMapping.Mapping.ForEach(x => Tm_QueryId_Mappings.Add(x.QueryId, x.Guid));
        }
    }
        public void Serialization_And_Deserialization_Looks_Good()
        {
            var DataMapping = new CheckMarxDataMapping {
                Mapping = GetData()
            };

            var    serializer = new XmlSerializer(DataMapping.GetType());
            string xmlResult;

            using (var ms = new MemoryStream())
            {
                using (var sw = new StreamWriter(ms))
                {
                    serializer.Serialize(sw, DataMapping);
                    xmlResult = Encoding.UTF8.GetString(ms.ToArray());
                }
            }
            //xmlResult.saveAs(@"C:\temp\CheckMarxMapping.xml");
            //Deserializing
            CheckMarxDataMapping deserializedResult;

            using (var reader = new StringReader(xmlResult))
            {
                deserializedResult = (CheckMarxDataMapping)serializer.Deserialize(reader);
            }

            Assert.IsTrue(deserializedResult.notNull());
            Assert.IsTrue(deserializedResult.Mapping.Count() == 95);
        }
        public void Serialization_And_Deserialization_Looks_Good()
        {
            var DataMapping = new CheckMarxDataMapping {Mapping = GetData()};

            var serializer = new XmlSerializer(DataMapping.GetType());
            string xmlResult;

            using (var ms = new MemoryStream())
            {
                using (var sw = new StreamWriter(ms))
                {
                    serializer.Serialize(sw, DataMapping);
                    xmlResult = Encoding.UTF8.GetString(ms.ToArray());
                }
            }
            //xmlResult.saveAs(@"C:\temp\CheckMarxMapping.xml");
            //Deserializing
            CheckMarxDataMapping deserializedResult;
            using (var reader = new StringReader(xmlResult))
            {
                deserializedResult = (CheckMarxDataMapping) serializer.Deserialize(reader);
            }

            Assert.IsTrue(deserializedResult.notNull());
            Assert.IsTrue(deserializedResult.Mapping.Count() == 95);
        }
        public void DataItemsAreCorrect()
        {
            var DataMapping = new CheckMarxDataMapping {Mapping = GetData()};

            Assert.IsTrue(DataMapping.Mapping.notNull());

            Assert.IsTrue(DataMapping.Mapping.Count == 95);
        }
        public void DataItemsAreCorrect()
        {
            var DataMapping = new CheckMarxDataMapping {
                Mapping = GetData()
            };

            Assert.IsTrue(DataMapping.Mapping.notNull());

            Assert.IsTrue(DataMapping.Mapping.Count == 95);
        }
        public void DataItems_Are_Not_Duplicated()
        {
            var DataMapping = new CheckMarxDataMapping {Mapping = GetData()};
            List<DataItem> mapping = DataMapping.Mapping;

            int filteredResults = mapping.GroupBy(x => x.QueryId)
                                         .Where(group => group.Count() > 1)
                                         .Select(group => group.Key).Count();

            //FilteredResults equals 0 means that there are not duplicated
            Assert.IsTrue(filteredResults.notNull());
            Assert.IsTrue(filteredResults == 0);
        }
        public void DataItems_Are_Not_Duplicated()
        {
            var DataMapping = new CheckMarxDataMapping {
                Mapping = GetData()
            };
            List <DataItem> mapping = DataMapping.Mapping;

            int filteredResults = mapping.GroupBy(x => x.QueryId)
                                  .Where(group => group.Count() > 1)
                                  .Select(group => group.Key).Count();

            //FilteredResults equals 0 means that there are not duplicated
            Assert.IsTrue(filteredResults.notNull());
            Assert.IsTrue(filteredResults == 0);
        }
        public void CheckMarx_DataItems_AreCorrect()
        {
            var DataMapping = new CheckMarxDataMapping {Mapping = GetData()};

            Assert.IsTrue(DataMapping.Mapping!=null);

            Assert.IsTrue(DataMapping.Mapping.Count == 114);
            IOrderedEnumerable<DataItem> orderedEnumerable = DataMapping.Mapping.OrderBy(item => item.QueryId);

            var minQueryId = orderedEnumerable.Min(x => x.QueryId);
            var maxQueryId = orderedEnumerable.Max(x => x.QueryId);

            var firstOrDefault = orderedEnumerable.FirstOrDefault();
            Assert.IsTrue(firstOrDefault != null && minQueryId ==firstOrDefault.QueryId);
            var lastOrDefault = orderedEnumerable.LastOrDefault();
            Assert.IsTrue(lastOrDefault != null && maxQueryId ==lastOrDefault.QueryId);
        }
        public void Mapping_Contains_Elements_With_Same_GUID_But_Different_QueryID()
        {
            var DataMapping = new CheckMarxDataMapping {Mapping = GetData()};
            List<DataItem> mapping = DataMapping.Mapping;

            List<IGrouping<string, DataItem>> resultsWithSameGUID = mapping.GroupBy(x => x.Guid)
                                                                           .Where(group => group.Count() > 1)
                                                                           .Select(x => x).ToList();

            //There should be DataItems with the same GUID
            Assert.IsTrue(resultsWithSameGUID!=null);
            Assert.IsTrue(resultsWithSameGUID.Count > 0);

            //Those DataItems with the same GUID should have different QueryID
            List<IGrouping<int, DataItem>> results = mapping.GroupBy(x => x.QueryId)
                                                            .Where(group => group.Count() > 1)
                                                            .Select(x => x).ToList();

            Assert.IsTrue(results!=null);
            Assert.IsTrue(results.Count == 0);
        }
        public void Mapping_Contains_Elements_With_Same_GUID_But_Different_QueryID()
        {
            var DataMapping = new CheckMarxDataMapping {
                Mapping = GetData()
            };
            List <DataItem> mapping = DataMapping.Mapping;

            List <IGrouping <string, DataItem> > resultsWithSameGUID = mapping.GroupBy(x => x.Guid)
                                                                       .Where(group => group.Count() > 1)
                                                                       .Select(x => x).ToList();

            //There should be DataItems with the same GUID
            Assert.IsTrue(resultsWithSameGUID.notNull());
            Assert.IsTrue(resultsWithSameGUID.Count > 0);

            //Those DataItems with the same GUID should have different QueryID
            List <IGrouping <int, DataItem> > results = mapping.GroupBy(x => x.QueryId)
                                                        .Where(group => group.Count() > 1)
                                                        .Select(x => x).ToList();

            Assert.IsTrue(results.notNull());
            Assert.IsTrue(results.count() == 0);
        }