public async Task Handle_Korektno() { var nalogIzBaze = new NalogForm() { Id = Guid.NewGuid(), Datum = new DateTime(2018, 10, 20), IdTip = 1, Opis = "opis" }; var fakeRepo = new Mock <INalogFormRepository>(); fakeRepo.Setup(x => x.GetAsync(nalogIzBaze.Id)).ReturnsAsync(nalogIzBaze); var fakeLogger = new Mock <ILogger <IzmenjenoZaglavljeNalogaHandler> >(); var evnt = new IzmenjenoZaglavljeNaloga(nalogIzBaze.Id, new DateTime(2018, 10, 21), 2, "opis novi") { UserId = Guid.NewGuid().ToString() }; var handler = new IzmenjenoZaglavljeNalogaHandler(fakeRepo.Object, fakeLogger.Object); await handler.Handle(evnt, default); Assert.Equal(new DateTime(2018, 10, 21), nalogIzBaze.Datum); Assert.Equal(2, nalogIzBaze.IdTip); Assert.Equal("opis novi", nalogIzBaze.Opis); }
public Task Handle(NalogOtvoren evnt, CancellationToken cancellationToken) { logger.LogTrace($"Handling IdNaloga: {evnt.IdNaloga}"); NalogForm nalog = new NalogForm() { Id = evnt.IdNaloga, IdTip = evnt.IdTip, Datum = evnt.DatumNaloga, Opis = evnt.Opis, }; nalogRepo.Add(nalog); return(Task.CompletedTask); }
public async Task Handle_Korektno() { var nalogIzBaze = new NalogForm() { Id = Guid.NewGuid(), }; var fakeRepo = new Mock <INalogFormRepository>(); fakeRepo.Setup(x => x.GetAsync(nalogIzBaze.Id)).ReturnsAsync(nalogIzBaze); var fakeLogger = new Mock <ILogger <NalogObrisanHandler> >(); var evnt = new NalogObrisan(nalogIzBaze.Id) { UserId = Guid.NewGuid().ToString() }; var handler = new NalogObrisanHandler(fakeRepo.Object, fakeLogger.Object); await handler.Handle(evnt, default); fakeRepo.Verify(x => x.Remove(nalogIzBaze)); }
public void Remove(NalogForm nalog) { context.NaloziForm.Remove(nalog); }
public void Add(NalogForm nalog) { context.NaloziForm.Add(nalog); }