Create moq for property in entity framework

18 views
Skip to first unread message

solai kannan

unread,
Oct 8, 2015, 12:19:20 PM10/8/15
to Moq Discussions
hi i have a method is repository

 public bool UpdateEffectiveDate(int driverId, DateTime effectiveDate, string UserId)
        {
            db myentity=new myentity();
            Driver driver = db.Drivers.Find(driverId);
            driver.EffectiveDate = effectiveDate;
            driver.LastModifiedBy = UserId;
            driver.LastModifiedDate = DateTime.Now;
            db.Drivers.Attach(driver);
            db.Entry(driver).Property(x => x.EffectiveDate).IsModified = true;
            db.Entry(driver).Property(x => x.LastModifiedBy).IsModified = true;
            db.Entry(driver).Property(x => x.LastModifiedDate).IsModified = true;
            return (db.SaveChanges() > 0);

        }

the moq must be created for entity, can anyone say how to create a moq for this method.
and how to create moq to properties like " db.Entry(driver).Property(x => x.EffectiveDate).IsModified" .


thanks in advance

Reply all
Reply to author
Forward
0 new messages