예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }