Beispiel #1
0
        public void TargetSerialiseDeserialise()
        {
            var originalTarget = new Target()
            {
                Key = Guid.NewGuid(),
                Name = "Test Target",
                GroupKey = Guid.NewGuid(),
                Tags = new Dictionary<string, string>()
                {
                    { "tagKey", "Some tag value." },
                    { "secondKey", "Multiline \r\n   test!" }
                }
            };

            Target secondTarget;
            using (var stream = originalTarget.Serialise())
            {
                secondTarget = new Target(stream);
            }

            Assert.AreEqual(originalTarget.Key, secondTarget.Key);
            Assert.AreEqual(originalTarget.Name, secondTarget.Name);
            Assert.AreEqual(originalTarget.GroupKey, secondTarget.GroupKey);

            Assert.IsNotNull(secondTarget.Tags);
            foreach (var tag in originalTarget.Tags)
            {
                Assert.IsTrue(secondTarget.Tags.ContainsKey(tag.Key));
                Assert.AreEqual(tag.Value, secondTarget.Tags[tag.Key]);
            }
        }
Beispiel #2
0
        public void TargetSerialiseDeserialiseNullTags()
        {
            var originalTarget = new Target()
            {
                Key = Guid.NewGuid(),
                Name = "Test Target",
                GroupKey = Guid.NewGuid(),
            };

            Target secondTarget;
            using (var stream = originalTarget.Serialise())
            {
                secondTarget = new Target(stream);
            }

            Assert.AreEqual(originalTarget.Key, secondTarget.Key);
            Assert.AreEqual(originalTarget.Name, secondTarget.Name);
            Assert.AreEqual(originalTarget.GroupKey, secondTarget.GroupKey);

            Assert.AreEqual(originalTarget.Tags.Count, secondTarget.Tags.Count);
        }