예제 #1
0
        public ProtobufContractGenerator(string protobufMappingFile)
        {
            _mapper = new ProtobufElementMapper(protobufMappingFile);
            if (!_mapper.IsMappingDocumentLoaded)
            {
                _mapper = null;
            }

            _model = TypeModel.Create();
        }
        public void GivenElementThatIsNotMappedWhenMappedThenIsAddedToFile()
        {
            const string elementName = "NumericRepresentation100";
            var          result      = _mapper.Map(elementName);

            _mapper = new ProtobufElementMapper(_tempFile);
            var           mappedNames = _mapper.GetListOfMappedNames();
            List <string> mappedIds   = _mapper.GetListOfMappedIds();

            Assert.Contains(elementName, mappedNames);
            Assert.Contains(result.ToString(CultureInfo.InvariantCulture), mappedIds);
        }
        public void Setup()
        {
            var resourceDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ProtobufTestFiles");

            var tempDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(tempDirectory);
            _tempFile = Path.Combine(tempDirectory, "text.xml");
            File.WriteAllText(_tempFile, File.ReadAllText(Path.Combine(resourceDirectory, "ProtobufMappingTest.xml")));

            _mapper = new ProtobufElementMapper(_tempFile);
            if (!_mapper.IsMappingDocumentLoaded)
            {
                _mapper = null;
            }
        }
        public void GivenXmlFileThatDoesNotExistWhenNewThenDocumentNotLoaded()
        {
            _mapper = new ProtobufElementMapper(@"..\..\NotAFile.xml");

            Assert.AreEqual(false, _mapper.IsMappingDocumentLoaded);
        }