Ejemplo n.º 1
0
        public void GIVEN_ValidInputArray_WHEN_GetMostCommonItems_THEN_ReturnMostCommonItems()
        {
            ICollection <MostCommonItemsTestSample> testcases = getTestInputs();

            StringBuilder result = new StringBuilder();

            foreach (MostCommonItemsTestSample sample in testcases)
            {
                int[]             commonItems = Req4.getMostCommonItems(sample.Input);
                IEnumerable <int> actual      = new List <int>(commonItems).OrderBy(i => i);
                IEnumerable <int> expected    = sample.ExpectedOutput.OrderBy(i => i);


                if (!actual.SequenceEqual(expected))
                {
                    string msg = string.Format("Test case failed for '{0}'. Actual: [{1}]. Expected: [{2}]",
                                               String.Join(",", sample.Input),
                                               String.Join(",", actual),
                                               String.Join(",", expected));

                    result.Append(msg);
                }

                Assert.IsTrue(result.Length == 0, result.ToString());
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }