예제 #1
0
        public async Task NalogNePostoji_Greska()
        {
            var fakeRepo   = new Mock <INalogFormRepository>();
            var fakeLogger = new Mock <ILogger <NalogObrisanHandler> >();
            var evnt       = new NalogObrisan(Guid.NewGuid());
            var handler    = new NalogObrisanHandler(fakeRepo.Object, fakeLogger.Object);

            Func <Task> handle = async() => await handler.Handle(evnt, default);

            await Assert.ThrowsAsync <NalogNePostojiException>(handle);
        }
예제 #2
0
        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));
        }
예제 #3
0
        public async Task Handle_Korektno()
        {
            var nalogIzBaze = new NalogGlavnaKnjiga()
            {
                Id = Guid.NewGuid(),
            };
            var fakeRepo = new Mock <INalogGKRepository>();

            fakeRepo.Setup(x => x.GetAsync(nalogIzBaze.Id)).ReturnsAsync(nalogIzBaze);
            var fakeNotifications = new Mock <INotificationQueue>();
            var fakeLogger        = new Mock <ILogger <NalogObrisanHandler> >();
            var evnt = new NalogObrisan(nalogIzBaze.Id)
            {
                UserId = Guid.NewGuid().ToString()
            };
            var handler = new NalogObrisanHandler(fakeRepo.Object, fakeNotifications.Object, fakeLogger.Object);

            await handler.Handle(evnt, default);

            fakeRepo.Verify(x => x.Remove(nalogIzBaze));
            fakeNotifications.Verify(x => x.Add(It.Is <GlavnaKnjigaChanged>(n => n.UserId == evnt.UserId)));
        }
예제 #4
0
        public async Task Handle_Korektno()
        {
            var stavkeNaloga = new List <KarticaKonta>()
            {
                new KarticaKonta()
                {
                    IdKonto = 1, Saldo = 100, SaldoKumulativno = 100
                },
                new KarticaKonta()
                {
                    IdKonto = 2, Saldo = 500, SaldoKumulativno = 100
                },
                new KarticaKonta()
                {
                    IdKonto = 1, Saldo = 200, SaldoKumulativno = 400
                },
                new KarticaKonta()
                {
                    IdKonto = 2, Saldo = 300, SaldoKumulativno = 375
                },
            };
            var evnt              = new NalogObrisan(Guid.NewGuid());
            var fakeRepo          = new Mock <IKarticaKontaRepository>();
            var fakeNotifications = new Mock <INotificationQueue>();

            fakeRepo.Setup(x => x.GetStavkeNalogaAsync(evnt.IdNaloga)).ReturnsAsync(stavkeNaloga);
            var fakeLogger = new Mock <ILogger <NalogObrisanHandler> >();
            var handler    = new NalogObrisanHandler(fakeRepo.Object, fakeNotifications.Object, fakeLogger.Object);

            await handler.Handle(evnt, default);

            foreach (var item in stavkeNaloga)
            {
                fakeRepo.Verify(x => x.Remove(item));
            }
            fakeNotifications.Verify(x => x.Add(It.IsNotNull <KarticaKontaChanged>()));
        }