public void SpecialQualitiesModel_Get_Property_Defaults_Should_Pass() { // Arrange var result = new SpecialQualities(); // Act // Assert Assert.IsNull(result.Location); Assert.IsNull(result.LocationId); Assert.IsNull(result.AcceptCash); Assert.IsNull(result.AcceptDeposit); Assert.IsNull(result.Access); Assert.IsNull(result.AccessNotes); Assert.IsNull(result.Cashless); Assert.IsNull(result.DriveThruOnly); Assert.IsNull(result.EnvelopeRequired); Assert.IsNull(result.HandicapAccess); Assert.IsNull(result.InstallationType); Assert.IsNull(result.LimitedTransactions); Assert.IsNull(result.MilitaryIdRequired); Assert.IsNull(result.OnMilitaryBase); Assert.IsNull(result.OnPremise); Assert.IsNull(result.RestrictedAccess); Assert.IsNull(result.SelfServiceDevice); Assert.IsNull(result.SelfServiceOnly); Assert.IsNull(result.Surcharge); }
public void BreaksOutSightBasedAbilities() { var sq = new SpecialQualities(); var abl = new SomeSpecialAbilities(); sq.ProcessSpecialAbilities(abl); Assert.AreEqual(sq.SightAbilities.First(), abl.SpecialAbilities.Last()); }
public void ProcessSpecialQualityAbilities() { var sq = new SpecialQualities(); var abl = new SomeSpecialAbilities(); sq.ProcessSpecialAbilities(abl); Assert.AreEqual(sq.SpecialAbilities.First(), abl.SpecialAbilities.First()); }
public void SpecialQualitiesModel_Default_Should_Pass() { // Arrange // Act var result = new SpecialQualities(); // Assert Assert.IsNotNull(result); }
/// <summary> /// /// Creates new Locations, Contacts, SpecialQualities, DailyHours. /// /// </summary> /// /// /// <param name="newLocation"> ViewModel with properties corresponding to the fields for each table </param> /// /// /// <returns> /// /// False: If newLocation is null or there was an error when attempting to insert /// True: It newLocation is successfully inserted into the Database /// /// </returns> public virtual bool Create(AllTablesViewModel newLocation) { if (newLocation == null) // Non-valid ViewModel Object { return(false); } // Ensures we don't end up with any duplicate LocationIds while (db.LocationIdNotUnique(newLocation.LocationId)) { newLocation.LocationId = Guid.NewGuid().ToString(); } Locations location = AllTablesViewModel.GetNewLocation(newLocation); Contacts contact = AllTablesViewModel.GetNewContact(newLocation); SpecialQualities specialQuality = AllTablesViewModel.GetNewSpecialQualities(newLocation); DailyHours dailyHours = AllTablesViewModel.GetNewDailyHours(newLocation); try { db.AlterRecordInfo(AlterRecordInfoEnum.Create, location); if (contact != null) { db.AlterRecordInfo(AlterRecordInfoEnum.Create, contact); } if (specialQuality != null) { db.AlterRecordInfo(AlterRecordInfoEnum.Create, specialQuality); } if (dailyHours != null) { db.AlterRecordInfo(AlterRecordInfoEnum.Create, dailyHours); } db.SaveChanges(); } catch (Exception) { return(false); } return(true); }
public void SpecialQualitiesModel_Set_Property_Should_Pass() { // Arrange var result = new SpecialQualities(); // Act result.Location = new Locations(); result.LocationId = "location id"; result.AcceptCash = "Y"; result.AcceptDeposit = "Y"; result.Access = "Y"; result.AccessNotes = "additional"; result.Cashless = "Y"; result.DriveThruOnly = "Y"; result.EnvelopeRequired = "Y"; result.HandicapAccess = "Y"; result.InstallationType = "installation type"; result.LimitedTransactions = "Y"; result.MilitaryIdRequired = "Y"; result.OnMilitaryBase = "Y"; result.OnPremise = "Y"; result.RestrictedAccess = "Y"; result.SelfServiceDevice = "Y"; result.SelfServiceOnly = "Y"; result.Surcharge = "Y"; // Assert Assert.IsNotNull(result.Location); Assert.AreEqual("location id", result.LocationId); Assert.AreEqual("Y", result.AcceptCash); Assert.AreEqual("Y", result.AcceptDeposit); Assert.AreEqual("Y", result.Access); Assert.AreEqual("additional", result.AccessNotes); Assert.AreEqual("Y", result.Cashless); Assert.AreEqual("Y", result.DriveThruOnly); Assert.AreEqual("Y", result.EnvelopeRequired); Assert.AreEqual("Y", result.HandicapAccess); Assert.AreEqual("installation type", result.InstallationType); Assert.AreEqual("Y", result.LimitedTransactions); Assert.AreEqual("Y", result.MilitaryIdRequired); Assert.AreEqual("Y", result.OnMilitaryBase); Assert.AreEqual("Y", result.OnPremise); Assert.AreEqual("Y", result.RestrictedAccess); Assert.AreEqual("Y", result.SelfServiceDevice); Assert.AreEqual("Y", result.SelfServiceOnly); Assert.AreEqual("Y", result.Surcharge); }
/// <summary> /// Populates a Special Qualities Object from a View Model Object's properties. /// </summary> /// /// /// <param name="newLocation"> A View Model Object from which to extract from </param> /// /// /// <returns> Null if all fields are empty, otherwise returns a Special Qualities Object </returns> public static SpecialQualities GetNewSpecialQualities(AllTablesViewModel newLocation) { if (newLocation is null) { return(null); } SpecialQualities specialQuality = new SpecialQualities(); specialQuality.AcceptCash = ConvertBooleanEnumToString(newLocation.AcceptCash); specialQuality.AcceptDeposit = ConvertBooleanEnumToString(newLocation.AcceptDeposit); specialQuality.Access = ConvertBooleanEnumToString(newLocation.Access); specialQuality.AccessNotes = newLocation.AccessNotes; specialQuality.Cashless = ConvertBooleanEnumToString(newLocation.Cashless); specialQuality.DriveThruOnly = ConvertBooleanEnumToString(newLocation.DriveThruOnly); specialQuality.EnvelopeRequired = ConvertBooleanEnumToString(newLocation.EnvelopeRequired); specialQuality.HandicapAccess = ConvertBooleanEnumToString(newLocation.HandicapAccess); specialQuality.InstallationType = newLocation.InstallationType; specialQuality.LimitedTransactions = ConvertBooleanEnumToString(newLocation.LimitedTransactions); specialQuality.LocationId = newLocation.LocationId; specialQuality.MilitaryIdRequired = ConvertBooleanEnumToString(newLocation.MilitaryIdRequired); specialQuality.OnMilitaryBase = ConvertBooleanEnumToString(newLocation.OnMilitaryBase); specialQuality.OnPremise = ConvertBooleanEnumToString(newLocation.OnPremise); specialQuality.RestrictedAccess = ConvertBooleanEnumToString(newLocation.RestrictedAccess); specialQuality.SelfServiceDevice = ConvertBooleanEnumToString(newLocation.SelfServiceDevice); specialQuality.SelfServiceOnly = ConvertBooleanEnumToString(newLocation.SelfServiceOnly); specialQuality.Surcharge = ConvertBooleanEnumToString(newLocation.Surcharge); if (specialQuality.AllPropertiesAreNull()) { return(null); } return(specialQuality); }
public override void ReadXML(XmlNode xmlNode) { base.ReadXML(xmlNode); try { foreach (XmlNode childNode in xmlNode.ChildNodes) { if (childNode.Name == "Type") { try { Type = Methods.GetCreatureTypeFromString(childNode.InnerText); } catch (FormatException) { Type = Types.Creature.Humanoid; } } else if (childNode.Name == "ChallengeRating") { ChallengeRating = Convert.ToSingle(childNode.InnerText); } else if (childNode.Name == "AttackSets") { AttackSets.Clear(); foreach (XmlNode attackSetNode in childNode.ChildNodes) { if (attackSetNode.Name == "AttackSet") { AttackSets.Add(new AttackSet(attackSetNode)); } } } else if (childNode.Name == "Strength") { Strength = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "Dexterity") { Dexterity = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "Constitution") { Constitution = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "Intelligence") { Intelligence = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "Wisdom") { Wisdom = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "Charisma") { Charisma = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "BaseAttackBonus") { BaseAttackBonus = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "GrappleModifier") { GrappleModifier = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "HitPoints") { HitPoints = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "HitDice") { HitDice = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "HitDieType") { HitDieType = Methods.GetDieTypeFromString(childNode.InnerText); } else if (childNode.Name == "ArmorClass") { ArmorClass = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "TouchArmorClass") { TouchArmorClass = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "FlatFootedArmorClass") { FlatFootedArmorClass = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "Speed") { Speed.ReadXML(childNode); } else if (childNode.Name == "FortitudeSave") { FortitudeSave = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "ReflexSave") { ReflexSave = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "WillSave") { WillSave = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "Feats") { foreach (XmlNode featNode in childNode.ChildNodes) { if (featNode.Name == "Feat") { Feats.Add(featNode.InnerText); } } } else if (childNode.Name == "Space") { Space = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "Reach") { Reach = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "Size") { Size = Methods.GetSizeFromString(childNode.InnerText); } else if (childNode.Name == "DamageReductions") { foreach (XmlNode drNode in childNode.ChildNodes) { if (drNode.Name == "DamageReduction") { DamageReduction dr = new DamageReduction(); dr.ReadXML(drNode); DamageReductions.Add(dr); } } } else if (childNode.Name == "Immunities") { Immunities.ReadXML(childNode); } else if (childNode.Name == "EnergyResistances") { foreach (XmlNode erNode in childNode.ChildNodes) { if (erNode.Name == "EnergyResistance") { EnergyResistance er = new EnergyResistance(); er.ReadXML(erNode); EnergyResistances.Add(er); } } } else if (childNode.Name == "SpellResistance") { SpellResistance = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "FastHealing") { FastHealing = Convert.ToInt32(childNode.InnerText); } else if (childNode.Name == "SpecialAttacks") { SpecialAttacks = childNode.InnerText; } else if (childNode.Name == "SpecialQualities") { foreach (string specialQuality in childNode.InnerText.Split(',')) { SpecialQualities.Add(specialQuality.Trim()); } } } } catch (XmlException e) { MessageBox.Show(e.ToString()); } }