public void Insert_EntityIsNull() { // Arrange var inMemory = new InMemory <TestEntity>(new Context(null)); // Act inMemory.Insert(null); // Assert }
public void Insert_Success() { // Arrange var mockDbSet = new Mock <DbSet <TestEntity> >(); mockDbSet.Setup(d => d.Add(It.IsAny <TestEntity>())); var mockContext = new Mock <IContext>(); mockContext.Setup(c => c.Set <TestEntity>()).Returns(mockDbSet.Object); mockContext.Setup(c => c.SaveChanges()); var inMemory = new InMemory <TestEntity>(mockContext.Object); // Act inMemory.Insert(new TestEntity()); // Assert mockDbSet.Verify(d => d.Add(It.IsAny <TestEntity>()), Times.Once); mockContext.Verify(c => c.Set <TestEntity>(), Times.Once); mockContext.Verify(c => c.SaveChanges(), Times.Once); }