public void GenerateData_SatisfiesDisposablePattern() { FinancialService service = new FinancialService(); var repo = DisposablePattern.For(new Mock <IRepository <FinancialTarget> >().Object); service.GenerateData(() => repo.Object); repo.VerifyDisposed(); }
public void GenerateDataOfRepoFactory_SaveCalled() { var repo = new Mock <IRepository <FinancialTarget> >(); FinancialService service = new FinancialService(repo.Object); service.GenerateData(() => repo.Object); repo.Verify(r => r.Save(), Times.AtLeastOnce()); }
public void GenerateDataParameterless_DoesNotCallDispose() { var repo = new Mock <IRepository <FinancialTarget> >(); FinancialService service = new FinancialService(repo.Object); service.GenerateData(); repo.Verify(x => x.Dispose(), Times.Never); }
public void GenerateData_CallsDispose() { FinancialService service = new FinancialService(); var repo = new Mock <IRepository <FinancialTarget> >(); service.GenerateData(() => repo.Object); repo.Verify(x => x.Dispose(), Times.AtLeastOnce); }
public void GenerateDataOfRepoFactory_AddsNothingAfterSave() { var repo = new Mock <IRepository <FinancialTarget> >(); bool saveCalled = false; bool addCalledAfterSave = false; repo.Setup(r => r.Save()).Callback(() => saveCalled = true); repo.Setup(r => r.Add(It.IsAny <FinancialTarget>())).Callback(() => addCalledAfterSave = saveCalled); FinancialService service = new FinancialService(repo.Object); service.GenerateData(() => repo.Object); Assert.False(addCalledAfterSave); }