private void SaveLoadConfigurationData(Role role, SerializerType serializer)
        {
            FileInfo          _fileInfo      = GetFileName(role, serializer, @"ConfigurationData{0}.{1}");
            ConfigurationData _configuration = null;

            switch (role)
            {
            case Role.Producer:
                _configuration = ReferenceConfiguration.LoadProducer();
                break;

            case Role.Consumer:
                _configuration = ReferenceConfiguration.LoadConsumer();
                break;

            default:
                break;
            }
            ConfigurationDataFactoryIO.Save <ConfigurationData>(_configuration, serializer, _fileInfo, (x, y, z) => { Console.WriteLine(z); });
            _fileInfo.Refresh();
            Assert.IsTrue(_fileInfo.Exists);
            ConfigurationData _mirror = ConfigurationDataFactoryIO.Load <ConfigurationData>(serializer, _fileInfo, (x, y, z) => { Console.WriteLine(z); }, () => { });

            ReferenceConfiguration.Compare(_configuration, _mirror);
        }
        private void LoadUsingSerializer(Role role, SerializerType serializer)
        {
            FileInfo _fileInfo = GetFileName(role, serializer, @"TestData\ConfigurationData{0}.{1}");

            Assert.IsTrue(_fileInfo.Exists, _fileInfo.ToString());
            ConfigurationData _mirror = null;
            ConfigurationData _source = null;

            switch (role)
            {
            case Role.Producer:
                _source = ReferenceConfiguration.LoadProducer();
                break;

            case Role.Consumer:
                _source = ReferenceConfiguration.LoadConsumer();
                break;
            }
            string _message = null;

            switch (serializer)
            {
            case SerializerType.Json:
                _mirror = ConfigurationDataFactoryIO.Load <ConfigurationData>
                              (() => JSONDataContractSerializers.Load <ConfigurationData>(_fileInfo, (x, y, z) => { _message = z; Assert.AreEqual <TraceEventType>(TraceEventType.Verbose, x); }), () => { });
                break;

            case SerializerType.Xml:
                _mirror = ConfigurationDataFactoryIO.Load <ConfigurationData>
                              (() => XmlDataContractSerializers.Load <ConfigurationData>(_fileInfo, (x, y, z) => { _message = z; Assert.AreEqual <TraceEventType>(TraceEventType.Verbose, x); }), () => { });
                break;
            }
            Console.WriteLine(_message);
            Assert.IsNotNull(_mirror);
            Assert.IsFalse(String.IsNullOrEmpty(_message));
            Assert.IsTrue(_message.Contains(_fileInfo.FullName));
            ReferenceConfiguration.Compare(_source, _mirror);
        }
예제 #3
0
 public ConfigurationDataWrapper()
 {
     ConfigurationData = ReferenceConfiguration.LoadConsumer();
 }