public void ProjectWithStoryIsSerializable()
        {
            string expected =
                string.Format(
                    @"<?xml version=""1.0"" encoding=""utf-16""?>
                                <Project xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
                                  <Abbreviation>FT</Abbreviation>
                                  <Name>Fairy Tales</Name>
                                  <Stories>
                                    {0}
                                  </Stories>
                                </Project>",
                    firstStory);

            var project = new Project("Fairy Tales", "FT");

            project.AddStory("Serializable Project And Story");
            project.Stories[0].Importance = 11;

            var serializer = new XmlSerializer(typeof(Project));
            var writer     = new StringWriter();

            serializer.Serialize(writer, project);
            XmlAssert.AreEqual(expected, writer.GetStringBuilder().ToString());
        }
示例#2
0
        public void EncodeAndDecode()
        {
            const string expectedBytes =
                "03-01-6A-12-61-62-63-00-20-45-6E-74-65-72-20-6E-61-6D-65-3A-20-00-47-C5-09-83-00-05-01-88-06-86-08-03-78-79-7A-00-85-03-2F-73-00-01-83-04-86-07-0A-03-4E-00-01-01-01";
            var document = new WbxmlDocument();

            document.LoadXml(xml);
            document.VersionNumber      = 1.3;
            document.TagCodeSpace       = new CodeSpace();
            document.AttributeCodeSpace = new AttributeCodeSpace();
            document.StringTable        = new StringTable(new[] { "abc", " Enter name: " });
            document.Encoding           = Encoding.UTF8;

            var bytes = document.GetBytes();

            //Console.WriteLine(bytes.ToHexString());
            Assert.AreEqual(expectedBytes, bytes.ToHexString());

            var decodedDocument = new WbxmlDocument
            {
                TagCodeSpace       = new CodeSpace(),
                AttributeCodeSpace = new AttributeCodeSpace()
            };

            decodedDocument.LoadBytes(bytes);
            XmlAssert.AreEqual(document, decodedDocument);
        }
示例#3
0
        public void EncodeAndDecode()
        {
            var document = new WbxmlDocument
            {
                VersionNumber      = 1.3,
                TagCodeSpace       = new CodeSpace(),
                AttributeCodeSpace = new AttrCodeSpace(),
                StringTable        = new StringTable(new[] { "NAP1" })
            };

            document.LoadXml(xml);

            var bytes = document.GetBytes();

            //Console.WriteLine(bytes.ToHexString());
            Assert.AreEqual(ExpectedBytes, bytes.ToHexString());

            var decodedDocument = new WbxmlDocument
            {
                TagCodeSpace       = new CodeSpace(),
                AttributeCodeSpace = new AttrCodeSpace()
            };

            decodedDocument.LoadBytes(bytes);

            XmlAssert.AreEqual(document, decodedDocument);
        }
        public void AttributesInDifferentOrderShouldBeOk()
        {
            string xmlSingleElementWithAttributes1 = @"<root attr1='attr1' attr2='attr2' attr3='attr3'/>";
            string xmlSingleElementWithAttributes2 = @"<root attr1='attr1' attr3='attr3' attr2='attr2'/>";

            XmlAssert.AreEqual(xmlSingleElementWithAttributes1, xmlSingleElementWithAttributes2);
        }
        public void TableHeaderTextBoxRender2010_ShouldRenderTextBoxRdlFragment()
        {
            var ServiceLocatorMock = new Mock <ISimpleServiceLocator>();

            SimpleServiceLocator.SetServiceLocatorProvider(ServiceLocatorMock.Object);

            var reportingStyleLeftMock = new Mock <IReportingServicesStyle>();

            reportingStyleLeftMock.Setup(x => x.TextAlign).Returns("");

            ServiceLocatorMock.Setup(x => x.Get <IReportingServicesStyle>
                                         ("ReportingServicesStyle", It.IsAny <Dictionary <string, object> >())).Returns(reportingStyleLeftMock.Object);

            string             name    = "Field1";
            string             caption = "Caption1";
            TableHeaderTextBox target  = new TableHeaderTextBox(name, caption);
            //Create stringbuilder for the xmlwriter
            StringBuilder sb = new StringBuilder();

            using (XmlWriter xmlWriter = XmlWriter.Create(sb))
            {
                //method under test
                target.Render2010(xmlWriter);

                //flush the output and grab the xml chunk
                xmlWriter.Flush();
                string outputRdl = sb.ToString();

                //compare output with expected xml
                XmlAssert.AreEqual(outputRdl, "<TablixCell><CellContents><Textbox Name=\"HeaderField1\"><Paragraphs><Paragraph><TextRuns><TextRun><Value>Caption1</Value></TextRun></TextRuns></Paragraph></Paragraphs><CanGrow>true</CanGrow><Top>0in</Top><Left>0in</Left><Width>.5in</Width></Textbox></CellContents></TablixCell>");
            }
        }
        public void CheckCompatibilityWithDefaultSerializator(object obj)
        {
            var standardXml = SerializeObject(obj);
            var obj2        = Serializer.Deserialize(standardXml, obj.GetType());

            XmlAssert.AreEqual(standardXml, SerializeObject(obj2));
        }
        public void CheckSerializationAndDeserializationByXml(string xml, object obj)
        {
            xml = ReplaceVariable(xml);
            XmlAssert.AreEqual(xml, Serializer.Serialize(obj));
            var obj2 = Serializer.Deserialize(xml, obj.GetType());

            XmlAssert.AreEqual(xml, Serializer.Serialize(obj2));
        }
