private static void AssertBasicContentMetaData(XmlData xmlMetaData, ContentMetaData metaData) { AssertMinimumContentMetaData(xmlMetaData, metaData.Name, metaData.Type.ToString(), metaData.LastTimeUpdated); Assert.AreEqual(metaData.LocalFilePath, xmlMetaData.GetAttributeValue("LocalFilePath")); Assert.AreEqual(metaData.FileSize.ToString(), xmlMetaData.GetAttributeValue("FileSize")); }
private static void AssertBasicContentMetaData(XmlData xmlMetaData, ContentMetaData metaData) { AssertMinimumContentMetaData(xmlMetaData, metaData.Name, metaData.Type.ToString(), metaData.LastTimeUpdated); Assert.AreEqual(metaData.LocalFilePath, xmlMetaData.GetAttributeValue("LocalFilePath")); Assert.AreEqual(metaData.FileSize.ToString(), xmlMetaData.GetAttributeValue("FileSize")); }
public void GetAttributeValueAsInteger() { var root = new XmlData("root"); root.AddAttribute("number", "123"); Assert.AreEqual(123, root.GetAttributeValue("number", 0)); Assert.AreEqual("", root.GetAttributeValue("nonexistant", "")); }
public void GetAttributeValue() { var root = new XmlData("root"); root.AddAttribute("attribute", "value"); Assert.AreEqual("value", root.GetAttributeValue("attribute")); Assert.AreEqual("", root.GetAttributeValue("attribute2")); }
private static void AssertMinimumContentMetaData(XmlData xmlMetaData, string nameAttributeValue, string typeAttributeValue, DateTime lastUpdatedAttributeValue) { Assert.AreEqual("ContentMetaData", xmlMetaData.Name); Assert.AreEqual(nameAttributeValue, xmlMetaData.GetAttributeValue("Name")); Assert.AreEqual(typeAttributeValue, xmlMetaData.GetAttributeValue("Type")); Assert.AreEqual(lastUpdatedAttributeValue.GetIsoDateTime(), xmlMetaData.GetAttributeValue("LastTimeUpdated")); }
private static void AssertMinimumContentMetaData(XmlData xmlMetaData, string nameAttributeValue, string typeAttributeValue, DateTime lastUpdatedAttributeValue) { Assert.AreEqual("ContentMetaData", xmlMetaData.Name); Assert.AreEqual(nameAttributeValue, xmlMetaData.GetAttributeValue("Name")); Assert.AreEqual(typeAttributeValue, xmlMetaData.GetAttributeValue("Type")); Assert.AreEqual(lastUpdatedAttributeValue.GetIsoDateTime(), xmlMetaData.GetAttributeValue("LastTimeUpdated")); }
//ncrunch: no coverage start public void LoadKerning(XmlData kerningData) { char firstChar = kerningData.GetAttributeValue("First", '\0'); char secondChar = kerningData.GetAttributeValue("Second", '\0'); int kerningDistance = kerningData.GetAttributeValue("Distance", 0); if (firstChar == '\0' || secondChar == '\0' || kerningDistance == 0) throw new InvalidDataException("Unable to add kerning " + firstChar + " and " + secondChar + " with distance=" + kerningDistance); Glyph glyph; if (GlyphDictionary.TryGetValue(firstChar, out glyph)) glyph.Kernings.Add(secondChar, kerningDistance); } //ncrunch: no coverage end
private void LoadGlyph(XmlData glyphData, Size fontMapSize) { char character = glyphData.GetAttributeValue("Character", ' '); var glyph = new Glyph { UV = new Rectangle(glyphData.GetAttributeValue("UV")), LeftSideBearing = glyphData.GetAttributeValue("LeftBearing", 0.0f), RightSideBearing = glyphData.GetAttributeValue("RightBearing", 0.0f) }; glyph.AdvanceWidth = glyphData.GetAttributeValue("AdvanceWidth", glyph.UV.Width - 2.0f); glyph.PrecomputedFontMapUV = Rectangle.BuildUVRectangle(glyph.UV, fontMapSize); GlyphDictionary.Add(character, glyph); }
private void LoadGlyph(XmlData glyphData, Size fontMapSize) { char character = glyphData.GetAttributeValue("Character", ' '); var glyph = new Glyph { UV = new Rectangle(glyphData.GetAttributeValue("UV")), LeftSideBearing = glyphData.GetAttributeValue("LeftBearing", 0.0f), RightSideBearing = glyphData.GetAttributeValue("RightBearing", 0.0f) }; glyph.AdvanceWidth = glyphData.GetAttributeValue("AdvanceWidth", glyph.UV.Width - 2.0f); glyph.PrecomputedFontMapUV = Rectangle.BuildUVRectangle(glyph.UV, fontMapSize); GlyphDictionary.Add(character, glyph); }
public void UpdateNonExistingAttribute() { var root = new XmlData("root"); root.UpdateAttribute("number", "312"); Assert.AreEqual("312", root.GetAttributeValue("number")); }
private string GetAppPackageFilePath(XmlData appInfoData) { string fileName = appInfoData.GetAttributeValue(XmlAttributeNameOfFileName); if (String.IsNullOrEmpty(fileName)) throw new AppInfoDataMissing(XmlAttributeNameOfFileName); // ncrunch: no coverage return Path.Combine(StorageDirectory, fileName); }
private static Guid GetAppGuid(XmlData appInfoData) { string appGuidString = appInfoData.GetAttributeValue(XmlAttributeNameOfAppGuid); if (String.IsNullOrEmpty(appGuidString)) throw new AppInfoDataMissing(XmlAttributeNameOfAppGuid); return new Guid(appGuidString); }
public void UpdateExistingAttributeWithSameValue() { var root = new XmlData("root"); root.AddAttribute("number", "123"); root.UpdateAttribute("number", "123"); Assert.AreEqual("123", root.GetAttributeValue("number")); }
private static DateTime GetAppBuildData(XmlData appInfoData) { var noBuildDate = DateTime.MinValue; DateTime buildDate = appInfoData.GetAttributeValue(XmlAttributeNameOfBuildDate, noBuildDate); if (buildDate == noBuildDate) throw new AppInfoDataMissing(XmlAttributeNameOfBuildDate); return buildDate; }
//ncrunch: no coverage start public void LoadKerning(XmlData kerningData) { char firstChar = kerningData.GetAttributeValue("First", '\0'); char secondChar = kerningData.GetAttributeValue("Second", '\0'); int kerningDistance = kerningData.GetAttributeValue("Distance", 0); if (firstChar == '\0' || secondChar == '\0' || kerningDistance == 0) { throw new InvalidDataException("Unable to add kerning " + firstChar + " and " + secondChar + " with distance=" + kerningDistance); } Glyph glyph; if (GlyphDictionary.TryGetValue(firstChar, out glyph)) { glyph.Kernings.Add(secondChar, kerningDistance); } } //ncrunch: no coverage end
public void InitializeData() { var mapXml = data.GetChild("Map"); if (mapXml == null || string.IsNullOrEmpty(mapXml.Value)) { throw new InvalidTileMapData(); //ncrunch: no coverage } Size = new Size(data.GetAttributeValue("Size")); ModelName = data.GetAttributeValue("ModelName"); InitializeLists(); StoreSpawnAndGoalPoints(); StoreWaves(); StoreGameTriggers(); InitializeMapFromXml(mapXml.Value); LoadCustomLevelData(data); Current = this; }
private string GetAppPackageFilePath(XmlData appInfoData) { string fileName = appInfoData.GetAttributeValue(XmlAttributeNameOfFileName); if (String.IsNullOrEmpty(fileName)) { throw new AppInfoDataMissing(XmlAttributeNameOfFileName); // ncrunch: no coverage } return(Path.Combine(StorageDirectory, fileName)); }
private static Guid GetAppGuid(XmlData appInfoData) { string appGuidString = appInfoData.GetAttributeValue(XmlAttributeNameOfAppGuid); if (String.IsNullOrEmpty(appGuidString)) { throw new AppInfoDataMissing(XmlAttributeNameOfAppGuid); // ncrunch: no coverage } return(new Guid(appGuidString)); }
private static string GetAppSolutionFilePath(XmlData appInfoData) { string solutionFilePath = appInfoData.GetAttributeValue(XmlAttributeNameOfSolutionFilePath); if (String.IsNullOrEmpty(solutionFilePath)) { throw new AppInfoDataMissing(XmlAttributeNameOfSolutionFilePath); // ncrunch: no coverage } return(solutionFilePath); }
private static void AssertFullContentMetaDataEntry(XmlData xmlMetaData, ContentMetaData metaData) { AssertBasicContentMetaData(xmlMetaData, metaData); AssertLanguageInMetaData(xmlMetaData, metaData); AssertPlatformFileIdInMetaData(xmlMetaData, metaData); foreach (KeyValuePair<string, string> valuePair in metaData.Values) Assert.AreEqual(metaData.Values[valuePair.Key], xmlMetaData.GetAttributeValue(valuePair.Key)); }
protected override AgentData ParseData(XmlData tower) { return (new TowerData((TowerType)Enum.Parse(typeof(TowerType), tower.GetAttributeValue("Type")), tower.GetAttributeValue("Name"), (AttackType)Enum.Parse(typeof(AttackType), tower.GetAttributeValue("AttackType")), tower.GetAttributeValue("Range", 0.0f), tower.GetAttributeValue("AttackFrequency", 0.0f), tower.GetAttributeValue("AttackDamage", 0.0f), tower.GetAttributeValue("Cost", 0))); }
protected override AgentData ParseData(XmlData tower) { return new TowerData((TowerType)Enum.Parse(typeof(TowerType), tower.GetAttributeValue("Type")), tower.GetAttributeValue("Name"), (AttackType)Enum.Parse(typeof(AttackType), tower.GetAttributeValue("AttackType")), tower.GetAttributeValue("Range", 0.0f), tower.GetAttributeValue("AttackFrequency", 0.0f), tower.GetAttributeValue("AttackDamage", 0.0f), tower.GetAttributeValue("Cost", 0)); }
private static DateTime GetAppBuildData(XmlData appInfoData) { var noBuildDate = DateTime.MinValue; DateTime buildDate = appInfoData.GetAttributeValue(XmlAttributeNameOfBuildDate, noBuildDate); if (buildDate == noBuildDate) { throw new AppInfoDataMissing(XmlAttributeNameOfBuildDate); // ncrunch: no coverage } return(buildDate); }
private static void AssertLanguageInMetaData(XmlData xmlMetaData, ContentMetaData metaData) { if (metaData.Language == null) { Assert.IsFalse(IsAttributeAvailable(xmlMetaData, "Language")); } else { Assert.AreEqual(metaData.Language, xmlMetaData.GetAttributeValue("Language")); } }
// ncrunch: no coverage end private static PlatformName GetAppPlatform(XmlData appInfoData) { const PlatformName NoPlatform = (PlatformName)0; PlatformName platform = appInfoData.GetAttributeValue(XmlAttributeNameOfPlatform, NoPlatform); if (platform == NoPlatform) { throw new AppInfoDataMissing(XmlAttributeNameOfPlatform); // ncrunch: no coverage } return(platform); }
private static void AssertFullContentMetaDataEntry(XmlData xmlMetaData, ContentMetaData metaData) { AssertBasicContentMetaData(xmlMetaData, metaData); AssertLanguageInMetaData(xmlMetaData, metaData); AssertPlatformFileIdInMetaData(xmlMetaData, metaData); foreach (KeyValuePair <string, string> valuePair in metaData.Values) { Assert.AreEqual(metaData.Values[valuePair.Key], xmlMetaData.GetAttributeValue(valuePair.Key)); } }
private static void AssertPlatformFileIdInMetaData(XmlData xmlMetaData, ContentMetaData metaData) { if (metaData.PlatformFileId == 0) { Assert.IsFalse(IsAttributeAvailable(xmlMetaData, "PlatformFileId")); } else { Assert.AreEqual(metaData.PlatformFileId.ToString(), xmlMetaData.GetAttributeValue("PlatformFileId")); } }
protected override AgentData ParseData(XmlData boss) { return(new BossData((BossType)Enum.Parse(typeof(BossType), boss.GetAttributeValue("Type")), boss.GetAttributeValue("Name"), boss.GetAttributeValue("MaxHp", 0.0f), boss.GetAttributeValue("Speed", 0.0f), boss.GetAttributeValue("Resistance", 0.0f), boss.GetAttributeValue("Gold", 0), ParseTypeDamageModifier(boss))); }
protected override AgentData ParseData(XmlData boss) { return new BossData((BossType)Enum.Parse(typeof(BossType), boss.GetAttributeValue("Type")), boss.GetAttributeValue("Name"), boss.GetAttributeValue("MaxHp", 0.0f), boss.GetAttributeValue("Speed", 0.0f), boss.GetAttributeValue("Resistance", 0.0f), boss.GetAttributeValue("Gold", 0), ParseTypeDamageModifier(boss)); }
private void DeleteFiles(XmlData entry) { var localFilePath = entry.GetAttributeValue("LocalFilePath"); if (string.IsNullOrEmpty(localFilePath)) { return; } if (NoContentEntryUsesFile(entry, localFilePath)) { File.Delete(Path.Combine(ContentProjectPath, localFilePath)); } }
protected override AgentData ParseData(XmlData creep) { return new CreepData((CreepType)Enum.Parse(typeof(CreepType), creep.GetAttributeValue("Type")), creep.GetAttributeValue("Name"), creep.GetAttributeValue("MaxHp", 0.0f), creep.GetAttributeValue("Speed", 0.0f), creep.GetAttributeValue("Resistance", 0.0f), creep.GetAttributeValue("Gold", 0), ParseTypeDamageModifier(creep)); }
protected override AgentData ParseData(XmlData creep) { return (new CreepData((CreepType)Enum.Parse(typeof(CreepType), creep.GetAttributeValue("Type")), creep.GetAttributeValue("Name"), creep.GetAttributeValue("MaxHp", 0.0f), creep.GetAttributeValue("Speed", 0.0f), creep.GetAttributeValue("Resistance", 0.0f), creep.GetAttributeValue("Gold", 0), ParseTypeDamageModifier(creep))); }
private void ParseXmlNode(XmlData currentNode) { var currentElement = ParseContentMetaData(currentNode.Attributes); var name = currentNode.GetAttributeValue("Name"); if (!metaData.ContainsKey(name) && currentNode.Parent != null) { lock (metaData) metaData.Add(name, currentElement); } foreach (var node in currentNode.Children) { ParseXmlNode(node); } }
// ncrunch: no coverage end private static PlatformName GetAppPlatform(XmlData appInfoData) { const PlatformName NoPlatform = (PlatformName)0; PlatformName platform = appInfoData.GetAttributeValue(XmlAttributeNameOfPlatform, NoPlatform); if (platform == NoPlatform) throw new AppInfoDataMissing(XmlAttributeNameOfPlatform); // ncrunch: no coverage return platform; }
private static void AssertLanguageInMetaData(XmlData xmlMetaData, ContentMetaData metaData) { if (metaData.Language == null) Assert.IsFalse(IsAttributeAvailable(xmlMetaData, "Language")); else Assert.AreEqual(metaData.Language, xmlMetaData.GetAttributeValue("Language")); }
private static GroupData ParseGroupData(XmlData group) { return(new GroupData(group.GetAttributeValue("Name"), group.GetAttributeValue("CreepTypeList").SplitAndTrim(',').ToList(), group.GetAttributeValue("SpawnIntervalList", 0.0f))); }
private static GroupData ParseGroupData(XmlData group) { return new GroupData(group.GetAttributeValue("Name"), group.GetAttributeValue("CreepTypeList").SplitAndTrim(',').ToList(), group.GetAttributeValue("SpawnIntervalList", 0.0f)); }
private static void AssertPlatformFileIdInMetaData(XmlData xmlMetaData, ContentMetaData metaData) { if (metaData.PlatformFileId == 0) Assert.IsFalse(IsAttributeAvailable(xmlMetaData, "PlatformFileId")); else Assert.AreEqual(metaData.PlatformFileId.ToString(), xmlMetaData.GetAttributeValue("PlatformFileId")); }
public void UpdateExistingAttributeWithSameValue() { var root = new XmlData("root"); root.AddAttribute("number", "123"); root.UpdateAttribute("number", "123"); Assert.AreEqual("123", root.GetAttributeValue("number")); }
public void UpdateNonExistingAttribute() { var root = new XmlData("root"); root.UpdateAttribute("number", "312"); Assert.AreEqual("312", root.GetAttributeValue("number")); }
public void GetAttributeValueAsInteger() { var root = new XmlData("root"); root.AddAttribute("number", "123"); Assert.AreEqual(123, root.GetAttributeValue("number", 0)); Assert.AreEqual("", root.GetAttributeValue("nonexistant", "")); }
public void GetAttributeValue() { var root = new XmlData("root"); root.AddAttribute("attribute", "value"); Assert.AreEqual("value", root.GetAttributeValue("attribute")); Assert.AreEqual("", root.GetAttributeValue("attribute2")); }
private static string GetAppSolutionFilePath(XmlData appInfoData) { string solutionFilePath = appInfoData.GetAttributeValue(XmlAttributeNameOfSolutionFilePath); if (String.IsNullOrEmpty(solutionFilePath)) throw new AppInfoDataMissing(XmlAttributeNameOfSolutionFilePath); // ncrunch: no coverage return solutionFilePath; }
private void DeleteFiles(XmlData entry) { var localFilePath = entry.GetAttributeValue("LocalFilePath"); if (string.IsNullOrEmpty(localFilePath)) return; if (NoContentEntryUsesFile(entry, localFilePath)) File.Delete(Path.Combine(contentPath, localFilePath)); }
private void LoadAlreadyBuiltApps() { storageData = settings.GetValue(XmlNodeNameOfStorageData, new XmlData(XmlNodeNameOfStorageData)); if (String.IsNullOrEmpty(storageData.GetAttributeValue("StoragePath"))) CreateNewBuiltAppsListData(); StorageDirectory = storageData.GetAttributeValue("StoragePath"); foreach (XmlData appInfoData in storageData.Children) TryLoadAppFromStorageData(appInfoData); }
private void ParseXmlNode(XmlData currentNode) { var currentElement = ParseContentMetaData(currentNode.Attributes); var name = currentNode.GetAttributeValue("Name"); if (!metaData.ContainsKey(name) && currentNode.Parent != null) metaData.Add(name, currentElement); foreach (var node in currentNode.Children) ParseXmlNode(node); }
public void CreateProjectMetaData() { AssertMinimumContentMetaData(projectMetaData, ProjectName, "Scene", DateTime.Now); Assert.AreEqual(Platform, projectMetaData.GetAttributeValue("ContentDeviceName")); }