예제 #1
0
        public void TestSimpleCSV(string fileContents, string fromName, string toName)
        {
            IReceive    receiver = null;
            IDataToSent data     = null;
            var         nl       = Environment.NewLine;

            fileContents = fileContents.Replace("{NewLine}", nl);
            $"When I create the receiver csv for the content {fileContents}".w(() =>
                                                                               receiver = new ReceiverCSVText(fileContents));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With a table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
            });
            $"and the table should contain column name {fromName}".w(() => {
                data.DataToBeSentFurther[0].Columns.Contains(fromName).Should().BeTrue();
                data.DataToBeSentFurther[0].Columns.Contains(toName).Should().BeFalse();
            });

            $"and applying {nameof(ChangeColumnName)} from {fromName} to {toName}".w(async() =>
                                                                                     data = await new ChangeColumnName(fromName, toName).TransformData(data));

            $"and the table should contain column name {toName}".w(() => {
                data.DataToBeSentFurther[0].Columns.Contains(toName).Should().BeTrue();
                data.DataToBeSentFurther[0].Columns.Contains(fromName).Should().BeFalse();
            });
        }
        public void TestSimpleCSV(string fileContents, int nrStart, string format, string formatAfterRegex)
        {
            IReceive    receiver = null;
            IDataToSent data     = null;
            var         nl       = Environment.NewLine;

            fileContents = fileContents.Replace("{NewLine}", nl);
            $"When I create the receiver csv for the content {fileContents}".w(() =>
                                                                               receiver = new ReceiverCSVText(fileContents));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With a table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
            });
            $"and applying {nameof(TransformerRenameTablesInOrder)} with {nrStart} and {format}".w(async() =>
                                                                                                   data = await new TransformerRenameTablesInOrder(nrStart, format).TransformData(data));

            $"the name of the table should be {nrStart.ToString(format)}".w(() =>
                                                                            data.DataToBeSentFurther[0].TableName.Should().Be(nrStart.ToString(format)));

            $" and after applying {nameof(ChangeTableNamesRegex)} ".w(async() =>
                                                                      data = await new ChangeTableNamesRegex("(?:.+ )((?<name>.+))").TransformData(data));

            $"the name of the table should be {nrStart}".w(() =>
                                                           data.DataToBeSentFurther[0].TableName.Should().Be(nrStart.ToString(formatAfterRegex)));
        }
예제 #3
0
        public void Add <T>(IReceive receive)
        {
            var list = GetList(typeof(T));

            list.Add(receive);
            list.Sort(_receiverSorter);
        }
        public void TestSimpleReceive(string newFileName, int numberRows)
        {
            string newFolder = Guid.NewGuid().ToString("N");
            var    dir       = Path.Combine(Environment.CurrentDirectory, newFolder);

            Directory.CreateDirectory(dir);
            var full = Path.Combine(dir, newFileName);

            File.WriteAllText(full, newFileName);

            IReceive    receiver = null;
            IDataToSent data     = null;
            var         nl       = Environment.NewLine;

            $"When I create the receiver files in folder {newFolder}".w(() => receiver = new ReceiverReadFileText(full));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With a table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
            });
            $"The number of rows should be {numberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(numberRows));
            $"and the contents should be {newFileName}".w(() =>
                                                          data.DataToBeSentFurther[0].Rows[0]["FileContents"].Should().Be(newFileName));

            $"and the FilePath should be {full}".w(() =>
                                                   data.DataToBeSentFurther[0].Rows[0]["FilePath"].Should().Be(full));
        }
예제 #5
0
 public Communicate(Schema schema, IShouldReceive shouldReceive, IReceive receive, ISend send)
 {
     _schema        = schema;
     _shouldReceive = shouldReceive;
     _receive       = receive;
     _send          = send;
 }