示例#8
0
        public void UpdateProduct2Test()
        {
            var        result    = UpdateProduct(_tf.Input("Pathway2.wxs"), "1.13.4.4658", "SE");
            const bool overwrite = true;

            File.Copy(result, _tf.Output("Pathway2.wxs"), overwrite);
            File.Delete(result);
            XmlAssert.AreEqual(_tf.Expected("Pathway2.wxs"), _tf.Output("Pathway2.wxs"), "Pathway Product File mismatch on change");
        }
        public void CheckSerializationAndDeserialization(string xmlPath, object obj)
        {
            var xml = EmbeddedResources.Get(xmlPath);

            xml = ReplaceVariable(xml);
            XmlAssert.AreEqual(xml, Serializer.Serialize(obj));
            var obj2 = Serializer.Deserialize(xml, obj.GetType());

            XmlAssert.AreEqual(xml, Serializer.Serialize(obj2));
        }
 private void AssertAndVerifyXmlAssertMessage(string expected, string actual, string expectedMessageFromXmlAssert)
 {
     try
     {
         XmlAssert.AreEqual(expected, actual);
     }
     catch (Exception e)
     {
         Assert.That(e.Message, Is.EqualTo(expectedMessageFromXmlAssert));
     }
 }
示例#11
0
        public void NKOu3Book()
        {
            SfmToUsx     _sfmToUsx = new SfmToUsx();
            const string file      = "MATNKOu3";

            string input    = Common.PathCombine(_inputPath, file + ".sfm");
            string output   = Common.PathCombine(_outputPath, file + ".usx");
            string expected = Common.PathCombine(_expectedPath, file + ".usx");

            _sfmToUsx.ConvertSFMtoUsx(input, output);

            XmlAssert.AreEqual(expected, output, file + " test fails");
        }
