示例#1
0
        public void CanConvertToString()
        {
            var strings = new string[] { "test1", "test2" };
            var result  = ClientCardSerializeService.ConvertToString(strings);

            result.Should().Be("test1test2");
        }
示例#2
0
        public void CanNotDeserializeFile()
        {
            var    encode     = Encoding.UTF8;
            var    filePath   = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestHelpers\\Files\\exceptionTestFile.xml");
            var    file       = File.ReadAllLines(filePath, encode);
            string stringFile = ClientCardSerializeService.ConvertToString(file);

            Action act = () => ClientCardSerializeService.DeserializeDataFromXml(stringFile, encode);

            act.Should().Throw <SerializeServiceException>()
            .WithMessage("Invalid xml file");
        }
示例#3
0
        public void CanDeserializeDataFromXml()
        {
            this.clientCard.Id = this.defaultGuidId;
            this.clientCard.Works[0].WorkId        = this.defaultGuidId;
            this.clientCard.RepairEquipments[0].Id = this.defaultGuidId;
            this.clientCard.RepairEquipments[1].Id = this.defaultGuidId;
            var    encode     = Encoding.UTF8;
            var    filePath   = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestHelpers\\Files\\data.xml");
            var    file       = File.ReadAllLines(filePath, encode);
            string stringFile = ClientCardSerializeService.ConvertToString(file);

            var dataFromXml = ClientCardSerializeService.DeserializeDataFromXml(stringFile, encode);

            dataFromXml.Should().BeEquivalentTo(this.clientCard);
        }