예제 #6
0
        public void TestSimpleSenderOutputToExcel(string fileContents, int NumberRows, string fileName)
        {
            IReceive        receiver = null;
            IDataToSent     data     = null;
            ISenderToOutput sender   = null;
            var             nl       = Environment.NewLine;

            fileContents = fileContents.Replace("{NewLine}", nl);
            fileName     = Guid.NewGuid().ToString("N") + fileName;
            $"the Excel {fileName} should not exists".w(() => File.Exists(fileName).Should().BeFalse());
            $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With a table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
            });
            $"The number of rows should be {NumberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRows));
            $"and now I want to export to excel file ".w(async() =>
            {
                sender = new SenderOutputExcel(fileName);
                data   = await sender.TransformData(data);
            }
                                                         );
            $"the Excel should exists".w(() => {
                sender.OutputByte.Should().NotBeNull();
                sender.OutputByte.Rows.Count.Should().Be(1);
            });
        }
예제 #7
0
        public void TestSimpleCSV(string fileContents, int NumberRows)
        {
            IReceive    receiver = null;
            IDataToSent data     = null;
            var         nl       = Environment.NewLine;

            fileContents = fileContents.Replace("{NewLine}", nl);
            $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With a table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
            });
            $"The number of rows should be {NumberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRows));
            var filesCSV = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.json");

            foreach (var f in filesCSV)
            {
                File.Delete(f);
            }
            $" and no csv files existing".w(() => Directory.GetFiles(Directory.GetCurrentDirectory(), "*.csv").Length.Should().Be(0));
            $"and now I export to json to the current folder".w(async() => data = await new SenderDefinitionToFile("a.json").TransformData(data));
            $" and now 1 json files existing".w(() => Directory.GetFiles(Directory.GetCurrentDirectory(), "*.json").Length.Should().Be(1));
        }
예제 #8
0
        public void TestAmazonCopyPasteStackOverflow(string fileName, int nrRows, string author)
        {
            IReceive    receiver  = null;
            IDataToSent data      = null;
            DataTable   dtContent = null;

            $"Given the file {fileName} ".w(() =>
            {
                File.Exists(fileName).Should().BeTrue();
            });
            $"When I create the {nameof(AmazonMeta)} for the {fileName}".w(() => receiver = new AmazonMeta(fileName, null));

            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With a table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
            });
            $"The number of rows should be {nrRows}".w(() =>
            {
                dtContent = data.DataToBeSentFurther[0];
                dtContent.Rows.Count.Should().Be(nrRows);
            });
            $"and should contain as {nameof(author)} me: {author}".w(() =>
            {
                var dv       = new DataView(dtContent);
                dv.RowFilter = $"meta_name='author'";
                dv.Count.Should().Be(1);
                dv[0]["meta_content"].ToString().Should().Be((author));
            });
        }
예제 #9
0
        public void SelectFromDb(string connectionString, string select, int nrRows, string result)
        {
            var fileName = Path.Combine(Environment.CurrentDirectory, Guid.NewGuid().ToString("N"));

            File.WriteAllText(fileName, select);
            IReceive status = null;

            IDataToSent data = null;

            $"Assume Sql Server instance {connectionString} exists , if not see docker folder".w(() => {
            });
            $"When I create the ReceiveQueryFromFileSql ".w(() => status = new ReceiveQueryFromFileSql(fileName, connectionString));
            $"and receive data".w(async() =>
            {
                data = await status.TransformData(null);
            });
            $"the data should have a table".w(() =>
            {
                data.DataToBeSentFurther.Count.Should().Be(2); // first table file, second table sql
            });


            $"should be {nrRows} rows".w(() => { data.DataToBeSentFurther[1].Rows.Count.Should().Be(nrRows); });

            $"and the result should be {result} ".w(() => { data.DataToBeSentFurther[1].Rows[0][0]?.ToString().Should().Be(result); });
        }
