示例#1
0
        public void GameGenreListXmlCloneTest()
        {
            var gameGenreList1 = new GameGenreList();

            gameGenreList1.Add(new GameGenre(
                                   1,
                                   2,
                                   3));

            gameGenreList1.Add(new GameGenre(
                                   2,
                                   3,
                                   4));

            gameGenreList1.Add(new GameGenre(
                                   3,
                                   4,
                                   5));

            var gameGenreList2 = CloneUtility.XmlClone(gameGenreList1, null);

            Assert.AreNotSame(gameGenreList1, gameGenreList2);
            Assert.AreEqual(gameGenreList1.List.Count, gameGenreList2.List.Count);

            for (var index = 0; index < gameGenreList1.List.Count; index++)
            {
                Assert.AreEqual(gameGenreList1.List[index].Id, gameGenreList2.List[index].Id);
                Assert.AreEqual(gameGenreList1.List[index].GameId, gameGenreList2.List[index].GameId);
                Assert.AreEqual(gameGenreList1.List[index].GenreId, gameGenreList2.List[index].GenreId);
            }
        }
示例#2
0
        public void TestXmlSerializer1()
        {
            var dto1 = CreateBasicDto();
            var dto2 = CloneUtility.XmlSerializerClone(dto1);

            IsValidClone(dto1, dto2);
        }
示例#3
0
        public void GameListXmlCloneTest()
        {
            var gameList1 = new GameList();

            gameList1.Add(new Game(
                              1,
                              "Name1",
                              "Description1"));

            gameList1.Add(new Game(
                              2,
                              "Name2",
                              "Description2"));

            gameList1.Add(new Game(
                              3,
                              "Name3",
                              "Description3"));

            var gameList2 = CloneUtility.XmlClone(gameList1, null);

            Assert.AreNotSame(gameList1, gameList2);
            Assert.AreEqual(gameList1.List.Count, gameList2.List.Count);

            for (var index = 0; index < gameList1.List.Count; index++)
            {
                Assert.AreEqual(gameList1.List[index].Id, gameList2.List[index].Id);
                Assert.AreEqual(gameList1.List[index].Name, gameList2.List[index].Name);
                Assert.AreEqual(gameList1.List[index].Description, gameList2.List[index].Description);
            }
        }
示例#4
0
        public void TestMemberwiseClone()
        {
            var dto1 = CreateBasicDto();
            var dto2 = CloneUtility.MemberwiseClone(dto1);

            IsValidClone(dto1, dto2);
        }
示例#5
0
        public void GameImageJsonTest()
        {
            var gameImage1 = new GameImage(
                1,
                2,
                _imageData);

            var jsonText = CloneUtility.ToJson(gameImage1);

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

            var gameImage2 = CloneUtility.FromJson <GameImage>(jsonText);

            Assert.AreNotSame(gameImage1, gameImage2);

            Assert.AreEqual(gameImage1.Id, gameImage2.Id);
            Assert.AreEqual(gameImage1.GameId, gameImage2.GameId);

            if (gameImage1.Image != null)
            {
                Assert.IsTrue(gameImage1.Image.SequenceEqual(gameImage2.Image));
            }

            else
            {
                Assert.IsNull(gameImage1.Image);
                Assert.IsNull(gameImage2.Image);
            }
        }
示例#6
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);
                }
            }
        }
示例#7
0
        public void GameImageXmlCloneTest()
        {
            var gameImage1 = new GameImage(
                1,
                2,
                _imageData);

            var gameImage2 = CloneUtility.XmlClone(gameImage1, null);

            Assert.AreNotSame(gameImage1, gameImage2);

            Assert.AreEqual(gameImage1.Id, gameImage2.Id);
            Assert.AreEqual(gameImage1.GameId, gameImage2.GameId);

            if (gameImage1.Image != null)
            {
                Assert.IsTrue(gameImage1.Image.SequenceEqual(gameImage2.Image));
            }

            else
            {
                Assert.IsNull(gameImage1.Image);
                Assert.IsNull(gameImage2.Image);
            }
        }