示例#12
0
        public void NewGuidewordStyleTest()
        {
            _projInfo.ProjectInputType = "Dictionary";
            const string file      = "NewGuidewordStyle";
            DateTime     startTime = DateTime.Now;

            string styleOutput     = GetStyleOutput(file);
            string contentExpected = Common.PathCombine(_expectedPath, file + "content.xml");

            XmlAssert.Ignore(styleOutput, "//office:font-face-decls", new Dictionary <string, string> {
                { "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" }
            });
            XmlAssert.AreEqual(contentExpected, _projInfo.TempOutputFolder, file + " in content.xml");
        }
        public void ProjectIsSerializeable()
        {
            const string expected   = @"<?xml version=""1.0"" encoding=""utf-16""?>
                                <Project xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
                                  <Abbreviation>FT</Abbreviation>
                                  <Name>Fairy Tales</Name>
                                  <Stories />
                                </Project>";
            var          project    = new Project("Fairy Tales", "FT");
            var          serializer = new XmlSerializer(typeof(Project));
            var          writer     = new StringWriter();

            serializer.Serialize(writer, project);
            XmlAssert.AreEqual(expected, writer.GetStringBuilder().ToString());
        }
示例#14
0
        public void RunningHeaderNoneTest()
        {
            _projInfo.ProjectInputType = "Scripture";
            const string file      = "RunningHeaderNone";
            DateTime     startTime = DateTime.Now;

            Common.UseAfterBeforeProcess = false;
            string styleOutput = GetStyleOutput(file);

            string styleExpected   = Common.PathCombine(_expectedPath, file + "styles.xml");
            string contentExpected = Common.PathCombine(_expectedPath, file + "content.xml");

            XmlAssert.Ignore(styleOutput, "//office:font-face-decls", new Dictionary <string, string> {
                { "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" }
            });
            XmlAssert.AreEqual(styleExpected, styleOutput, file + " in styles.xml");
            XmlAssert.AreEqual(contentExpected, _projInfo.TempOutputFolder, file + " in content.xml");
        }