예제 #10
0
        //[Example("Server=(local);Database=msdb;User Id=SA;Password = <YourStrong!Passw0rd>;", "sys.tables", "a.xlsx")]
        public void ExportTableToExcelSql(string connectionString, string tableName, string fileName)
        {
            IReceive status = null;

            IDataToSent data = null;

            fileName = Guid.NewGuid().ToString("N") + fileName;


            $"the Excel {fileName} should not exists".w(() => File.Exists(fileName).Should().BeFalse());
            $"Assume Sql Server instance {connectionString} exists , if not see docker folder".w(() => { });

            $"When I create the ExportTableToExcelSql ".w(() =>
                                                          status = new ExportTableToExcelSql(connectionString, tableName, fileName));
            $"and receive data".w(async() => { data = await status.TransformData(null); });
            $"the data should have a table".w(() =>
            {
                data.DataToBeSentFurther.Count.Should().Be(3);
                //table + 2 outputs
            });



            $"the Excel {fileName} should  exists".w(() => File.Exists(fileName).Should().BeTrue());
        }
예제 #11
0
        public void TestAliveJob(string url, string job, int numberTables)
        {
            //if this does not work and you have already a jenkins running in docker-compose
            //run this
            //docker exec docker_jenkins_1 bash -c "cat /var/jenkins_home/jenkinsjob.xml | java -jar /var/jenkins_home/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080 create-job newmyjob"

            IReceive receiver = null;

            IDataToSent data = null;
            string      nl   = Environment.NewLine;

            $"When I create the {nameof(ReceiverJenkinsJob)} for the {url}".w(() => receiver = new ReceiverJenkinsJob(url, job));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With {numberTables} table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().BeGreaterOrEqualTo(numberTables);
            });
            $"and should have data success".w(() =>
            {
                var res = AliveStatus.FromTable(data.DataToBeSentFurther.First().Value);
                res.Should().NotBeNull();
                res.Count().Should().Be(1);
                res.First().IsSuccess.Should().Be(true);
            });
        }
예제 #12
0
        public void SelectFromDb(string connectionString, int nrTables, int nrRows, string select1, string val1, string select2,
                                 string val2)
        {
            var pathName = Path.Combine(Environment.CurrentDirectory, Guid.NewGuid().ToString("N"));

            Directory.CreateDirectory(pathName);
            File.WriteAllText(Path.Combine(pathName, "a1.sql"), select1);
            File.WriteAllText(Path.Combine(pathName, "a2.sql"), select2);
            IReceive status = null;

            IDataToSent data = null;

            $"Assume Sql Server instance {connectionString} exists , if not see docker folder".w(() => { });
            $"When I create the ReceiveQueryFromFileSql ".w(() =>
                                                            status = new ReceiveQueryFromFolderSql(pathName, "*.sql", connectionString));
            $"and receive data".w(async() => { data = await status.TransformData(null); });
            $"the data should have {nrTables} table".w(() =>
            {
                data.DataToBeSentFurther.Count.Should().Be(nrTables); // first table files, other table sql's
            });


            $"should be {nrRows} rows".w(() =>
            {
                data.FindAfterName(select1).Value.Rows.Count.Should().Be(nrRows);
                data.FindAfterName(select2).Value.Rows.Count.Should().Be(nrRows);
            });

            $"and the result should contain {val1} ".w(() =>
            {
                data.FindAfterName(select1).Value.Rows[0][0]?.ToString().Should().Be(val1);
                data.FindAfterName(select2).Value.Rows[0][0]?.ToString().Should().Be(val2);
            });
        }
예제 #13
0
        public void TestSimpleExcel(string fileName, int NumberSheets, string verifySheet, int nrCols, int nrRows)
        {
            IReceive    receiver = null;
            IDataToSent data     = null;

            $"When I create the receiver Excel for the {fileName}".w(() => receiver = new ReceiverExcel(fileName));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With some tables".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
            });
            $"The number of sheets should be {NumberSheets}".w(() => data.DataToBeSentFurther.Count.Should().Be(NumberSheets + 1));
            $"and verification for first sheet ".w(() =>
            {
                var firstTable = data.FindAfterName(verifySheet).Value;
                firstTable.Columns.Count.Should().Be(nrCols);
                firstTable.Rows.Count.Should().Be(nrRows);

                //firstTable.Rows[0].ItemArray[0].Should().Be("Browsers");
                //firstTable.Rows[0].ItemArray[7].Should().Be(1);
                //firstTable.Rows[7].ItemArray[0].Should().Be("Communications");
                //firstTable.Rows[7].ItemArray[7].Should().Be(5);
            });
        }
