private static BrokerHost <Topic> InitializeHost() { var ipAddress = ConfigurationManager.AppSettings["ipAddress"]; var port = ConfigurationManager.AppSettings["port"]; var endpoint = ConfigurationManager.AppSettings["endpoint"]; var state = (State)Enum.Parse(typeof(State), ConfigurationManager.AppSettings["state"]); var brokerHost = new BrokerHost <Topic>(); var broker = new Broker <Topic>(state); broker.InitializeReplicationClientProxy(); broker.AddTopic(Topic.FirstT); broker.AddTopic(Topic.SecondT); broker.AddTopic(Topic.ThirdT); if (state == State.StandBy) { broker.RequestIntegiryUpdate(); } brokerHost.Initialize(ipAddress, port, endpoint, broker); return(brokerHost); }
public void AddTopicWhenTopicIsAlreadyAdded() { var broker = new Broker <Topic>(State.StandBy); var result = broker.AddTopic(Topic.FirstT); Assert.IsTrue(result); result = broker.AddTopic(Topic.FirstT); Assert.IsTrue(result); }
public void RequestStreamWithBadCount() { var broker = new Broker <Topic>(State.StandBy); broker.AddTopic(Topic.FirstT); int count = 10; var stream = new List <Message <Topic> >(count); var testDataString = "TEST"; for (int i = 0; i < count; i++) { var message = new Message <Topic>() { Topic = Topic.FirstT, Data = testDataString.ToByteArray() }; var response = broker.PublishSync(message); Assert.AreEqual(response, NotifyStatus.Secceeded); } var topicCount = broker.TopicCount(Topic.FirstT); Assert.AreEqual(count, topicCount); var retVal = broker.MultipleRequest(new MultipleRequest <Topic>() { Topic = Topic.FirstT, Offset = 0, Count = 17 }); Assert.AreEqual(retVal.Count, count); }
public void DeleteTopic() { var broker = new Broker <Topic>(State.StandBy); var result = broker.AddTopic(Topic.FirstT); Assert.IsTrue(result); result = broker.DeleteTopic(Topic.FirstT); Assert.IsTrue(result); }
public void TopicCountTest() { var broker = new Broker <Topic>(State.StandBy); broker.AddTopic(Topic.FirstT); var testDataString = "TEST"; var response = broker.PublishSync(new Message <Topic>() { Topic = Topic.FirstT, Data = testDataString.ToByteArray() }); Assert.AreEqual(response, NotifyStatus.Secceeded); Assert.AreEqual(1, broker.TopicCount(Topic.FirstT)); Assert.AreEqual(-1, broker.TopicCount(Topic.SecondT)); }
public void RequestMessageWithInvalidOffset() { var broker = new Broker <Topic>(State.StandBy); broker.AddTopic(Topic.FirstT); var testDataString = "TEST"; var response = broker.PublishSync(new Message <Topic>() { Topic = Topic.FirstT, Data = testDataString.ToByteArray() }); Assert.AreEqual(response, NotifyStatus.Secceeded); var message = broker.SingleRequest(new SingleRequest <Topic>() { Topic = Topic.FirstT, Offset = 4 }); Assert.IsNull(message); }
public void RequestMessageWithValidParametars() { var broker = new Broker <Topic>(State.StandBy); broker.AddTopic(Topic.FirstT); var testDataString = "TEST"; var response = broker.PublishSync(new Message <Topic>() { Topic = Topic.FirstT, Data = testDataString.ToByteArray() }); Assert.AreEqual(response, NotifyStatus.Secceeded); var message = broker.SingleRequest(new SingleRequest <Topic>() { Topic = Topic.FirstT, Offset = 0 }); Assert.AreEqual(message.Data.ToObject <string>(), testDataString); Assert.AreEqual(message.Topic, Topic.FirstT); }