Example #1
0
        public void GameImageListXmlCloneTest()
        {
            var gameImageList1 = new GameImageList();

            gameImageList1.Add(new GameImage(1, 2, _imageData));

            gameImageList1.Add(new GameImage(3, 4, null));

            gameImageList1.Add(new GameImage(5, 6, _imageData));

            var gameImageList2 = CloneUtility.XmlClone(gameImageList1, null);

            Assert.AreNotSame(gameImageList1, gameImageList2);
            Assert.AreEqual(gameImageList1.List.Count, gameImageList2.List.Count);

            for (var index = 0; index < gameImageList1.List.Count; index++)
            {
                Assert.AreEqual(gameImageList1.List[index].Id, gameImageList2.List[index].Id);
                Assert.AreEqual(gameImageList1.List[index].GameId, gameImageList2.List[index].GameId);

                if (gameImageList1.List[index].Image != null)
                {
                    Assert.IsTrue(gameImageList1.List[index].Image.SequenceEqual(gameImageList2.List[index].Image));
                }

                else
                {
                    Assert.IsNull(gameImageList1.List[index].Image);
                    Assert.IsNull(gameImageList2.List[index].Image);
                }
            }
        }
Example #2
0
        public void GameImageListAddandRemoveTest()
        {
            var gameImageList = new GameImageList();

            Assert.AreEqual(gameImageList.List.Count, 0);

            gameImageList.Add(new GameImage(1, 2, _imageData));

            Assert.AreEqual(gameImageList.List.Count, 1);

            gameImageList.Add(new GameImage(3, 4, null));

            Assert.AreEqual(gameImageList.List.Count, 2);

            gameImageList.Add(new GameImage(5, 6, _imageData));

            Assert.AreEqual(gameImageList.List.Count, 3);

            gameImageList.Remove(1);

            Assert.AreEqual(gameImageList.List.Count, 2);

            gameImageList.Remove(3);

            Assert.AreEqual(gameImageList.List.Count, 1);

            gameImageList.Remove(5);

            Assert.AreEqual(gameImageList.List.Count, 0);
        }
Example #3
0
        public void GameImageListGetByIdTest()
        {
            var gameImageList = new GameImageList();

            gameImageList.Add(new GameImage(1, 2, _imageData));

            gameImageList.Add(new GameImage(3, 4, null));

            gameImageList.Add(new GameImage(5, 6, _imageData));

            var gameImage = gameImageList.GetById(0);

            Assert.AreEqual(gameImage, null);

            gameImage = gameImageList.GetById(-1);
            Assert.AreEqual(gameImage, null);

            gameImage = gameImageList.GetById(1);
            Assert.AreEqual(gameImage.GameId, 2);

            gameImage = gameImageList.GetById(3);
            Assert.AreEqual(gameImage.GameId, 4);

            gameImage = gameImageList.GetById(5);
            Assert.AreEqual(gameImage.GameId, 6);
        }
Example #4
0
        public void GameImageListExistsTest()
        {
            var gameImageList = new GameImageList();

            gameImageList.Add(new GameImage(1, 2, _imageData));

            gameImageList.Add(new GameImage(3, 4, null));

            gameImageList.Add(new GameImage(5, 6, _imageData));

            Assert.IsFalse(gameImageList.Exists(0));
            Assert.IsFalse(gameImageList.Exists(-1));
            Assert.AreEqual(gameImageList.Exists(1), true);
            Assert.AreEqual(gameImageList.Exists(3), true);
            Assert.AreEqual(gameImageList.Exists(5), true);
        }
Example #5
0
        public void GameImageListDictionaryTest()
        {
            var gameImageList1 = new GameImageList();

            gameImageList1.Add(new GameImage(1, 2, _imageData));

            gameImageList1.Add(new GameImage(3, 4, null));

            gameImageList1.Add(new GameImage(5, 6, _imageData));

            var dictionaryList = GameImageList.ToDictionaryList(gameImageList1);

            Assert.IsNotNull(dictionaryList);

            var gameImageList2 = GameImageList.FromDictionaryList(dictionaryList);

            Assert.AreNotSame(gameImageList1, gameImageList2);
            Assert.AreEqual(gameImageList1.List.Count, gameImageList2.List.Count);

            for (var index = 0; index < gameImageList1.List.Count; index++)
            {
                Assert.AreEqual(gameImageList1.List[index].Id, gameImageList2.List[index].Id);
                Assert.AreEqual(gameImageList1.List[index].GameId, gameImageList2.List[index].GameId);

                if (gameImageList1.List[index].Image != null)
                {
                    Assert.IsTrue(gameImageList1.List[index].Image.SequenceEqual(gameImageList2.List[index].Image));
                }

                else
                {
                    Assert.IsNull(gameImageList1.List[index].Image);
                    Assert.IsNull(gameImageList2.List[index].Image);
                }
            }
            #endregion Test Cases
        }
Example #6
0
        public void GameImageListJsonTest()
        {
            var gameImageList1 = new GameImageList();

            gameImageList1.Add(new GameImage(1, 2, _imageData));

            gameImageList1.Add(new GameImage(3, 4, null));

            gameImageList1.Add(new GameImage(5, 6, _imageData));

            var jsonText = CloneUtility.ToJson(gameImageList1);

            Assert.IsFalse(string.IsNullOrEmpty(jsonText));

            var gameImageList2 = CloneUtility.FromJson <GameImageList>(jsonText);

            Assert.AreNotSame(gameImageList1, gameImageList2);
            Assert.AreEqual(gameImageList1.List.Count, gameImageList2.List.Count);

            for (var index = 0; index < gameImageList1.List.Count; index++)
            {
                Assert.AreEqual(gameImageList1.List[index].Id, gameImageList2.List[index].Id);
                Assert.AreEqual(gameImageList1.List[index].GameId, gameImageList2.List[index].GameId);

                if (gameImageList1.List[index].Image != null)
                {
                    Assert.IsTrue(gameImageList1.List[index].Image.SequenceEqual(gameImageList2.List[index].Image));
                }

                else
                {
                    Assert.IsNull(gameImageList1.List[index].Image);
                    Assert.IsNull(gameImageList2.List[index].Image);
                }
            }
        }