예제 #14
0
        public void TestSimpleCSV(string fileContents, int numberRows, string filter, string contain, int numberRowsAfterFilter)
        {
            IReceive    receiver = null;
            IDataToSent data     = null;
            var         nl       = Environment.NewLine;

            fileContents = fileContents.Replace("{NewLine}", nl);
            $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With 1 tables and {numberRows} rows".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
                data.DataToBeSentFurther[0].Rows.Count.Should().Be(numberRows);
            });
            $"And when I filter with {filter} {contain} ".w(async() => data = await new FilterRetainColumnDataContains(filter, contain).TransformData(data));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With 1 table and {numberRowsAfterFilter} after filter".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
                data.DataToBeSentFurther[0].Rows.Count.Should().Be(numberRowsAfterFilter);
            });
        }
            public void TestSimpleCSV(string fileContents, int NumberRows, int NumberRowsAfterFilter)
            {
                IReceive    receiver = null;
                IDataToSent data     = null;
                var         nl       = Environment.NewLine;

                fileContents = fileContents.Replace("{NewLine}", nl);
                $"When I create the receiver csv for the content {fileContents}".w(() =>
                                                                                   receiver = new ReceiverCSVText(fileContents));
                $"And I read the data".w(async() => data = await receiver.TransformData(null));
                $"Then should be a data".w(() => data.Should().NotBeNull());
                $"With a table".w(() =>
                {
                    data.DataToBeSentFurther.Should().NotBeNull();
                    data.DataToBeSentFurther.Count.Should().Be(1);
                });
                $"The number of rows should be {NumberRows}".w(() =>
                                                               data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRows));
                $"And when I filter".w(async() =>
                                       data = await new FilterRemoveColumnDataGreaterThanLength("Car", 5).TransformData(data));
                $"Then should be a data".w(() => data.Should().NotBeNull());
                $"With a table".w(() =>
                {
                    data.DataToBeSentFurther.Should().NotBeNull();
                    data.DataToBeSentFurther.Count.Should().Be(1);
                });
                $"The number of rows should be {NumberRowsAfterFilter}".w(() =>
                                                                          data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRowsAfterFilter));
            }
예제 #16
0
 /// <summary>
 /// Get an IAsyncEnumerable for receiving messages.
 /// </summary>
 public static async IAsyncEnumerable <Message> Messages(this IReceive receiver, [EnumeratorCancellation] CancellationToken cancellationToken = default)
 {
     while (!cancellationToken.IsCancellationRequested)
     {
         yield return(await receiver.Receive(cancellationToken).ConfigureAwait(false));
     }
 }
예제 #17
0
        //[Example("https://trello.com/b/SQYjpHEf.json",3)]
        public void TestTrelloJson(string fileName, int numberTables, int nrLists, int nrCards, int nrComments)
        {
            IReceive receiver = null;

            IDataToSent data = null;
            var         nl   = Environment.NewLine;

            $"Given the file {fileName}".w(() =>
            {
                //File.Exists(fileName).Should().BeTrue();
            });
            $"When I create the receiver trello for the {fileName}".w(() => receiver = new ReceiverFromTrello(fileName));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With a {numberTables}:   tables: list, card , tables".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(numberTables);
            });
            $"With {nrLists} lists".w(() =>
            {
                var list = data.FindAfterName("list");
                list.Value.Rows.Count.Should().Be(nrLists);
            });
            $"With {nrCards} cards".w(() =>
            {
                var list = data.FindAfterName("card");
                list.Value.Rows.Count.Should().Be(nrCards);
            });
            $"with {nrComments} comments".w(() =>
            {
                var list = data.FindAfterName("comment");
                list.Value.Rows.Count.Should().Be(nrComments);
            });
        }
