public void RepositoryUpdate()
        {
            //arrange
            var connection = DbConnectionFactory.CreateTransient();
            var stubDB     = new GroceryStoreContext(connection);
            var userRepo   = new EfGenericRepository <User>(stubDB);

            var user = new User
            {
                FirstName   = "Pesho",
                LastName    = "Pesho",
                Username    = "******",
                Password    = "******",
                PhoneNumber = "Pesho"
            };

            userRepo.Add(user);
            stubDB.SaveChanges();

            //act
            user.Password = "******";
            userRepo.Update(user);

            string actual = userRepo.GetById(1).Password;

            //assert
            Assert.AreEqual("newPassword", actual);
        }
        public void ThrowArgumentNullExceptionWhenPassedEntityIsNull()
        {
            //Arrange
            var pages = new List <Page>
            {
                new Page()
                {
                    Id = Guid.NewGuid(), Title = "page", Content = "cntnt"
                },
                new Page()
                {
                    Id = Guid.NewGuid(), Title = "page", Content = "cntnt"
                }
            };
            var mockedDbContext = new Mock <ISotnWikiDbContext>();
            var mockedPageSet   = QueryableDbSetMock.GetQueryableMockDbSet <Page>(pages);

            mockedDbContext.Setup(c => c.Set <Page>()).Returns(mockedPageSet);
            mockedDbContext.Setup(c => c.Pages).Returns(mockedPageSet);
            string expectedExceptionMessage = "entity";

            var repositoryUnderTest = new EfGenericRepository <Page>(mockedDbContext.Object);

            //Act & Assert
            var exc = Assert.Throws <ArgumentNullException>(() => repositoryUnderTest.Update(null));

            //Assert
            StringAssert.Contains(expectedExceptionMessage, exc.Message);
        }
 public T Update(T entity)
 {
     return(efGenericRepository.Update(entity));
 }