Browse Source

Added TotalSegments

Piotr Czajkowski 3 years ago
parent
commit
32cf64425e
2 changed files with 24 additions and 1 deletions
  1. 9 1
      memoQAnalysis/MemoQAnalysis.cs
  2. 15 0
      memoQAnalysisTests/AnalysisTests.cs

+ 9 - 1
memoQAnalysis/MemoQAnalysis.cs

@@ -251,7 +251,15 @@ namespace memoQAnalysis
         public int FragmentsReserved3 { get; set; }
 
         [Index(82)]
-        public int TotalSegments { get; set; }
+        public int TotalSegments {
+            get
+            {
+                var total = XtranslatedSegments + HundredOneSegments + RepetitionsSegments + HundredSegments +
+                            NinentyFiveNineSegments + EightyFiveNinentyFourSegments + SeventyFiveEightyFourSegments +
+                            FiftySeventyFourSegments + NoMatchSegments + FragmentsSegments;
+                return total;
+            }
+        }
 
         [Index(83)]
         public int TotalWords {

+ 15 - 0
memoQAnalysisTests/AnalysisTests.cs

@@ -69,6 +69,21 @@ namespace memoQAnalysisTests
             Assert.Equal(expectedTotal, newTotal);
         }
 
+        [Fact]
+        public void TotalSegments()
+        {
+            var test = new Analysis(MainTestFile);
+            var total = test.Data.Sum(x => x.TotalSegments);
+
+            var originalFirstFile = test.Data.FirstOrDefault();
+            Assert.NotNull(originalFirstFile);
+            originalFirstFile.FiftySeventyFourSegments += 1050;
+
+            var expectedTotal = total + 1050;
+            var newTotal = test.Data.Sum(x => x.TotalSegments);
+            Assert.Equal(expectedTotal, newTotal);
+        }
+
         [Fact]
         public void ReadModifySaveCheck()
         {