public override void Act() { base.Act(); _updated = _repository.Update(new NonKeyed { Id = 1, Name = "updated", TestEntities = new List <TestEntity> { new TestEntity { Id = 1, Name = "1" }, new TestEntity { Id = 4, Name = "4" }, new TestEntity { Id = 0, Name = "new 1" }, new TestEntity { Id = 0, Name = "new 2" } } }, "TestEntities"); }
public override void Arrange() { base.Arrange(); var data = new List <NonKeyed> { new NonKeyed { Id = 1, Name = "1" }, new NonKeyed { Id = 2, Name = "2" }, }.AsQueryable(); MockNonKeyedSet = new Mock <DbSet <NonKeyed> >(); MockNonKeyedSet.As <IQueryable <NonKeyed> >().Setup(m => m.Provider).Returns(data.Provider); MockNonKeyedSet.As <IQueryable <NonKeyed> >().Setup(m => m.Expression).Returns(data.Expression); MockNonKeyedSet.As <IQueryable <NonKeyed> >().Setup(m => m.ElementType).Returns(data.ElementType); MockNonKeyedSet.As <IQueryable <NonKeyed> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator()); MockNonKeyedSet.Setup(s => s.Find(It.IsAny <object[]>())).Returns(() => { _old = new NonKeyed { Id = 1, Name = "updated", TestEntities = new List <TestEntity> { new TestEntity { Id = 2, Name = "2" }, new TestEntity { Id = 3, Name = "3" }, new TestEntity { Id = 1, Name = "1" } } }; return(_old); }); MockContext = new Mock <ModelContext>(); MockContext.Setup(c => c.Set <NonKeyed>()).Returns(MockNonKeyedSet.Object); _repository = new Repository <NonKeyed>(MockContext.Object); RelationshipLoaderAdapter.LoadFunction = (DbContext context, object entity, string[] includes) => { return; }; }