public void Execute_DoesNotThrowException_ShouldCommitAllChanges() { //Arrange var addedComponent = CreateComponent(); //Act _unitOfWork.Execute(() => { SaveComponent(addedComponent); }).Wait(); var loadedComponents = LoadComponents(); //Assert Assert.That(loadedComponents.Count == 1); Assert.That(loadedComponents.First().SameIdentityAs(addedComponent)); }
public void Execute_InvokesSaveChanges_OnDbContext() { var context = EntityFrameworkMockHelper.GetMockContext <FakeDbContext>(); context.Setup(x => x.SaveChanges()).Returns(1); var unitOfWork = new EntityFrameworkUnitOfWork(() => context.Object); unitOfWork.Execute(); context.Verify(x => x.SaveChanges(), Times.Once); }