Beispiel #1
0
        public void VersionSerialiseDeserialise()
        {
            var originalVersion = new Version()
            {
                Key = Guid.NewGuid(),
                GroupKey = Guid.NewGuid(),
                AppKey = Guid.NewGuid(),
                VersionNumber = "0.1",
                Comment = "Test Version",
                Tags = new Dictionary<string, string>()
                {
                    { "tagKey", "Some tag value." },
                    { "secondKey", "Multiline \r\n   test!" }
                }
            };

            Version secondVersion;
            using (var stream = originalVersion.Serialise())
            {
                secondVersion = new Version(stream);
            }

            Assert.AreEqual(originalVersion.Key, secondVersion.Key);
            Assert.AreEqual(originalVersion.GroupKey, secondVersion.GroupKey);
            Assert.AreEqual(originalVersion.AppKey, secondVersion.AppKey);
            Assert.AreEqual(originalVersion.Timestamp, secondVersion.Timestamp);
            Assert.AreEqual(originalVersion.Name, secondVersion.Name);
            Assert.AreEqual(originalVersion.Comment, secondVersion.Comment);
            Assert.AreEqual(originalVersion.VersionNumber, secondVersion.VersionNumber);

            Assert.IsNotNull(secondVersion.Tags);
            foreach (var tag in originalVersion.Tags)
            {
                Assert.IsTrue(secondVersion.Tags.ContainsKey(tag.Key));
                Assert.AreEqual(tag.Value, secondVersion.Tags[tag.Key]);
            }
        }
Beispiel #2
0
        public void VersionSerialiseDeserialiseNullTags()
        {
            var originalVersion = new Version()
            {
                Key = Guid.NewGuid(),
                GroupKey = Guid.NewGuid(),
                AppKey = Guid.NewGuid(),
                VersionNumber = "0.2",
                Comment = "Test Version",
            };

            Version secondVersion;
            using (var stream = originalVersion.Serialise())
            {
                secondVersion = new Version(stream);
            }

            Assert.AreEqual(originalVersion.Key, secondVersion.Key);
            Assert.AreEqual(originalVersion.GroupKey, secondVersion.GroupKey);
            Assert.AreEqual(originalVersion.AppKey, secondVersion.AppKey);
            Assert.AreEqual(originalVersion.Timestamp, secondVersion.Timestamp);
            Assert.AreEqual(originalVersion.Name, secondVersion.Name);
            Assert.AreEqual(originalVersion.Comment, secondVersion.Comment);
            Assert.AreEqual(originalVersion.VersionNumber, secondVersion.VersionNumber);

            Assert.AreEqual(originalVersion.Tags.Count, secondVersion.Tags.Count);
        }