public async Task Create_Category_Command_Should_Create_Entity() { var user = new User(Guid.NewGuid(), "*****@*****.**"); await _dbFixture.InsertAsync(user); var command = new CreateCategory(Guid.NewGuid(), "Category 1", user.Id); var creationTask = await _rabbitMqFixture.SubscribeAndGetAsync <CategoryCreated, Category>(_dbFixture.GetEntityTask, command.Id); await _rabbitMqFixture.PublishAsync(command); var createdEntity = await creationTask.Task; createdEntity.Id.ShouldBe(command.Id); createdEntity.Name.ShouldBe(command.Name); createdEntity.Creator.ShouldBe(command.UserId); createdEntity.CreatedAt.ShouldNotBeNull(); }
public async Task AddPlayerShouldCreateDbEntity() { var externalId = Guid.NewGuid().ToString(); var command = new AddPlayer() { ExternalId = externalId, FirstName = "Test FirstName", LastName = "Test LastName" }; var creationTask = await _rabbitMqFixture.SubscribeAndGetAsync <PlayerAdded>( _testDbFixture.GetPlayerByExternalId, externalId); await _rabbitMqFixture.PublishAsync(command); Player player = await creationTask.Task; player.FirstName.Should().Be(command.FirstName); player.LastName.Should().Be(command.LastName); player.ExternalId.Should().Be(command.ExternalId); }
public async Task CreateLeagueShouldCreateDbEntity() { var command = new CreateLeague { Name = "Test league name", Description = "Test league descr", LeagueType = new LeagueType { Name = "Hockey" } }; var creationTask = await _rabbitMqFixture.SubscribeAndGetAsync <LeagueCreated>( _testDbFixture.GetLeagueByName, command.Name); await _rabbitMqFixture.PublishAsync(command); League league = await creationTask.Task; league.Should().NotBeNull(); league.Name.Should().Be(command.Name); league.Description.Should().Be(command.Description); league.Type.Name.Should().Be(command.LeagueType.Name); }
public async Task TourForwardWithDateShouldCreateDbEntity() { string date = DateTime.UtcNow.AddDays(100).ToShortDateString(); int seasonId = 10; var command = new TourForward() { Date = date, SeasonId = seasonId }; var creationTask = await _rabbitMqFixture.SubscribeAndGetAsync <TourCreated>( _testDbFixture.GetTourByDate, date); await _rabbitMqFixture.PublishAsync(command); Tour tour = await creationTask.Task; tour.TourStatus.Should().Be(TourStatus.Planned); tour.SeasonId.Should().Be(seasonId); tour.GuestCount.Should().BeNull(); tour.HomeCount.Should().BeNull(); }
public async Task Create_Advert_Command_Should_Create_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 command = new CreateAdvert(Guid.NewGuid(), "Test title", advertDescription, user.Id, category.Id, null); var creationTask = await _rabbitMqFixture.SubscribeAndGetAsync <AdvertCreated, Advert>(_dbFixture.GetEntityTask, command.Id); await _rabbitMqFixture.PublishAsync(command); var createdEntity = await creationTask.Task; createdEntity.ShouldNotBeNull(); createdEntity.Id.ShouldBe(command.Id); createdEntity.Title.ShouldBe(command.Title); createdEntity.Description.ShouldBe(command.Description); createdEntity.Image.ShouldBe(command.Image); createdEntity.Creator.ShouldBe(user.Id); createdEntity.Category.ShouldBe(category.Id); }
public async Task Create_Discount_Command_Should_Create_MongoEntity() { var customerId = Guid.NewGuid(); await _mongoDbFixture.InsertAsync("Customers", new Customer(customerId, "*****@*****.**")); var command = new CreateDiscount(Guid.NewGuid(), customerId, "DISCOUNT", 10); var creationTask = await _rabbitMqFixture.SubscribeAndGetAsync <DiscountCreated>(_mongoDbFixture.GetMongoEntity, command.Id); await _rabbitMqFixture.PublishAsync(command); var createdMongoEntity = await creationTask.Task; createdMongoEntity.Id.ShouldBe(command.Id); createdMongoEntity.CustomerId.ShouldBe(command.CustomerId); createdMongoEntity.Code.ShouldBe(command.Code); createdMongoEntity.Percentage.ShouldBe(command.Percentage); }
public async Task Create_Category_Command_Should_Insert_NewData_And_Publish_CategoryCreatedEvent() { //Arrange var category = new Category(Guid.NewGuid(), "Testing Name", "Testing Desc"); await _mongoDbFixture.Repository.AddAsync(category); var command = new CategoryCreated(category.Id, category.Name, category.Description); //Act var creationTask = await _rabbitMqFixture.SubscribeAndGetAsync <CategoryCreated, Category>(_mongoDbFixture.GetMongoEntity, command.Id); await _rabbitMqFixture.PublishAsync(command); var createdCategoryMessage = await creationTask.Task; //Assert createdCategoryMessage.Id.Should().Be(command.Id); createdCategoryMessage.Name.Should().Be(command.Name); createdCategoryMessage.Description.Should().Be(command.Description); }