示例#8
0
        public void GamePlatformListBinaryCloneTest()
        {
            var gamePlatformList1 = new GamePlatformList();

            gamePlatformList1.Add(new GamePlatform(
                                      1,
                                      2,
                                      3));

            gamePlatformList1.Add(new GamePlatform(
                                      2,
                                      3,
                                      4));

            gamePlatformList1.Add(new GamePlatform(
                                      3,
                                      4,
                                      5));

            var gamePlatformList2 = CloneUtility.BinaryClone(gamePlatformList1);

            Assert.AreNotSame(gamePlatformList1, gamePlatformList2);
            Assert.AreEqual(gamePlatformList1.List.Count, gamePlatformList2.List.Count);

            for (var index = 0; index < gamePlatformList1.List.Count; index++)
            {
                Assert.AreEqual(gamePlatformList1.List[index].Id, gamePlatformList2.List[index].Id);
                Assert.AreEqual(gamePlatformList1.List[index].GameId, gamePlatformList2.List[index].GameId);
                Assert.AreEqual(gamePlatformList1.List[index].PlatformId, gamePlatformList2.List[index].PlatformId);
            }
        }
示例#9
0
        public void GamePlatformListJsonTest()
        {
            var gamePlatformList1 = new GamePlatformList();

            gamePlatformList1.Add(new GamePlatform(
                                      1,
                                      2,
                                      3));

            gamePlatformList1.Add(new GamePlatform(
                                      2,
                                      3,
                                      4));

            gamePlatformList1.Add(new GamePlatform(
                                      3,
                                      4,
                                      5));

            var jsonText = CloneUtility.ToJson(gamePlatformList1);

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

            var gamePlatformList2 = CloneUtility.FromJson <GamePlatformList>(jsonText);

            Assert.AreNotSame(gamePlatformList1, gamePlatformList2);
            Assert.AreEqual(gamePlatformList1.List.Count, gamePlatformList2.List.Count);

            for (var index = 0; index < gamePlatformList1.List.Count; index++)
            {
                Assert.AreEqual(gamePlatformList1.List[index].Id, gamePlatformList2.List[index].Id);
                Assert.AreEqual(gamePlatformList1.List[index].GameId, gamePlatformList2.List[index].GameId);
                Assert.AreEqual(gamePlatformList1.List[index].PlatformId, gamePlatformList2.List[index].PlatformId);
            }
        }
示例#10
0
        public void TestXmlSerializer2()
        {
            var dto1 = CreateComplexDto();
            var dto2 = CloneUtility.XmlSerializerClone(dto1);

            IsValidClone(dto1, dto2);
        }
示例#11
0
        public void TestSerializeClone2()
        {
            var dto1 = CreateComplexDto();
            var dto2 = CloneUtility.SerializableClone(dto1);

            IsValidClone(dto1, dto2);
        }
示例#12
0
        public void GameRatingListJsonTest()
        {
            var gameRatingList1 = new GameRatingList();

            gameRatingList1.Add(new GameRating(
                                    1,
                                    2,
                                    3, "Notes1"));

            gameRatingList1.Add(new GameRating(
                                    2,
                                    3,
                                    4, "Notes2"));

            gameRatingList1.Add(new GameRating(
                                    3,
                                    4,
                                    5, "Notes3"));

            var jsonText = CloneUtility.ToJson(gameRatingList1);

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

            var gameRatingList2 = CloneUtility.FromJson <GameRatingList>(jsonText);

            Assert.AreNotSame(gameRatingList1, gameRatingList2);
            Assert.AreEqual(gameRatingList1.List.Count, gameRatingList2.List.Count);

            for (var index = 0; index < gameRatingList1.List.Count; index++)
            {
                Assert.AreEqual(gameRatingList1.List[index].Id, gameRatingList2.List[index].Id);
                Assert.AreEqual(gameRatingList1.List[index].GameId, gameRatingList2.List[index].GameId);
                Assert.AreEqual(gameRatingList1.List[index].RatingId, gameRatingList2.List[index].RatingId);
            }
        }
示例#13
0
        public void GameRatingListXmlCloneTest()
        {
            var gameRatingList1 = new GameRatingList();

            gameRatingList1.Add(new GameRating(
                                    1,
                                    2,
                                    3, "Notes1"));

            gameRatingList1.Add(new GameRating(
                                    2,
                                    3,
                                    4, "Notes2"));

            gameRatingList1.Add(new GameRating(
                                    3,
                                    4,
                                    5, "Notes3"));

            var gameRatingList2 = CloneUtility.XmlClone(gameRatingList1, null);

            Assert.AreNotSame(gameRatingList1, gameRatingList2);
            Assert.AreEqual(gameRatingList1.List.Count, gameRatingList2.List.Count);

            for (var index = 0; index < gameRatingList1.List.Count; index++)
            {
                Assert.AreEqual(gameRatingList1.List[index].Id, gameRatingList2.List[index].Id);
                Assert.AreEqual(gameRatingList1.List[index].GameId, gameRatingList2.List[index].GameId);
                Assert.AreEqual(gameRatingList1.List[index].RatingId, gameRatingList2.List[index].RatingId);
            }
        }
