public void EndPosition()
        {
            var testInstance = new ExclusionPositions();
            testInstance.EndPosition = 10;

            Assert.AreEqual(10, testInstance.EndPosition);
        }
        public void StartPosition()
        {
            var testInstance = new ExclusionPositions();
            testInstance.StartPosition = 6;

            Assert.AreEqual(6, testInstance.StartPosition);
        }
예제 #3
0
        public void ExclusionBitMap()
        {
            var testInstance = new Exclusion();

            var testValue = new ExclusionPositions();
            testValue.StartPosition = 1;
            testValue.EndPosition = 3;
            testInstance.ExclusionPositions.Add(testValue);

            testValue = new ExclusionPositions();
            testValue.StartPosition = 7;
            testValue.EndPosition = 10;
            testInstance.ExclusionPositions.Add(testValue);

            var expectedVal = new bool[10];
            expectedVal[0] = true;
            expectedVal[1] = true;
            expectedVal[2] = true;
            expectedVal[6] = true;
            expectedVal[7] = true;
            expectedVal[8] = true;
            expectedVal[9] = true;
            bool[] retVal = testInstance.ExclusionBitMap;

            Assert.AreEqual(expectedVal, retVal);
        }
        private static List<Exclusion> ParseExclusions(XmlNode testConfig)
        {
            var exclusions = new List<Exclusion>();

            XmlNodeList exclusionNodes = testConfig.SelectNodes("exclusions/rowType");

            if (exclusionNodes != null)
            {
                foreach (XmlNode exclusionNode in exclusionNodes)
                {
                    var exclusion = new Exclusion();
                    if (exclusionNode.Attributes != null)
                    {
                        exclusion.RowIdentifyingRegularExpression = exclusionNode.Attributes["identifier"].Value;

                        foreach (XmlNode positionNode in exclusionNode.ChildNodes)
                        {
                            var positions = new ExclusionPositions();
                            if (positionNode.Attributes != null)
                            {
                                positions.StartPosition = int.Parse(positionNode.Attributes["startPosition"].Value, CultureInfo.InvariantCulture);
                                positions.EndPosition = int.Parse(positionNode.Attributes["endPosition"].Value, CultureInfo.InvariantCulture);
                            }
                            exclusion.ExclusionPositions.Add(positions);
                        }
                    }
                    exclusions.Add(exclusion);
                }
            }
            return exclusions;
        }
예제 #5
0
        public void ExclusionPositions()
        {
            var testInstance = new List<ExclusionPositions>();
            var testValue = new ExclusionPositions();

            testValue.StartPosition = 10;
            testValue.EndPosition = 20;

            testInstance.Add(testValue);

            Assert.AreEqual(10, testInstance[0].StartPosition);
            Assert.AreEqual(20, testInstance[0].EndPosition);
        }
 public void ExclusionProperty()
 {
     var testList = new List<Exclusion>();
     var testValue = new Exclusion();
     var testExclusionPositions = new ExclusionPositions();
     testExclusionPositions.StartPosition = 10;
     testExclusionPositions.EndPosition = 20;
     testValue.ExclusionPositions.Add(testExclusionPositions);
     testList.Add(testValue);
     var testInstance = new BizUnitFlatfileCompareConfiguration();
     testInstance.Exclusions = testList;
     Assert.AreEqual(10, testInstance.Exclusions[0].ExclusionPositions[0].StartPosition);
     Assert.AreEqual(20, testInstance.Exclusions[0].ExclusionPositions[0].EndPosition);
 }
예제 #7
0
        public void RemoveExclusions()
        {
            var inputData = new StringBuilder();
            inputData.AppendLine("this is the input");
            inputData.AppendLine("should not be touched");

            var expectedData = new StringBuilder();
            expectedData.AppendLine("thisistheinput");
            expectedData.AppendLine("should not be touched");

            StreamWriter writer = File.CreateText(_documentPath);
            writer.Write(inputData.ToString());
            writer.Dispose();

            var exclusions = new List<Exclusion>();
            var exclusion = new Exclusion();
            exclusion.RowIdentifyingRegularExpression = "this";

            var position = new ExclusionPositions();
            position.StartPosition = 5;
            position.EndPosition = 5;
            exclusion.ExclusionPositions.Add(position);

            position = new ExclusionPositions();
            position.StartPosition = 8;
            position.EndPosition = 8;
            exclusion.ExclusionPositions.Add(position);

            position = new ExclusionPositions();
            position.StartPosition = 12;
            position.EndPosition = 12;
            exclusion.ExclusionPositions.Add(position);

            exclusions.Add(exclusion);

            MemoryStream returnStream = FlatfileCleaner.RemoveExclusions(_documentPath, exclusions);
            var returnReader = new StreamReader(returnStream);
            string returnString = returnReader.ReadToEnd();
            returnStream.Dispose();

            Assert.AreEqual(expectedData.ToString(), returnString);
        }