public void A_User_Should_be_Able_to_Read_A_XmlFile(string fileName) { var xmlFileReader = new XmlFileReader(filePath, fileName); string contentFile = xmlFileReader.Read(); Assert.Equal("<note><to>Tove</to><from>Jani</from></note>", contentFile); }
public void A_User_Should_be_Able_to_Read_An_Encrypted_XmlFile_InjectingService() { string fileName = "EncryptedContentXML.xml"; //Mock DecryptService Service var mockDecryptService = new Mock <IDecryptDataService>(); mockDecryptService .Setup(mock => mock.DecryptData(It.IsAny <string>())) .Returns((string param) => { StringBuilder stringBuilder = new StringBuilder(param); char[] array = stringBuilder.ToString().ToCharArray(); Array.Reverse(array); return(new string(array)); }); var xmlFileReader = new XmlFileReader(filePath, fileName, mockDecryptService.Object); string contentFile = xmlFileReader.Read(); Assert.Equal("<note><to>Tove</to><from>Jani</from></note>", contentFile); }
public void ReadTest() { XmlFileReader xmlReader = new XmlFileReader("XMLFile1.xml"); string content = xmlReader.Read(); Assert.Equals(content, @"<tui><core><io>FileReader library</io></core></tui>"); }
public void AUserShouldBeAbleToSwitchEncryptionXmlFile() { IEncryptor encryptor = new ReverseEncryptor(); var fileReader = new XmlFileReader(encryptor); var filename = $@"{_currentDirectory}\files\xmlFile.xml"; var actualReversedXml = fileReader.Read(filename); fileReader.SetEncryptor(VoidEncryptor.Instance); var actualXml = fileReader.Read(filename); Assert.AreEqual("\n\r>txet/<!dlrow olleH>txet<\n\r>?\"0.1\"=noisrev lmx?<", actualReversedXml); Assert.AreEqual("<?xml version=\"1.0\"?>\r\n<text>Hello world!</text>\r\n", actualXml); }
public void Error_WrongConstructor_Read_An_Encrypted_XmlFile() { string fileName = "EncryptedContentXML.xml"; var xmlFileReader = new XmlFileReader(filePath, fileName); string contentFile = xmlFileReader.Read(); Assert.NotEqual("<note><to>Tove</to><from>Jani</from></note>", contentFile); }
public void AUserShouldBeAbleToReadAnEncryptedXMLFile() { IEncryptor encryptor = new ReverseEncryptor(); IFileReader fileReader = new XmlFileReader(encryptor); var filename = $@"{_currentDirectory}\files\xmlFile.xml"; var actual = fileReader.Read(filename); Assert.AreEqual("\n\r>txet/<!dlrow olleH>txet<\n\r>?\"0.1\"=noisrev lmx?<", actual); }
public void AUserShouldBeAbleToReadAXMLFile() { IFileReader fileReader = new XmlFileReader(); var filename = $@"{_currentDirectory}\files\xmlFile.xml"; var actual = XElement.Parse(fileReader.Read(filename)); var expected = XElement.Parse("<?xml version=\"1.0\"?><text>Hello world!</text>"); Assert.AreEqual(expected.ToString(), actual.ToString()); }
private async Task <List <XmlModel> > GenerateXmlModelAsync(string file) { return(await Task.Factory.StartNew(() => XmlFileReader.Read(file))); }