Ejemplo n.º 1
0
        public void GivenFilenameThatDoesNotExistWhenReadThenNull()
        {
            var filename = Path.Combine(_tempPath, DatacardConstants.VersionFile);

            var serializer = new VersionInfoSerializer();
            var model      = serializer.Deserialize(filename);

            Assert.That(model, Is.Null);
        }
Ejemplo n.º 2
0
        public void GivenFilenameWhenSerializeDeserializeThenFileContainsCorrectVersionInfo()
        {
            var serializationVersion = SerializationVersionEnum.V1;
            var expectedVersion      = typeof(Plugin).Assembly.GetName().Version;

            var serializer = new VersionInfoSerializer();

            serializer.Serialize(serializationVersion, _tempPath);
            var result = serializer.Deserialize(_tempPath);

            Assert.That(result.PluginVersion, Is.EqualTo(expectedVersion));
            Assert.That(result.SerializationVersion, Is.EqualTo(serializationVersion));
        }
        public void GivenVersionFileWrittenInPostNetCoreApp31FormatWhenReadThenCorrectVersionReturned()
        {
            var postNetCoreApp31Json = "{\"AdmVersion\":null,\"PluginVersion\":\"1.2.3.4\",\"SerializationVersion\":1}";

            Directory.CreateDirectory(_tempPath);
            var filename = Path.Combine(_tempPath, DatacardConstants.VersionFile);

            File.WriteAllText(filename, postNetCoreApp31Json);

            var serializer = new VersionInfoSerializer();
            var model      = serializer.Deserialize(_tempPath);

            Assert.That(model.PluginVersion, Is.EqualTo(new Version(1, 2, 3, 4)));
        }
Ejemplo n.º 4
0
        public void GivenFilenameWhenDeserialzieThenCorrectVersionInfo()
        {
            var versionInfo = new AdmVersionInfo
            {
                PluginVersion        = new Version("1.2.3.4"),
                SerializationVersion = SerializationVersionEnum.V1
            };

            Directory.CreateDirectory(_tempPath);
            File.WriteAllText(Path.Combine(_tempPath, DatacardConstants.VersionFile), JsonConvert.SerializeObject(versionInfo));

            var serializer = new VersionInfoSerializer();
            var result     = serializer.Deserialize(_tempPath);

            Assert.That(result.PluginVersion, Is.EqualTo(versionInfo.PluginVersion));
            Assert.That(result.SerializationVersion, Is.EqualTo(versionInfo.SerializationVersion));
        }