public void TestAsyncReceive() { MessageGateway<MockMessage> gateway = new MessageGateway<MockMessage>(Destination); gateway.OnMessageReceived += ReceiveMessage; gateway.StopAsync(); gateway.StartAsync(); gateway.StartAsync(); gateway.StopAsync(); gateway.StopAsync(); //gateway.Send(new MockMessage("1 Custom Type Test")); //gateway.Send(new MockMessage("2 Custom Type Test")); //Console.WriteLine("moving on..."); //System.Threading.Thread.Sleep(3000); //gateway.StopAsync(); ////MockMessage response = gateway.Receive(5000); ////Console.WriteLine("caught: {0}.", response.Name); //gateway.Send(new MockMessage("3 Custom Type Test")); //gateway.Send(new MockMessage("4 Custom Type Test")); //Console.WriteLine("After sending two messages and async stoped..."); //gateway.StartAsync(); //Console.WriteLine("started async again..."); //gateway.Send(new MockMessage("Custom Type Test")); //Assert.IsNotNull(response); //Assert.IsNotEmpty(response.Name); //Console.WriteLine(response.Name); System.Threading.Thread.Sleep(10000); }
public Bank(INicknameValidator emptyNicknameValidator, IDuplicatedNicknameValidator duplicatedNicknameValidator, MessageGateway messageGateway) { _emptyNicknameValidator = emptyNicknameValidator; _duplicatedNicknameValidator = duplicatedNicknameValidator; _messageGateway = messageGateway; _customers = new List<Customer>(); _nicknames = new List<string>(); }
public void TestReceiveObject() { //IMessageReceiverGateway gateway = new MessageReceiverGateway(""); //object result = gateway.ReceiveObject(); MessageGateway<string> gateway = new MessageGateway<string>("boomerang"); gateway.Send("abel"); string response = gateway.Receive(10000); Assert.IsNotNull(response); Assert.IsNotEmpty(response); Console.WriteLine(response); }
/// <summary> /// /// </summary> /// /// <param name="runtime"></param> /// public override void Invoke(ExchangeRuntime runtime) { Stopwatch timer = new Stopwatch(); timer.Start(); MessageGatewayEvent @event = new MessageGatewayEvent(this.GetType().Name); string xml = ExchangeTracker.CreateSoapMessage(runtime); MessageGateway<string> gateway = new MessageGateway<string>(Destination); gateway.Send(xml); @event.Destination = Destination; @event.Content = xml; timer.Stop(); @event.ElapsedTime = timer.ElapsedMilliseconds; runtime.AddStrategyEvent(@event); runtime.Continue(); }
public void TestSendReceiveCustomType() { MessageGateway<MockMessage> gateway = new MessageGateway<MockMessage>(Destination); gateway.Send(new MockMessage("Custom Type Test")); MockMessage response = gateway.Receive(); Assert.IsNotNull(response); Assert.IsNotEmpty(response.Name); Console.WriteLine(response.Name); }
public void TestSendReceiveXmlDocument() { XmlDocument xml = new XmlDocument(); xml.LoadXml("<?xml version=\"1.0\"?><Message><Test>Xml Document Test</Test></Message>"); MessageGateway<XmlDocument> gateway = new MessageGateway<XmlDocument>(Destination); gateway.Send(xml); XmlDocument response = gateway.Receive(); Assert.IsNotNull(response); Assert.IsNotEmpty(response.OuterXml); Console.WriteLine(response.OuterXml); }
public void TestSendReceiveString() { MessageGateway<string> gateway = new MessageGateway<string>(Destination); gateway.Send("String Message Test"); string response = gateway.Receive(); Assert.IsNotNull(response); Assert.IsNotEmpty(response); Console.WriteLine(response); }
public void TestSendReceiveObject() { MessageGateway<object> gateway = new MessageGateway<object>(Destination); gateway.Send("Object Message Test"); object response = gateway.Receive(); Assert.IsNotNull(response); Console.WriteLine(response); }
public void StartMessenger() { try { logger.Info("Starting messenger"); // Connect to the default gateway Gateway gateway = database.Gateways.Find(GlobalConstants.DefaultGatewayID); if (gateway != null && !string.IsNullOrEmpty(gateway.GatewayConfig)) { MobileGatewayConfiguration config = EntityHelper.FromCommonRepresentation <MobileGatewayConfiguration>(gateway.GatewayConfig); // Set log level to debug config.LogLevel = Core.Log.LogLevel.Verbose; config.LogNameFormat = Core.Log.LogNameFormat.Name; //config.LogLocation = @"c:\temp"; MessageGateway <IMobileGateway, MobileGatewayConfiguration> messageGateway = MessageGateway <IMobileGateway, MobileGatewayConfiguration> .NewInstance(); messenger = messageGateway.Find(config); if (messenger == null) { string errorMsg = string.Format("Error connecting to gateway at port {0}. Check the log file", config.PortName); logger.ErrorFormat(errorMsg); throw new Exception(errorMsg); } messenger.Id = gateway.GatewayID; ConfigureMessenger(); logger.InfoFormat("Successfully started messenger. Model is {0}. Port is {1}", messenger.DeviceInformation.Model, config.PortName); } else { logger.Error("Unable to connect to gateway. Make sure you configure a gateway [" + GlobalConstants.DefaultGatewayID + "] in the Gateway database table"); } } catch (Exception ex) { logger.Error(ex.ToString(), ex); } }
public void SetUp() { _messageGatewayStub = new MessageGatewayStub(); var bank = new Bank(new EmptyNicknameValidator(), new DuplicatedNicknameValidator(), _messageGatewayStub); _customer = bank.AddCustomer("Andy", new DateTime(1981, 01, 01), "*****@*****.**"); }
List <int> GetSentboxMessagesIds(string currentUsername, MessageTypes messageTypes) { bool deleted = messageTypes.HasFlag(MessageTypes.Deleted); return(MessageGateway.SelectIds(currentUsername, currentUsername, deleted)); }