예제 #18
0
        public void TestSimpleJSON(string fileName, int NumberRows)
        {
            IReceive receiver = null;

            IDataToSent data = null;
            var         nl   = Environment.NewLine;

            $"Given the file {fileName}".w(() =>
            {
                File.Exists(fileName).Should().BeTrue();
            });
            $"When I create the ReceiveRest for the {fileName}".w(() => receiver = new ReceiveRestFromFile(fileName));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With a table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
            });
            $"The number of rows should be {NumberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRows));
            $"and now I export to typescript definition ".w(async() =>
                                                            data = await new SenderToTypeScript().TransformData(data));

            $"should have 1 record in ExportOutput".w(() =>
                                                      data.FindAfterName("OutputString").Value.Rows.Count.Should().Be(1));
        }
예제 #19
0
        public void TestSimpleCSVRender(string fileContents, int numberRows)
        {
            string newFolder = Guid.NewGuid().ToString("N");
            var    dir       = Path.Combine(Environment.CurrentDirectory, newFolder);

            Directory.CreateDirectory(dir);
            IReceive    receiver = null;
            IDataToSent data     = null;
            var         nl       = Environment.NewLine;

            fileContents = fileContents.Replace("{NewLine}", nl);
            $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With a table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
            });
            $"The number of rows should be {numberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(numberRows));
            $"and now use SenderRazorTableOneByOne ".w(async() =>
            {
                data = await  new SenderRazorTableOneByOne("aaa", dir).TransformData(data);
            });
            $"and the new folder {dir} should have 1 file".w(() => { Directory.GetFiles(dir).Length.Should().Be(1); });
        }
예제 #20
0
        public void SenderToHTML(string connectionString)
        {
            IReceive        status = null;
            ISenderToOutput sender = null;
            IDataToSent     data   = null;

            $"Assume Sql Server instance {connectionString} exists , if not see docker folder".w(() => {
            });
            $"When I create the ReceiverDBServer ".w(() => status = new ReceiveMetadataFromDatabaseSql(connectionString));
            $"and receive data".w(async() =>
            {
                data = await status.TransformData(null);
            });
            $"the data should have a tables, columns, relations,keys,properties".w(() =>
            {
                data.DataToBeSentFurther.Count.Should().Be(5);
            });

            $"and now export to SenderToDot".w(async() => {
                sender = new SenderDBDiagramHTMLDocument("");
                data   = await sender.TransformData(data);
            });
            $"should be some content".w(() =>
            {
                sender.OutputString.Should().NotBeNull();
                sender.OutputString.Rows.Count.Should().Be(1);
                //File.WriteAllText(@"C:\Users\Surface1\Desktop\viz.html", sender.OutputContents.First().Value);
                //Process.Start("notepad.exe","a.txt");
            });
        }
        public void TestSimpleCSVWithConst(string fileContents, int NumberRows, string newVal)
        {
            IReceive    receiver = null;
            IDataToSent data     = null;
            var         nl       = Environment.NewLine;

            fileContents = fileContents.Replace("{NewLine}", nl);
            $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With a table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
            });
            $"The number of rows should be {NumberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRows));

            $"and now I send to razor {nameof(SenderToRazorWithContents)}".w(async() =>
            {
                data = await new SenderToRazorWithContents("asdasdasd").TransformData(data);
            });
            $"and I can transform the value of the output ".w(async() =>
            {
                data = await new TransformerOutputStringColumnName(newVal).TransformData(data);
            });
            $"should be the value equal to {newVal}".w(() =>
            {
                data.FindAfterName("OutputString").Value.Rows[0]["Name"].ToString().Should().Be(newVal.Replace("'", ""));
            });
        }
