public void GIVEN_PositiveInteger_WHEN_GetPositiveDivisors_THEN_ReturnPositiveDivisors() { IDictionary <UInt64, UInt64[]> testcases = new Dictionary <UInt64, UInt64[]>() { { 60, new UInt64[] { 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60 } }, { 42, new UInt64[] { 1, 2, 3, 6, 7, 14, 21, 42 } }, { 25, new UInt64[] { 1, 5, 25 } }, { 3, new UInt64[] { 1, 3 } }, { 2, new UInt64[] { 1, 2 } }, { 1, new UInt64[] { 1 } } }; StringBuilder result = new StringBuilder(); foreach (KeyValuePair <UInt64, UInt64[]> testcase in testcases) { UInt64[] actual = Req2.getPositiveDivisors(testcase.Key); UInt64[] expected = testcase.Value; // Ref: https://msdn.microsoft.com/en-us/library/bb348567.aspx if (!actual.SequenceEqual(expected)) { string msg = string.Format("Test case failed for '{0}'. Actual: [{1}]. Expected: [{2}]", testcase.Key, String.Join(",", actual), String.Join(",", expected)); result.Append(msg); } Assert.IsTrue(result.Length == 0, result.ToString()); } }
public void Save(int itemNum) { if (!Directory.Exists(Paths.DataPath + "Item")) { Directory.CreateDirectory(Paths.DataPath + "Item"); } using (XmlWriter writer = XmlWriter.Create(Paths.DataPath + "Item\\" + itemNum + ".xml", Logger.XmlWriterSettings)) { writer.WriteStartDocument(); writer.WriteStartElement("ItemEntry"); #region Basic data writer.WriteStartElement("General"); writer.WriteElementString("Name", Name); writer.WriteElementString("Description", Desc); writer.WriteElementString("ItemType", Type.ToString()); writer.WriteElementString("Price", Price.ToString()); writer.WriteElementString("Rarity", Rarity.ToString()); writer.WriteElementString("Sprite", Sprite.ToString()); writer.WriteElementString("Requirement", Req.ToString()); writer.WriteElementString("Req1", Req1.ToString()); writer.WriteElementString("Req2", Req2.ToString()); writer.WriteElementString("Req3", Req3.ToString()); writer.WriteElementString("Req4", Req4.ToString()); writer.WriteElementString("Req5", Req5.ToString()); writer.WriteElementString("Effect", Effect.ToString()); writer.WriteElementString("Effect1", Effect1.ToString()); writer.WriteElementString("Effect2", Effect2.ToString()); writer.WriteElementString("Effect3", Effect3.ToString()); writer.WriteElementString("ThrowEffect", ThrowEffect.ToString()); writer.WriteElementString("Throw1", Throw1.ToString()); writer.WriteElementString("Throw2", Throw2.ToString()); writer.WriteElementString("Throw3", Throw3.ToString()); writer.WriteEndElement(); #endregion Basic data writer.WriteEndElement(); writer.WriteEndDocument(); } }
public void GIVEN_Zero_WHEN_GetPositiveDivisors_THEN_ThrowArgumentException() { UInt64[] result = Req2.getPositiveDivisors(0); }
public Plot Clone() => new Plot { Req1 = Req1.Clone(), Req2 = Req2.Clone(), Req3 = Req3.Clone(), District = District };