示例#14
0
        public void RatingListJsonTest()
        {
            var ratingList1 = new RatingList();

            ratingList1.Add(new Rating(1, "Name1", "Description1", "Symbol1"));
            ratingList1.Add(new Rating(2, "Name2", "Description2", "Symbol2"));
            ratingList1.Add(new Rating(3, "Name3", "Description3", "Symbol3"));

            var jsontext = CloneUtility.ToJson(ratingList1);

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

            var ratingList2 = CloneUtility.FromJson <RatingList>(jsontext);

            Assert.AreNotSame(ratingList1, ratingList2);
            Assert.AreEqual(ratingList1.List.Count, ratingList2.List.Count);

            for (var index = 0; index < ratingList1.List.Count; index++)
            {
                Assert.AreEqual(ratingList1.List[index].Id, ratingList2.List[index].Id);
                Assert.AreEqual(ratingList1.List[index].Name, ratingList2.List[index].Name);
                Assert.AreEqual(ratingList1.List[index].Description, ratingList2.List[index].Description);
                Assert.AreEqual(ratingList1.List[index].Symbol, ratingList2.List[index].Symbol);
            }
        }
示例#15
0
        public void GameListJsonTest()
        {
            var gameList1 = new GameList();

            gameList1.Add(new Game(
                              1,
                              "Name1",
                              "Description1"));

            gameList1.Add(new Game(
                              2,
                              "Name2",
                              "Description2"));

            gameList1.Add(new Game(
                              3,
                              "Name3",
                              "Description3"));

            var jsonText = CloneUtility.ToJson(gameList1);

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

            var gameList2 = CloneUtility.FromJson <GameList>(jsonText);

            Assert.AreNotSame(gameList1, gameList2);
            Assert.AreEqual(gameList1.List.Count, gameList2.List.Count);

            for (var index = 0; index < gameList1.List.Count; index++)
            {
                Assert.AreEqual(gameList1.List[index].Id, gameList2.List[index].Id);
                Assert.AreEqual(gameList1.List[index].Name, gameList2.List[index].Name);
                Assert.AreEqual(gameList1.List[index].Description, gameList2.List[index].Description);
            }
        }
示例#16
0
        public void TestReflectionClone()
        {
            var dto1 = CreateSimpleDto();
            var dto2 = CloneUtility.ReflectionDeepClone(dto1);

            IsValidClone(dto1, dto2);
        }
        public object Clone()
        {
            var o = MemberwiseClone();

            CloneUtility.CloneProperties(o);

            return(o);
        }
示例#18
0
        public void TestExpressionTree()
        {
            // Could store compiled expression tree for reuse, possibly in cached dictionary with key being type.
            var dlg  = CloneUtility.CreateCloneDelegate(typeof(BasicDto));
            var dto1 = CreateBasicDto();
            var dto2 = dlg(dto1);

            IsValidClone(dto1, dto2);
        }
示例#19
0
        public void PlatformXmlCloneTest()
        {
            var platform1 = new Platform(1, "Name", "Maker");

            var platform2 = CloneUtility.XmlClone(platform1, null);

            Assert.AreNotSame(platform1, platform2);

            Assert.AreEqual(platform1.Id, platform2.Id);
            Assert.AreEqual(platform1.Name, platform2.Name);
            Assert.AreEqual(platform1.Maker, platform2.Maker);
        }
示例#20
0
        public void GenreXmlCloneTest()
        {
            var genre1 = new Genre(1, "Name", "Description");

            var genre2 = CloneUtility.XmlClone(genre1, null);

            Assert.AreNotSame(genre1, genre2);

            Assert.AreEqual(genre1.Id, genre2.Id);
            Assert.AreEqual(genre1.Name, genre2.Name);
            Assert.AreEqual(genre1.Description, genre2.Description);
        }
        /// <summary>
        /// Creates a deep clone of the current invoice (all fields and properties)
        /// </summary>
        /// <param name="invoice">Invoice to clone</param>
        public async Task <Invoice> Clone(Invoice invoice)
        {
            try
            {
                var clonedInvoice = await Task.FromResult(CloneUtility.DeepClone(invoice));

                return(clonedInvoice ?? null);
            }
            catch
            {
                throw;
            }
        }