예제 #22
0
        public void TestSimpleJSON(string fileName, int NumberRows)
        {
            string urlCachet = Environment.GetEnvironmentVariable("cachet");

            if (string.IsNullOrWhiteSpace(urlCachet))
            {
                urlCachet = "localhost";
            }
            urlCachet = "http://" + urlCachet + ":8000";

            IReceive receiver = null;

            IDataToSent data = null;
            var         nl   = Environment.NewLine;

            $"Given the file {fileName}".w(() =>
            {
                File.Exists(fileName).Should().BeTrue();
            });
            $"When I create the {nameof(ReceiveRest)} for the {fileName}".w(() => receiver = new ReceiveRestFromFile(fileName));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With a table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(1);
            });
            $"The number of rows should be {NumberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRows));
            $"and now I transform with {nameof(SenderCachet)}".w(async() =>
                                                                 data = await new SenderCachet(urlCachet, "5DiHQgKbsJqck4TWhMVO").TransformData(data)
                                                                 );
        }
예제 #23
0
        public void TestSimpleCSV(string fileContents1, string fileContents2, int nrTablesBefore, int nrTablesAfter, int nrRowsAfter)
        {
            IReceive    receiver = null;
            IDataToSent data     = null;
            var         nl       = Environment.NewLine;

            fileContents1 = fileContents1.Replace("{NewLine}", nl);
            fileContents2 = fileContents2.Replace("{NewLine}", nl);
            $"When I create the receiver csv for the content {fileContents1}".w(() => receiver = new ReceiverCSVText(fileContents1));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"And I read the data from other receiver".w(async() => data = await new ReceiverCSVText(fileContents2).TransformData(data));

            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With {nrTablesBefore} tables".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(nrTablesBefore);
            });
            $"and I transform to one table".w(async() => data = await new TransformerToOneTable().TransformData(data));

            $"Should be {nrTablesAfter} tables".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().Be(nrTablesAfter);
            });

            $"with {nrRowsAfter} rows".w(() =>
            {
                data.DataToBeSentFurther[0].Rows.Count.Should().Be(nrRowsAfter);
            });
        }
예제 #24
0
 public void AddObserver <T>(IReceive <T> handler) where T : IEntityMessage
 {
     if (_messageReceivers.Contains(handler))
     {
         return;
     }
     _messageReceivers.Add(handler);
     _messageReceivers.Sort(_msgSorter);
 }
예제 #25
0
 public void Register(string eventName, IReceive <AnimationEventTriggered> receiver)
 {
     if (!_eventReceivers.TryGetValue(eventName, out var list))
     {
         list = new List <IReceive <AnimationEventTriggered> >();
         _eventReceivers.Add(eventName, list);
     }
     list.Add(receiver);
 }
예제 #26
0
        void Remove(IReceive receive, Type type)
        {
            List <IReceive> cachedSignals;

            if (signals.TryGetValue(type.GetHashCode(), out cachedSignals))
            {
                cachedSignals.Remove(receive);
            }
        }
        public TransformerApplyReceiver(IReceive receiver, string propertyNameReceiver, string key)
        {
            Receiver             = receiver;
            PropertyNameReceiver = propertyNameReceiver;
            Key = key;
            string type = (receiver == null) ? "" : receiver.GetType().Name;

            this.Name = $"apply {key} => {type}.{propertyNameReceiver}";
        }
예제 #28
0
 public void AddObserver(IReceive handler)
 {
     if (MessageReceivers.CurrentList.Contains(handler))
     {
         return;
     }
     MessageReceivers.CurrentList.Add(handler);
     MessageReceivers.CurrentList.Sort(_msgSorter);
 }
예제 #29
0
 public void AddObserver(IReceive handler)
 {
     if (_messageReceivers.Contains(handler))
     {
         return;
     }
     _messageReceivers.Add(handler);
     _messageReceivers.Sort(_msgSorter);
 }
예제 #30
0
 void Resend(IReceive <int> numbers, ISend <string> results, string name)
 {
     foreach (var n in numbers.Range())
     {
         Task.Delay(5).Wait();
         results.Send($"{name} : {n}");
     }
     results.Close();
     Console.WriteLine($" [+] {name} done");
 }