Exemple #1
0
        public bool SaveGranule(GranuleSet granuleSet, out string error)
        {
            error = null;
            if (granuleSet == null)
            {
                error = "Pusty zbiór granul.";
                return(false);
            }

            var path = _fileService.GetPathFromSaveFileDialog(FileService.CsvFilter);

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

                return(false);
            }

            var content = _printGranuleService.Print(granuleSet);

            return(_fileService.SaveFile(path, content, out error));
        }
Exemple #2
0
        public void Print_WhenPutGranuleSet_ThenShouldPreparePrint()
        {
            //Arrange
            var granuleSet = new GranuleSet()
            {
                new Granule(new[] { 1, 0, 1 }, 1), new Granule(new[] { 1, 1, 1 }, 2), new Granule(new[] { 0, 0, 1 }, 3)
            };

            //Act
            var result = _fileReaderService.Print(granuleSet);

            //Assert
            var expected = new List <string> {
                ";g(u1);g(u2);g(u3)", "u1;1;1;0", "u2;0;1;0", "u3;1;1;1"
            };

            Assert.Equal(expected, result);
        }