public void TestSendMessage() { // Arrange var TestQueueName = "foo"; var TestTransactionID = 100; var TestHeaders = new Dictionary <string, object> { { "bar", "baz" } }; var TestRequestMessage = new TransmissionMessageDTO() { Content = "Test message!" }; var TestTransaction = new TransactionDTO() { TransactionID = TestTransactionID, Headers = TestHeaders, RequestMessage = TestRequestMessage }; var TestContext = new LinkerSharpContext(); TestContext.DirectQueues.Add(TestQueueName, new Queue <TransactionDTO>()); TestContext.DirectQueues[TestQueueName].Enqueue(TestTransaction); var TestFactory = new EndpointFactory <IConsumer>(); var TestConsumer = TestFactory.GetFrom($"direct->{TestQueueName}", TestContext); // Execution var TestResults = TestConsumer.ReceiveMessages(); // Assertions Assert.AreEqual(1, TestResults.Count, "TestConsumer should have results!"); Assert.AreEqual(TestTransactionID, TestResults[0].TransactionID); Assert.AreEqual(TestHeaders["bar"], TestResults[0].Headers["bar"]); Assert.AreEqual(TestRequestMessage.Content, TestResults[0].RequestMessage.Content); Assert.IsTrue(TestResults[0].ResponseMessage == null); }
public void TestFullRouteEndpoints() { // Arrange var TestContext = new LinkerSharpContext(); var TestFilePath = AppDomain.CurrentDomain.BaseDirectory.Replace(@"bin\Debug", "TestFiles"); var TestDestiny = $"{TestFilePath}\\Destiny\\"; var TestConsumerFactory = new EndpointFactory <IConsumer>(); var TestProducerFactory = new EndpointFactory <IProducer>(); var TestFileConsumer = TestConsumerFactory.GetFrom($"file->{TestFilePath}\\Origin\\->autoclean=false", TestContext); var TestFileProducer = TestProducerFactory.GetFrom($"file->{TestDestiny}", TestContext); // Execute var TestTransactions = TestFileConsumer.ReceiveMessages(); var TestResults = new List <bool>(); foreach (var TestTransaction in TestTransactions) { var Date = DateTime.Now; TestFileProducer.Transaction = TestTransaction; TestFileProducer.Transaction.ResponseMessage.Content = TestTransaction.RequestMessage.Content; TestFileProducer.Transaction.ResponseMessage.Name = $"TestReal_{Date.Year}_{Date.Month}_{Date.Day}_{Date.Hour}_{Date.Minute}_{Date.Millisecond}.txt"; TestResults.Add(TestFileProducer.SendMessage()); } this.CleanFiles(TestDestiny); // Assertions Assert.AreEqual(TestTransactions.Count(), TestResults.Count(t => t), "There are unsent messages!"); }
public DIRECTConsumer(string Path, LinkerSharpContext Context) : base(Context) { this.Endpoint = Path; if (!base.Context.DirectQueues.ContainsKey(this.Endpoint)) { base.Context.DirectQueues[this.Endpoint] = new Queue <TransactionDTO>(); } }
public void Init() { this.TestFtpUrl = $"{AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug", "TestFiles")}\\Origin\\"; this.TestContext = new LinkerSharpContext(); this.TestConsumerFactory = new EndpointFactory <IConsumer>(); //this.TestFtpConsumer = this.TestConsumerFactory.GetFrom($"ftp->{this.TestFtpUrl}"); }
static void Main(string[] args) { // Context instantiation var Context = new LinkerSharpContext(); // Adding routes Context.AddRoute(new BaritizeRouteBuilder()); Context.AddRoute(new SenderRouteBuilder()); // Starting process Context.Run(); }
public FILEProducer(string Path, LinkerSharpContext Context) : base(Context) { this.Endpoint = Path; if (!this.Params.ContainsKey(Headers.AUTOCLEAN)) { this.Params[Headers.AUTOCLEAN] = "true"; } this.Transaction = new TransactionDTO() { ResponseMessage = new TransmissionMessageDTO() }; }
public DIRECTProducer(string Path, LinkerSharpContext Context) : base(Context) { this.Endpoint = Path; if (!base.Context.DirectQueues.ContainsKey(this.Endpoint)) { base.Context.DirectQueues[this.Endpoint] = new Queue <TransactionDTO>(); } this.Transaction = new TransactionDTO() { ResponseMessage = new TransmissionMessageDTO() }; }
public void Init() { this.TestFilePath = $"{AppDomain.CurrentDomain.BaseDirectory.Replace(@"bin\Debug", "TestFiles")}\\Destiny\\"; this.TestContext = new LinkerSharpContext(); var TestFactory = new EndpointFactory <IProducer>(); this.TestProducer = TestFactory.GetFrom($"file->{this.TestFilePath}", this.TestContext); this.TestMessage = new TransmissionMessageDTO() { Content = "this is a test file.", Name = "Testfile.txt", Destiny = this.TestFilePath }; }
public T GetFrom(string Endpoint, LinkerSharpContext Context) { var Protocol = Endpoint.Substring(0, Endpoint.IndexOf("->")).ToUpper(); var IFaceSuffix = typeof(T).Name.Replace("I", ""); var ClassName = $"{Protocol}{IFaceSuffix}"; if (this.AvailableEndpoints.ContainsKey(ClassName)) { return((T)Activator.CreateInstance(this.AvailableEndpoints[ClassName], new object[] { Endpoint, Context })); } else { throw new KeyNotFoundException($"Consumer with name {ClassName} was not found."); } }
public void Init() { this.TestFilePath = $"{AppDomain.CurrentDomain.BaseDirectory.Replace(@"bin\Debug", "TestFiles")}\\Destiny\\"; this.TestContext = new LinkerSharpContext(); var TestFactory = new EndpointFactory <IProducer>(); this.TestProducer = new FTPProducer($"ftp->{this.TestFilePath}", this.TestContext, new FTPConnectorMock(FTPConnectorMock.Behaviour.SUCCESS)); this.TestMessage = new TransmissionMessageDTO() { Content = "This is a test file.", Name = "Testfile.txt", Destiny = this.TestFilePath }; }
public void Init() { this.TestMessage = new TransmissionMessageDTO() { Name = TEST_MESSAGE_NAME, Content = TEST_MESSAGE_CONTENT }; this.TestTransaction = new TransactionDTO() { TransactionID = TEST_TRANSACT_ID, Transport = TransportTypeEnum.IN_OUT, RequestMessage = this.TestMessage, ResponseMessage = this.TestMessage }; this.TestContext = new LinkerSharpContext(); this.TestRoute = new RouteDefinition(new List <TransactionDTO>() { TestTransaction }, this.TestContext); }
public void TestSendMessage() { // Arrange var TestContext = new LinkerSharpContext(); var TestQueueName = "foo"; var TestMessage = new TransmissionMessageDTO() { Content = "this is a direct test message.", Name = "", Destiny = TestQueueName }; var TestTransaction = new TransactionDTO() { RequestMessage = TestMessage, ResponseMessage = TestMessage }; var TestFactory = new EndpointFactory <IProducer>(); var TestProducer = TestFactory.GetFrom($"direct->{TestQueueName}", TestContext); TestProducer.Transaction = TestTransaction; // Execution var Result = TestProducer.SendMessage(); // Assertions }
public FTPProducer(string Uri, LinkerSharpContext Context, IFTPOutConnector OutConnector) : base(Context) { this.Endpoint = Uri; this.Connector = OutConnector ?? new DefaultFTPConnector(); }
public RouteDefinition(List <TransactionDTO> Transactions, LinkerSharpContext Context) { this.Transactions = Transactions; this.Context = Context; }
public FTPConsumer(string Uri, LinkerSharpContext Context, IFTPInConnector Connector = null) : base(Context) { this.Endpoint = Uri; this.Connector = Connector ?? new DefaultFTPConnector(); }
public void Init() { this.TestContext = new LinkerSharpContext(); }
public FILEConsumer(string Path, LinkerSharpContext Context) : base(Context) { this.Endpoint = Path; }