public void Should_round_trip_single_scope_with_parameters() { var template = GetBaseLiveTemplate(); template.Scopes.Add(new Scope { Guid = Guid.NewGuid(), Type = "InCSharpStatement", Parameters = new Dictionary <string, string>() { { "minimumLanguageVersion", "2.0" }, { "foo", "bar" } } }); var dictionary = Serialise(template); var deserialiser = new SettingsDeserialisation(dictionary); var templates = deserialiser.DeserialiseTemplates(); Assert.AreEqual(template.Scopes[0].Parameters.Count, templates[0].Scopes[0].Parameters.Count); Assert.AreEqual(template.Scopes[0].Parameters.First().Key, templates[0].Scopes[0].Parameters.First().Key); Assert.AreEqual(template.Scopes[0].Parameters.First().Value, templates[0].Scopes[0].Parameters.First().Value); Assert.AreEqual(template.Scopes[0].Parameters.Skip(1).First().Key, templates[0].Scopes[0].Parameters.Skip(1).First().Key); Assert.AreEqual(template.Scopes[0].Parameters.Skip(1).First().Value, templates[0].Scopes[0].Parameters.Skip(1).First().Value); }
public void Should_round_trip_multiple_fields() { var template = GetBaseLiveTemplate(); template.Fields.Add(new Field { Name = "var1", Editable = true, Expression = "constant(\"true\")" }); template.Fields.Add(new Field { Name = "var2", Editable = false, Expression = "constant(\"false\")", EditableInstance = 2 }); var dictionary = Serialise(template); var deserialiser = new SettingsDeserialisation(dictionary); var templates = deserialiser.DeserialiseTemplates(); Assert.AreEqual(2, templates[0].Fields.Count); Assert.AreEqual("var1", templates[0].Fields[0].Name); Assert.IsTrue(templates[0].Fields[0].Editable); Assert.AreEqual("constant(\"true\")", templates[0].Fields[0].Expression); Assert.AreEqual("var2", templates[0].Fields[1].Name); Assert.IsTrue(templates[0].Fields[1].Editable); Assert.AreEqual("constant(\"false\")", templates[0].Fields[1].Expression); Assert.AreEqual(2, templates[0].Fields[1].EditableInstance); }
public void Should_round_trip_image() { var template = GetBaseLiveTemplate(); template.Image = "MyTemplateImage"; var dictionary = Serialise(template); var deserialiser = new SettingsDeserialisation(dictionary); var templates = deserialiser.DeserialiseTemplates(); Assert.AreEqual(1, templates.Count); Assert.AreEqual("MyTemplateImage", templates[0].Image); }
public void Should_round_trip_categories() { var template = GetBaseLiveTemplate(); template.Categories.Add("xunit"); template.Categories.Add("xunit-assert"); var dictionary = Serialise(template); var deserialiser = new SettingsDeserialisation(dictionary); var templates = deserialiser.DeserialiseTemplates(); Assert.AreEqual(2, templates[0].Categories.Count); Assert.AreEqual("xunit", templates[0].Categories[0]); Assert.AreEqual("xunit-assert", templates[0].Categories[1]); }
public void Should_round_trip_single_scope() { var template = GetBaseLiveTemplate(); template.Scopes.Add(new Scope { Guid = Guid.NewGuid(), Type = "InCSharpStatement" }); var dictionary = Serialise(template); var deserialiser = new SettingsDeserialisation(dictionary); var templates = deserialiser.DeserialiseTemplates(); Assert.AreEqual(1, templates[0].Scopes.Count); Assert.AreEqual(template.Scopes[0].Guid, templates[0].Scopes[0].Guid); Assert.AreEqual(template.Scopes[0].Type, templates[0].Scopes[0].Type); Assert.IsEmpty(templates[0].Scopes[0].Parameters); }
public void Should_round_trip_live_template() { var template = GetBaseFileTemplate(); var dictionary = Serialise(template); var deserialiser = new SettingsDeserialisation(dictionary); var templates = deserialiser.DeserialiseTemplates(); Assert.NotNull(templates); Assert.AreEqual(1, templates.Count); Assert.AreEqual(template.Guid, templates[0].Guid); Assert.AreEqual(TemplateType.File, templates[0].Type); Assert.AreEqual(template.Type, templates[0].Type); Assert.Null(templates[0].Shortcut); Assert.AreEqual(template.Description, templates[0].Description); Assert.AreEqual(template.Text, templates[0].Text); Assert.AreEqual(template.Reformat, templates[0].Reformat); Assert.AreEqual(template.ShortenQualifiedReferences, templates[0].ShortenQualifiedReferences); }