コード例 #1
0
        public void TestSetExpressionParameters()
        {
            // TODO: OpenDDS Issue: The correct number of expression parameters are not checked

            // Initialize
            AthleteResultTypeSupport athleteResultSupport = new AthleteResultTypeSupport();
            string     athleteResultTypeName = athleteResultSupport.GetTypeName();
            ReturnCode result = athleteResultSupport.RegisterType(_participant, athleteResultTypeName);

            Assert.AreEqual(ReturnCode.Ok, result);

            // Create a multitopic with two expresion parameters
            string     query      = "SELECT * FROM AthleteTopic NATURAL JOIN ResultTopic WHERE Id >= %0 AND Id <= %1";
            string     topicName  = "AthleteResultTopic";
            string     parameter1 = "0";
            string     parameter2 = "10";
            MultiTopic multiTopic = _participant.CreateMultiTopic(topicName, athleteResultTypeName, query, parameter1, parameter2);

            Assert.IsNotNull(multiTopic);

            List <string> parameters = new List <string>();

            result = multiTopic.GetExpressionParameters(parameters);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.IsNotNull(parameters);
            Assert.AreEqual(2, parameters.Count);
            Assert.AreEqual(parameter1, parameters[0]);
            Assert.AreEqual(parameter2, parameters[1]);

            // Test with null list
            result = multiTopic.SetExpressionParameters(null);
            Assert.AreEqual(ReturnCode.BadParameter, result);

            // Change the expression parameters
            result = multiTopic.SetExpressionParameters(parameter2, parameter1);
            Assert.AreEqual(ReturnCode.Ok, result);

            result = multiTopic.GetExpressionParameters(parameters);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.IsNotNull(parameters);
            Assert.AreEqual(2, parameters.Count);
            Assert.AreEqual(parameter2, parameters[0]);
            Assert.AreEqual(parameter1, parameters[1]);

            // Change to no expression parameters
            result = multiTopic.SetExpressionParameters();
            Assert.AreEqual(ReturnCode.Ok, result);

            result = multiTopic.GetExpressionParameters(parameters);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.IsNotNull(parameters);
            Assert.AreEqual(0, parameters.Count);
        }
コード例 #2
0
        public void TestGetExpressionParameters()
        {
            // Initialize
            AthleteResultTypeSupport athleteResultSupport = new AthleteResultTypeSupport();
            string     athleteResultTypeName = athleteResultSupport.GetTypeName();
            ReturnCode result = athleteResultSupport.RegisterType(_participant, athleteResultTypeName);

            Assert.AreEqual(ReturnCode.Ok, result);

            // Create a multitopic without expression parameters
            string     query      = "SELECT * FROM AthleteTopic NATURAL JOIN ResultTopic";
            string     topicName  = "AthleteResultTopic";
            MultiTopic multiTopic = _participant.CreateMultiTopic(topicName, athleteResultTypeName, query);

            Assert.IsNotNull(multiTopic);

            // Test null parameter
            result = multiTopic.GetExpressionParameters(null);
            Assert.AreEqual(ReturnCode.BadParameter, result);

            // Test empty expression parameters
            List <string> parameters = new List <string>();

            result = multiTopic.GetExpressionParameters(parameters);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.IsNotNull(parameters);
            Assert.AreEqual(0, parameters.Count);

            // Test with two expresion parameters
            query     = "SELECT * FROM AthleteTopic NATURAL JOIN ResultTopic WHERE Id >= %0 AND Id <= %1";
            topicName = "AthleteResultTopic1";
            string     parameter1  = "0";
            string     parameter2  = "10";
            MultiTopic multiTopic1 = _participant.CreateMultiTopic(topicName, athleteResultTypeName, query, parameter1, parameter2);

            Assert.IsNotNull(multiTopic1);

            result = multiTopic1.GetExpressionParameters(parameters);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.IsNotNull(parameters);
            Assert.AreEqual(2, parameters.Count);
            Assert.AreEqual(parameter1, parameters[0]);
            Assert.AreEqual(parameter2, parameters[1]);
        }
コード例 #3
0
        public void TestProperties()
        {
            // Initialize
            AthleteResultTypeSupport athleteResultSupport = new AthleteResultTypeSupport();
            string     athleteResultTypeName = athleteResultSupport.GetTypeName();
            ReturnCode result = athleteResultSupport.RegisterType(_participant, athleteResultTypeName);

            Assert.AreEqual(ReturnCode.Ok, result);

            // Create a multitopic and check the properties
            string     query      = "SELECT * FROM AthleteTopic NATURAL JOIN ResultTopic";
            string     topicName  = "AthleteResultTopic";
            MultiTopic multiTopic = _participant.CreateMultiTopic(topicName, athleteResultTypeName, query);

            Assert.IsNotNull(multiTopic);
            Assert.AreEqual(topicName, multiTopic.Name);
            Assert.AreEqual(athleteResultTypeName, multiTopic.TypeName);
            Assert.AreEqual(query, multiTopic.SubscriptionExpression);
            Assert.AreEqual(_participant, multiTopic.Participant);
        }