Example #1
0
        public void RegisterMessageSerializationTest()
        {
            var problemList = new List <string>()
            {
                "DVRP"
            };
            var registerMessage = new RegisterMessage(EComponentType.TaskManager, 1, problemList);

            var result = registerMessage.SerializeToXml();

            Assert.IsNotNull(result);
            Assert.AreNotEqual(0, result.Length);

            var xmlValidator     = new XmlValidator();
            var xsdSchemaFile    = "RegisterMessage.xsd";
            var xsdSchemaPath    = Path.Combine(_xsdSchemasPath, xsdSchemaFile);
            var validationResult = xmlValidator.Validate(result, xsdSchemaPath, true);
            var errorsCount      = validationResult.Errors.Count + validationResult.Warnings.Count;

            Assert.AreEqual(0, errorsCount);

            #region ExampleResult

            //<?xml version="1.0" encoding="utf-16"?>
            //<Register xmlns="http://www.mini.pw.edu.pl/ucc/">
            //  <Type>TaskManager</Type>
            //  <SolvableProblems>
            //    <ProblemName>DVRP</ProblemName>
            //  </SolvableProblems>
            //  <ParallelThreads>1</ParallelThreads>
            //</Register>

            #endregion
        }
Example #2
0
        public void RegisterMessageDeserializationTest()
        {
            var problemList = new List <string>()
            {
                "DVRP"
            };
            var registerMessage = new RegisterMessage(EComponentType.TaskManager, 1, problemList);

            var result = Message.Deserialize <RegisterMessage>(registerMessage.SerializeToXml());

            Assert.AreEqual("DVRP", result.SolvableProblems[0]);
        }