public void GivenIdShouldRemoveFromDb() { Device d = new Device() { Id = 0, Name = "A" }; var mockContext = new Mock <UserDataContext>(); mockContext.Setup(c => c.Device.Find(0)).Returns(d); var dao = new DeviceDAO(mockContext.Object); dao.Remove(0); mockContext.Verify(m => m.Device.Remove(It.IsAny <Device>()), Times.Once()); }