public void EntityRenownTaskToDictionary()
        {
            int     taskId    = 101;
            string  objective = "Do something tedious";
            int     level     = 42;
            Point2D coord     = new Point2D(500, 1000);

            var expected = new Dictionary <string, object>()
            {
                { "task_id", taskId },
                { "objective", objective },
                { "level", level },
                { "coord", new Dictionary <string, double>()
                  {
                      { "x", coord.X },
                      { "y", coord.Y }
                  } },
            };

            RenownTask task = new RenownTask()
            {
                TaskId      = taskId,
                Objective   = objective,
                Level       = level,
                Coordinates = coord,
            };

            var actual = task.ToDictionary();

            Assert.AreEqual(expected, actual, "Renown task");
            CollectionAssert.AreEquivalent((IDictionary <string, double>)expected["coord"],
                                           (IDictionary <string, double>)actual["coord"], "Coords");
        }
Exemple #2
0
 public static IDictionary <string, object> ToDictionary(this RenownTask task)
 {
     return(new Dictionary <string, object>()
     {
         { "task_id", task.TaskId },
         { "objective", task.Objective },
         { "level", task.Level },
         { "coord", new Dictionary <string, double>()
           {
               { "x", task.Coordinates.X },
               { "y", task.Coordinates.Y }
           } }
     });
 }
        public void EntitySubregionWithRenownTaskToDictionary()
        {
            RenownTask task = new RenownTask()
            {
                TaskId = 12
            };
            Subregion subregion = new Subregion()
            {
                Tasks = new List <RenownTask>()
                {
                    task
                }
            };

            var expected = task.ToDictionary();
            var actualPointOfInterest = (ICollection <object>)subregion.ToDictionary()["tasks"];
            var actual = (IDictionary <string, object>)actualPointOfInterest.First();

            Assert.AreEqual(expected, actual);
        }