Exemple #1
0
        public void XmlSerializer()
        {
            var mockWebClient = new Mock <IHttpClient>();

            mockWebClient.Setup(x => x.DownloadString(It.IsAny <string>())).Returns(XmlData);

            var serializer = new ThirdPartySerializer(mockWebClient.Object);
            var result     = serializer.SerializeXmlData <RootObject>(XmlData);

            mockWebClient.Verify(x => x.DownloadString(XmlData), Times.Once);
            Assert.That(result, Is.Not.Null);
            Assert.That(result.version, Is.EqualTo(3.1));
            Assert.That(result.releaseDate, Is.EqualTo("2014-06-25T00:00:00.000Z"));
            Assert.That(result.demo, Is.True);
            Assert.That(result.person.id, Is.EqualTo(12345));
        }
        public void XmlSerializer()
        {
            var xmlData       = File.ReadAllText("TestData/Class.xml");
            var mockWebClient = new Mock <IWebClient>();

            mockWebClient.Setup(x => x.DownloadString(It.IsAny <string>())).Returns(xmlData);


            var seralizer = new ThirdPartySerializer(mockWebClient.Object);
            var result    = seralizer.SerializeXmlData <RootObject>(xmlData);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.version, Is.EqualTo(3.1));
            Assert.That(result.releaseDate, Is.EqualTo("2014-06-25T00:00:00.000Z"));
            Assert.That(result.demo, Is.True);
            Assert.That(result.person.id, Is.EqualTo(12345));
        }
        public void XmlSerializer()
        {
            var mockWebClient = new Mock<IHttpClient>();

            mockWebClient.Setup(x => x.DownloadString(It.IsAny<string>())).Returns(XmlData);

            var serializer = new ThirdPartySerializer(mockWebClient.Object);
            var result = serializer.SerializeXmlData<RootObject>(XmlData);

            mockWebClient.Verify(x => x.DownloadString(XmlData), Times.Once);
            Assert.That(result, Is.Not.Null);
            Assert.That(result.version, Is.EqualTo(3.1));
            Assert.That(result.releaseDate, Is.EqualTo("2014-06-25T00:00:00.000Z"));
            Assert.That(result.demo, Is.True);
            Assert.That(result.person.id, Is.EqualTo(12345));
        }