示例#22
0
        public void ReviewXmlCloneTest()
        {
            var rating1 = new Review(1, "Name", "Description", 2);

            var rating2 = CloneUtility.XmlClone(rating1, null);

            Assert.AreNotSame(rating1, rating2);

            Assert.AreEqual(rating1.Id, rating2.Id);
            Assert.AreEqual(rating1.Name, rating2.Name);
            Assert.AreEqual(rating1.Description, rating2.Description);
            Assert.AreEqual(rating1.Reviewrating, rating2.Reviewrating);
        }
示例#23
0
        public void RatingXmlCloneTest()
        {
            var rating1 = new Rating(1, "Name", "Description", "Symbol");

            var rating2 = CloneUtility.XmlClone(rating1, null);

            Assert.AreNotSame(rating1, rating2);

            Assert.AreEqual(rating1.Id, rating2.Id);
            Assert.AreEqual(rating1.Name, rating2.Name);
            Assert.AreEqual(rating1.Description, rating2.Description);
            Assert.AreEqual(rating1.Symbol, rating2.Symbol);
        }
示例#24
0
        public void GameReviewXmlCloneTest()
        {
            var gameReview1 = new GameReview(
                1,
                2,
                3);

            var gameReview2 = CloneUtility.XmlClone(gameReview1, null);

            Assert.AreNotSame(gameReview1, gameReview2);

            Assert.AreEqual(gameReview1.Id, gameReview2.Id);
            Assert.AreEqual(gameReview1.GameId, gameReview2.GameId);
            Assert.AreEqual(gameReview1.ReviewId, gameReview2.ReviewId);
        }
示例#25
0
        public void GameBinaryCloneTest()
        {
            var game1 = new Game(
                1,
                "Name",
                "Description");

            var game2 = CloneUtility.BinaryClone(game1);

            Assert.AreNotSame(game1, game2);

            Assert.AreEqual(game1.Id, game2.Id);
            Assert.AreEqual(game1.Name, game2.Name);
            Assert.AreEqual(game1.Description, game2.Description);
        }
示例#26
0
        public void GamePlatformXmlCloneTest()
        {
            var gamePlatform1 = new GamePlatform(
                1,
                2,
                3);

            var gamePlatform2 = CloneUtility.XmlClone(gamePlatform1, null);

            Assert.AreNotSame(gamePlatform1, gamePlatform2);

            Assert.AreEqual(gamePlatform1.Id, gamePlatform2.Id);
            Assert.AreEqual(gamePlatform1.GameId, gamePlatform2.GameId);
            Assert.AreEqual(gamePlatform1.PlatformId, gamePlatform2.PlatformId);
        }
示例#27
0
        public void GameRatingXmlCloneTest()
        {
            var gameRating1 = new GameRating(
                1,
                2,
                3, "Notes");

            var gameRating2 = CloneUtility.XmlClone(gameRating1, null);

            Assert.AreNotSame(gameRating1, gameRating2);

            Assert.AreEqual(gameRating1.Id, gameRating2.Id);
            Assert.AreEqual(gameRating1.GameId, gameRating2.GameId);
            Assert.AreEqual(gameRating1.RatingId, gameRating2.RatingId);
        }
示例#28
0
        public void GameGenreXmlCloneTest()
        {
            var gameGenre1 = new GameGenre(
                1,
                2,
                3);

            var gameGenre2 = CloneUtility.XmlClone(gameGenre1, null);

            Assert.AreNotSame(gameGenre1, gameGenre2);

            Assert.AreEqual(gameGenre1.Id, gameGenre2.Id);
            Assert.AreEqual(gameGenre1.GameId, gameGenre2.GameId);
            Assert.AreEqual(gameGenre1.GenreId, gameGenre2.GenreId);
        }
示例#29
0
        public void GenreJsonTest()
        {
            var genre1 = new Genre(1, "Name", "Description");

            var jsontext = CloneUtility.ToJson(genre1);

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

            var genre2 = CloneUtility.FromJson <Genre>(jsontext);

            Assert.AreNotSame(genre1, genre2);

            Assert.AreEqual(genre1.Id, genre2.Id);
            Assert.AreEqual(genre1.Name, genre2.Name);
            Assert.AreEqual(genre1.Description, genre2.Description);
        }
示例#30
0
        public void PlatformJsonTest()
        {
            var platform1 = new Platform(1, "Name", "Maker");

            var jsontext = CloneUtility.ToJson(platform1);

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

            var platform2 = CloneUtility.FromJson <Platform>(jsontext);

            Assert.AreNotSame(platform1, platform2);

            Assert.AreEqual(platform1.Id, platform2.Id);
            Assert.AreEqual(platform1.Name, platform2.Name);
            Assert.AreEqual(platform1.Maker, platform2.Maker);
        }