예제 #1
0
        public void ConvertContentToData_WhenPassRightContent_ThenShouldConvertToDataWithoutError()
        {
            // Arrange
            var content = new List <string> {
                "1;2;3", "1;2;3", "1;2;3"
            };

            // Act
            var result = _coverageDataConverter.Convert(content, out var error);

            // Assert
            var expected = new CoverageData(new List <List <int> >
            {
                new List <int> {
                    1, 2, 3
                }, new List <int> {
                    1, 2, 3
                }, new List <int> {
                    1, 2, 3
                }
            });

            Assert.Equal(expected, result);
            Assert.Null(error);
        }
예제 #2
0
        public GranuleSetWithPath Load(out string error)
        {
            error = null;
            var path = _fileService.GetPathFromOpenFileDialog(FileService.CsvFilter);

            if (string.IsNullOrEmpty(path))
            {
                if (path == string.Empty)
                {
                    error = "Ścieżka do pliku jest pusta.";
                }

                return(null);
            }

            var content = _fileService.ReadFile(path, out error);

            if (!string.IsNullOrEmpty(error))
            {
                return(null);
            }

            var data = _coverageDataConverter.Convert(content, out error);

            if (data == null)
            {
                return(null);
            }

            var coverageFile = new CoverageFile(path, data);

            if (!_coverageFileValidator.Valid(coverageFile, out error))
            {
                return(null);
            }

            var granuleSet = _granuleService.GenerateGran(coverageFile.CoverageData);

            return(new GranuleSetWithPath(granuleSet, path));
        }