Esempio n. 1
0
        public void UpdateUpdate()
        {
            var playerRepo   = PlayerRepoFactory.Create();
            var initialCount = playerRepo.Context
                               .ToList()
                               .Count();

            var leSommer = playerRepo.Single(1);

            leSommer.LastName    = "Grandet";
            leSommer.DateOfBirth = new DateTime(1989, 5, 18);

            playerRepo.Update(leSommer);
            playerRepo.SaveChanges();

            var FinalCount = playerRepo.Context
                             .ToList()
                             .Count();

            var leSommerUpdated =
                playerRepo.Single(leSommer.Id);

            Assert.True(leSommerUpdated.LastName == "Grandet");
            Assert.True(leSommerUpdated.DateOfBirth == new DateTime(1989, 5, 18));
            Assert.True(initialCount == FinalCount);
        }
Esempio n. 2
0
        public void UpdateCreate()
        {
            var playerRepo   = PlayerRepoFactory.Create();
            var initialCount = playerRepo.Context
                               .ToList()
                               .Count();
            var renard = new Player()
            {
                FirstName   = "Wendie",
                LastName    = "Renard",
                DateOfBirth = new DateTime(1920, 8, 29)
            };

            playerRepo.Update(renard);
            playerRepo.SaveChanges();

            var FinalCount = playerRepo.Context
                             .ToList()
                             .Count();

            Assert.True(initialCount == FinalCount - 1);

            var renardCreated = playerRepo.Single(3);

            Assert.True(renardCreated != null);
            Assert.True(renardCreated.FirstName == "Wendie");
            Assert.True(renardCreated.LastName == "Renard");
            Assert.True(!renardCreated.IsNew);
        }
Esempio n. 3
0
        public void SingleByName()
        {
            var playerRepo = PlayerRepoFactory.Create();

            var leSommer = playerRepo.Single(1);

            Assert.True(leSommer.FirstName == "Eugénie");

            var fake = playerRepo.Single(42);

            Assert.True(fake == null);
        }
Esempio n. 4
0
        public void SingleById()
        {
            var playerRepo = PlayerRepoFactory.Create();

            var player1 = playerRepo.Single(1);

            Assert.True(player1.Id == 1);

            var noplayer = playerRepo.Single(42);

            Assert.True(noplayer == null);
        }
Esempio n. 5
0
        public void GetAll()
        {
            var playerRepo   = PlayerRepoFactory.Create();
            var contextCount = playerRepo.Context
                               .ToList()
                               .Count();

            var getAllCount = playerRepo
                              .GetAll()
                              .ToList()
                              .Count();

            Assert.True(contextCount == getAllCount);
        }
Esempio n. 6
0
        public void Find()
        {
            var playerRepo = PlayerRepoFactory.Create();
            var query      = playerRepo
                             .Find(c => c.FirstName.Contains("e"));
            var result = query.ToList();

            var countPlayersFromQuery = 0;

            foreach (var c in playerRepo.Context.ToList())
            {
                if (c.FirstName.Contains("e"))
                {
                    countPlayersFromQuery++;
                }
            }
            Assert.True(result.Count == countPlayersFromQuery);
        }
Esempio n. 7
0
        public void Delete()
        {
            var playerRepo   = PlayerRepoFactory.Create();
            var initialCount = playerRepo.Context
                               .ToList()
                               .Count();

            var leSommer = playerRepo.Single(1);

            playerRepo.Delete(leSommer);
            playerRepo.SaveChanges();
            var finalCount = playerRepo.Context
                             .ToList()
                             .Count();

            Assert.True(finalCount == initialCount - 1);
            Assert.True(playerRepo.Single(0) == null);
        }