示例#15
0
        public void EveryPageBottomCenterExport()
        {
            Common.UseAfterBeforeProcess = false;
            _projInfo.ProjectInputType   = "Scripture";
            const string file      = "everypagebottomcenter";
            DateTime     startTime = DateTime.Now;

            string styleOutput = GetStyleOutput(file);

            _totalTime = DateTime.Now - startTime;

            string styleExpected   = Common.PathCombine(_expectedPath, file + "styles.xml");
            string contentExpected = Common.PathCombine(_expectedPath, file + "content.xml");

            XmlAssert.AreEqual(styleExpected, styleOutput, file + " in styles.xml");
            XmlAssert.AreEqual(contentExpected, _projInfo.TempOutputFolder, file + " in content.xml");
            Common.UseAfterBeforeProcess = true;
        }
        public void WhitespaceShouldNotMatter()
        {
            XmlAssert.AreEqual("<xml></xml>", "<xml />");
            XmlAssert.AreEqual("<xml></xml>", "<xml></xml>");
            XmlAssert.AreEqual("<xml></xml>", "<xml></xml> ");
            XmlAssert.AreEqual("<xml></xml>", " <xml></xml> ");
            XmlAssert.AreEqual("<xml></xml>", " <xml> </xml> ");
            XmlAssert.AreEqual("<xml></xml>", " <xml > </xml> ");
            XmlAssert.AreEqual("<xml></xml>", " <xml > </xml > ");
            XmlAssert.AreEqual("<xml></xml>", " <xml >  </xml > ");
            XmlAssert.AreEqual("<xml><tag/></xml>", " <xml > <tag /> </xml > ");
            XmlAssert.AreEqual("<xml><tag attribute='attribute'/></xml>",
                               " <xml > <tag attribute ='attribute' /> </xml > ");
            XmlAssert.AreEqual("<xml><tag attribute='attribute'/></xml>",
                               " <xml > <tag attribute = 'attribute' /> </xml > ");
            XmlAssert.AreEqual("<xml><tag attribute='attribute'/></xml>",
                               @" <xml > 
<tag attribute = 'attribute' /> 
</xml > ");
        }
示例#17
0
        public void CpDocumentCreate()
        {
            var document = new CpDocument
            {
                StringTable = new StringTable(new[] { "NAP1" })
            };

            document.LoadXml(xml);

            var bytes = document.GetBytes();

            //Console.WriteLine(bytes.ToHexString());
            Assert.AreEqual(ExpectedBytes, bytes.ToHexString());

            var decodedDocument = new CpDocument();

            decodedDocument.LoadBytes(bytes);

            XmlAssert.AreEqual(document, decodedDocument);
        }
        public void StoryIsSerializable()
        {
            var story = new Story("Serialize Story", "FT-1", new DateTime(2008, 4, 19))
            {
                Importance = 42,
                Estimate   = 3,
                HowToDemo  = "Story ends up in project xml file"
            };

            story.Start(new DateTime(2008, 1, 23));
            story.Pause(new DateTime(2008, 1, 25));
            story.Reset(new DateTime(2008, 4, 19));
            story.Start(new DateTime(2008, 4, 19));
            story.MarkAsDone(new DateTime(2008, 4, 24));

            var serializer = new XmlSerializer(typeof(Story));
            var writer     = new StringWriter();

            serializer.Serialize(writer, story);
            XmlAssert.AreEqual(expectedStory, writer.GetStringBuilder().ToString());
        }
        public void AsserterShouldBeAbleToDistinguishTagNames()
        {
            string input =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
                                <Story xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
                                  <Abbreviation>FT-1</Abbreviation>
                                </Story>";
            string testAgainst =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
                                <Story xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
                                  <Abbriviation>FT-1</Abbriviation>
                                </Story>";

            try
            {
                XmlAssert.AreEqual(input, testAgainst);
                throw new Exception("XmlAssert.AreEqual should have thrown.");
            }
            catch (AssertionException)
            {
            }
        }
示例#20
0
        public void ProcessTreeTest()
        {
            if (Common.IsUnixOS())
            {
                return;
            }
            ResetIds();
            var inputGuids = _tf.Input("FileLibrary.xml");

            LoadGuids(inputGuids);
            ApplicationFileName = "Application.wxs";
            DirectoryInfo directoryInfo = new DirectoryInfo(_tf.Input(@"output\Release"));

            foreach (DirectoryInfo directory in directoryInfo.GetDirectories())
            {
                ResetFileComponents();
                ProcessTree((XmlElement)XDoc.SelectSingleNode("//*[@Id='APPLICATIONFOLDER']"), directory.FullName);
                AddFeatures();
            }

            // Check File & Features Match
            var actualPath = _tf.Output("Application.wxs");
            var writer     = XmlTextWriter.Create(actualPath, new XmlWriterSettings {
                Indent = true, Encoding = Encoding.UTF8
            });

            XDoc.WriteTo(writer);
            writer.Close();
            XmlAssert.AreEqual(_tf.Expected("Application.wxs"), actualPath, "File Feature format changed");

            // Check no Guids created
            var actualGuids = _tf.Output("FileLibrary.xml");

            SaveGuids(actualGuids);
            XmlAssert.AreEqual(inputGuids, actualGuids, "Guids changed");
        }
        public void OutputTablixRowElement()
        {
            //Mock repository
            var mockRepository = new Moq.Mock <IDataTableRepository>();

            //construct the tableheader object
            TableHeader target = new TableHeader(new List <DataItem>(), mockRepository.Object, new DataModel());

            //Create stringbuilder for the xmlwriter
            StringBuilder sb = new StringBuilder();

            using (XmlWriter xmlWriter = XmlWriter.Create(sb))
            {
                //method under test
                target.Render2010(xmlWriter);

                //flush the output and grab the xml chunk
                xmlWriter.Flush();
                string outputRdl = sb.ToString();

                //compare output with expected xml
                XmlAssert.AreEqual(outputRdl, "<TablixRow><Height>.25in</Height><TablixCells /></TablixRow>");
            }
        }
 public void BigXmlDocumentIsSameAsSelfWithLotsOfWhitespaceRemoved()
 {
     XmlAssert.AreEqual(bigXml, bigXmlWithLessWhitespace);
 }
 public void BigXmlDocumentIsSameWithSelf()
 {
     XmlAssert.AreEqual(bigXml, bigXml);
 }