Ejemplo n.º 1
0
        public XmlFileStorageTests()
        {
            if (File.Exists(_filePath))
            {
                File.Delete(_filePath);
            }

            _xmlFileStorage = new XmlFileStorage <FlashObservation>(_filePath);

            using var fileProcessor = new SaveToFileProcessor <FlashObservation>(new SerializeToXmlProcessor <FlashObservation>(), _filePath);
            var data = FlashObservationBaseData.InitializeFlashObservations();

            fileProcessor.OnNext(data[0]);
            fileProcessor.OnNext(data[1]);
            fileProcessor.OnNext(data[2]);
            fileProcessor.OnNext(data[3]);
            fileProcessor.OnCompleted();
        }
Ejemplo n.º 2
0
        protected override IEnergyObservationAnalizer GetAnalyzer()
        {
            if (File.Exists(_filePath))
            {
                File.Delete(_filePath);
            }

            using (var fileProcessor = new SaveToFileProcessor <FlashObservation>(new SerializeToXmlProcessor <FlashObservation>(), _filePath))
            {
                foreach (var flashObservation in ListStorage)
                {
                    fileProcessor.OnNext(flashObservation);
                }

                fileProcessor.OnCompleted();
            }

            return(new XmlAnalyzer <FlashObservation>(XDocument.Load(_filePath)));
        }
        public void OnNextTest_SomeFlashObservations_TheyAreWrittenCorrectlyToTheStream()
        {
            List <FlashObservation> flashObservations = FlashObservationBaseData.InitializeFlashObservations();

            var filePath = "data.json";

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            var processor = new SerializeToJsonProcessor <FlashObservation>();

            using var saveProcessor = new SaveToFileProcessor <FlashObservation>(processor, filePath);

            saveProcessor.OnNext(flashObservations[0]);
            saveProcessor.OnNext(flashObservations[1]);
            saveProcessor.OnNext(flashObservations[2]);
            saveProcessor.OnNext(flashObservations[3]);
            saveProcessor.OnCompleted();
        }