Example #1
0
        public void TestSerializeSurveyFile()
        {
            S3Root s3       = GetS3Survey();
            string filename = "example1.xml";

            S3Serializer.ToFile(filename, s3);
            var s3Import = S3Serializer.FromFile(filename);

            Assert.AreEqual("A", s3Import.Survey.Record.ID);
        }
Example #2
0
        public void TestSerializeSurveyString()
        {
            S3Root s3 = GetS3Survey();

            string xml = S3Serializer.ToString(s3);

            Assert.IsTrue(xml.Length > 0);

            // Write out XML for review
            File.WriteAllText(@"S3Test.xml", xml);
        }
Example #3
0
        public void TestRoundtripSurvey()
        {
            S3Root s3  = GetS3Survey();
            string xml = S3Serializer.ToString(s3);

            // Get a copy of the survey from the serialized string and check some random properties.
            var s3Import = S3Serializer.FromString(xml);

            Assert.AreEqual("A", s3Import.Survey.Record.ID);

            // Does the xml rountrip to the same xml?
            var xmlCopy = S3Serializer.ToString(s3Import);

            Assert.AreEqual(xml, xmlCopy);
        }
Example #4
0
        public void Initialize()
        {
            var assembly = Assembly.GetExecutingAssembly();
            var resource = assembly.GetManifestResourceStream("TripleS.Tests.v20.example1.sss");

            example1 = S3Serializer.FromStream(resource);

            resource = assembly.GetManifestResourceStream("TripleS.Tests.v20.example2.sss");
            example2 = S3Serializer.FromStream(resource);

            foreach (var s3Var in example2.Survey.Record.Variables)
            {
                // Do something
            }
        }
Example #5
0
        private void OnExecute()
        {
            var subject = TripleSFilename;

            if (string.IsNullOrEmpty(TripleSFilename))
            {
                Console.WriteLine($"Must specify a valid Triple-S file");
                Console.ReadLine();
                return;
            }


            try {
                var data = S3Serializer.FromFile(TripleSFilename);
                Console.WriteLine(data.Survey.Name);
                Console.WriteLine(data.Survey.Version);
                Console.WriteLine(data.Survey.Title.GetText());

                var record = data.Survey.Record;
                foreach (var s3var in record.Variables)
                {
                    var error = S3Validator.ValidateVariable(s3var);

                    if (!string.IsNullOrEmpty(error))
                    {
                        Console.WriteLine(s3var.Name + " " + s3var.Label.GetText());

                        Console.ForegroundColor = ConsoleColor.Red;

                        Console.WriteLine(error);

                        Console.ResetColor();
                    }
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }

            //Console.ReadLine();
        }
Example #6
0
        public void TestSerialization()
        {
            string xml = S3Serializer.ToString(example1);

            Assert.IsTrue(xml.Length > 0);
        }