public void InstanceSerialiseDeserialise()
        {
            var originalInstance = new Instance()
            {
                Key = Guid.NewGuid(),
                GroupKey = Guid.NewGuid(),
                TargetKey = Guid.NewGuid(),
                Name = "Test Instance",
                Tags = new Dictionary<string, string>()
                {
                    { "tagKey", "Some tag value." },
                    { "secondKey", "Multiline \r\n   test!" }
                }
            };

            Instance secondInstance;
            using (var stream = originalInstance.Serialise())
            {
                secondInstance = new Instance(stream);
            }

            Assert.AreEqual(originalInstance.Key, secondInstance.Key);
            Assert.AreEqual(originalInstance.GroupKey, secondInstance.GroupKey);
            Assert.AreEqual(originalInstance.TargetKey, secondInstance.TargetKey);
            Assert.AreEqual(originalInstance.Name, secondInstance.Name);

            Assert.IsNotNull(secondInstance.Tags);
            foreach (var tag in originalInstance.Tags)
            {
                Assert.IsTrue(secondInstance.Tags.ContainsKey(tag.Key));
                Assert.AreEqual(tag.Value, secondInstance.Tags[tag.Key]);
            }
        }
        public void InstanceSerialiseDeserialiseNullTags()
        {
            var originalInstance = new Instance()
            {
                Key = Guid.NewGuid(),
                GroupKey = Guid.NewGuid(),
                TargetKey = Guid.NewGuid(),
                Name = "Test Instance",
            };

            Instance secondInstance;
            using (var stream = originalInstance.Serialise())
            {
                secondInstance = new Instance(stream);
            }

            Assert.AreEqual(originalInstance.Key, secondInstance.Key);
            Assert.AreEqual(originalInstance.GroupKey, secondInstance.GroupKey);
            Assert.AreEqual(originalInstance.TargetKey, secondInstance.TargetKey);
            Assert.AreEqual(originalInstance.Name, secondInstance.Name);

            Assert.AreEqual(originalInstance.Tags.Count, secondInstance.Tags.Count);
        }