Ejemplo n.º 1
0
        public async Task <IActionResult> Delete(Guid id)
        {
            var command = new ArchiveAdvert(id, UserId);

            return(await SendAsync(command, resourceId : command.Id,
                                   resource : "categories"));
        }
Ejemplo n.º 2
0
        public async Task Archive_Advert_Command_Should_Archive_Entity()
        {
            var user = new User(Guid.NewGuid(), "*****@*****.**");
            await _dbFixture.InsertAsync(user);

            var category = new Category(Guid.NewGuid(), user.Id);
            await _dbFixture.InsertAsync(category);

            string advertDescription = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum bibendum purus et libero vulputate elementum.";
            var    advert            = new Advert(Guid.NewGuid(), "Test Advert Name", advertDescription, user.Id,
                                                  category.Id, null);
            await _dbFixture.InsertAsync(advert);

            var command     = new ArchiveAdvert(advert.Id, advert.Creator);
            var archiveTask = await _rabbitMqFixture.SubscribeAndGetAsync <AdvertArchived, Advert>(_dbFixture.GetEntityTask, command.Id);

            await _rabbitMqFixture.PublishAsync(command);

            var archivedEntity = await archiveTask.Task;

            archivedEntity.ShouldNotBeNull();
            archivedEntity.Id.ShouldBe(command.Id);
            archivedEntity.ArchivedAt.ShouldNotBeNull();
        }