public async Task IzmeniZaglavlje_NalogNull_Greska() { var fakeNalogRepo = new Mock <IFinNalogRepository>(); var nalogSvc = new FinNalogService(fakeNalogRepo.Object); Func <Task> izmeni = async() => await nalogSvc.IzmeniZaglavljeAsync(null, TipNaloga.Izvodi, new DateTime(2018, 10, 20), "opis"); await Assert.ThrowsAsync <ArgumentNullException>(izmeni); }
public async Task NePostoji_KorektnoMenja() { var nalogIzBaze = FinNalogHelper.NalogFromDb(callBase: false); var fakeNalogRepo = new Mock <IFinNalogRepository>(); fakeNalogRepo.Setup(x => x.GetPostojeciAsync(TipNaloga.Izvodi, new DateTime(2018, 10, 20))).ReturnsAsync(null as FinNalogId); var nalogSvc = new FinNalogService(fakeNalogRepo.Object); await nalogSvc.IzmeniZaglavljeAsync(nalogIzBaze.Object, TipNaloga.Izvodi, new DateTime(2018, 10, 20), "opis new"); nalogIzBaze.Verify(x => x.IzmeniZaglavlje(TipNaloga.Izvodi, new DateTime(2018, 10, 20), "opis new")); }
public async Task VecPostoji_Greska() { var nalogIzBaze = FinNalogHelper.NalogFromDb(callBase: false); var fakeNalogRepo = new Mock <IFinNalogRepository>(); var nalogIzBazeIdRandom = new Mock <FinNalogId> { CallBase = true }; nalogIzBazeIdRandom.SetupGet(x => x.Id).Returns(Guid.NewGuid()); fakeNalogRepo.Setup(x => x.GetPostojeciAsync(TipNaloga.UlazneFakture, new DateTime(2018, 10, 21))).ReturnsAsync(nalogIzBazeIdRandom.Object); var nalogSvc = new FinNalogService(fakeNalogRepo.Object); Func <Task> izmeni = async() => await nalogSvc.IzmeniZaglavljeAsync(nalogIzBaze.Object, TipNaloga.UlazneFakture, new DateTime(2018, 10, 21), "opis"); await Assert.ThrowsAsync <KnjizenjeException>(izmeni); }