Exemplo n.º 1
0
        public void JsonWriterTest()
        {
            EmptyDirectory(Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\Target Files"));

            Configurator configurator = new Configurator();

            ConcreteMediator <string, string> m = new ConcreteMediator <string, string>();

            JsonWriterProvider JsonWriter = new JsonWriterProvider(m);

            configurator.ConfigureDestinationPath(JsonWriter, Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\Target Files\\Document1.json"));


            JsonWriter.ProcessData("<Employees><title ><ID>1</ID ><FirstName > David </FirstName > </title > <text></text ></Employees>");

            Assert.IsTrue(File.Exists(Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\Target Files\\Document1.json")));
        }
Exemplo n.º 2
0
        public void DoubleProviderTestXmlToJson()
        {
            EmptyDirectory(Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\Target Files"));

            Configurator configurator = new Configurator();

            ConcreteMediator <string, string> m = new ConcreteMediator <string, string>();

            XmlReaderProvider diskReaderProvider = new XmlReaderProvider(m);

            configurator.ConfigureSourcePath(diskReaderProvider, Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\Source Files\\Document1.xml"));

            JsonWriterProvider jsonWriter = new JsonWriterProvider(m);

            configurator.ConfigureDestinationPath(jsonWriter, Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\Target Files\\Document1.json"));


            DoubleProvider <string, string> doubleProvider = new DoubleProvider <string, string>(diskReaderProvider, jsonWriter, m);

            doubleProvider.Process();

            Assert.IsTrue(File.Exists(Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\Target Files\\Document1.json")));
        }