public async void ProductCreateEventHandlerTest(string name, string description, string expiration)
        {
            var fakeAplicationDbContext = DataBaseInMemory.GetContext();

            var fakeProductGetAllEventHandler = new ProductCreateEventHandler(fakeAplicationDbContext, MapperTest.CreateMapper());

            var result = await fakeProductGetAllEventHandler
                         .Handle(new ProductCreateCommand
            {
                Name        = name,
                Description = description,
                Expiration  = DateTime.Parse(expiration)
            }, new CancellationToken());

            Assert.True(result != null);
        }
        public async void ProductDeleteEventHandlerTest(string name, string description)
        {
            var fakeAplicationDbContext = DataBaseInMemory.GetContext();

            var fakeTracking = await fakeAplicationDbContext.AddAsync(new Domain.Product
            {
                Name        = name,
                Description = description,
                Expiration  = new DateTime(),
            });

            await fakeAplicationDbContext.SaveChangesAsync();

            var fakeProductDeleteEventHandler = new ProductDeleteEventHandler(fakeAplicationDbContext, MapperTest.CreateMapper());

            var fakeResult = await fakeProductDeleteEventHandler.Handle(new ProductDeleteCommand(fakeTracking.Entity.ProductId), new CancellationToken());

            Assert.True(fakeResult != null);
        }
Ejemplo n.º 3
0
        public async void ProductGetByIdEventHandlerTest()
        {
            var fakeAplicationDbContext = DataBaseInMemory.GetContext();

            var tracking = await fakeAplicationDbContext.AddAsync(new Domain.Product
            {
                Name        = "Coca Cola",
                Description = "1.5L",
                Expiration  = new DateTime()
            });

            await fakeAplicationDbContext.SaveChangesAsync();

            var fakeProductGetAllEventHandler = new ProductGetByIdEventHandler(fakeAplicationDbContext, MapperTest.CreateMapper());

            var result = await fakeProductGetAllEventHandler.Handle(new ProductGetByIdQuery(tracking.Entity.ProductId), new CancellationToken());

            Assert.True(result != null);
        }