private S3Root GetS3Survey()
        {
            var s3 = new S3Root()
            {
                Origin = "Triple-S.Net",
                Date   = DateTime.Now.ToShortDateString(),
                Time   = DateTime.Now.ToShortTimeString(),
            };

            var s3Style = new S3Style {
                Href  = "http:\\www.example.com",
                Value = "text-align:center"
            };

            s3.Style    = new S3Style[1];
            s3.Style[0] = s3Style;

            var survey = s3.Survey;

            survey.Name    = "Triple-S Tests";
            survey.Version = "1";

            var record = survey.Record;

            record.ID = "A";

            var variable = record.AddVariable("1", "Q1", S3Type.Single);

            variable.AddValue("1", "Red");
            variable.AddValue("2", "blue");
            variable.AddValue("3", "Green");
            return(s3);
        }
        public void TestCreateSurvey()
        {
            S3Root s3 = GetS3Survey();

            // Check some random properties.
            Assert.AreEqual("1", s3.Survey.Version);
            Assert.AreEqual("A", s3.Survey.Record.ID);
        }
        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);
        }
        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);
        }
        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);
        }
        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
            }
        }