public async Task SetCategorySeoData_Should_Throw_ArgumentException_If_CategoryId_Is_Empty() { Repository.IRepository repository = new Mock <Repository.IRepository>().Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid categoryId = Guid.Empty; SeoData seo = new SeoData { Title = "title", Description = "description" }; var commands = new CategoryCommands(repository, eventBus); var ex = await Assert.ThrowsAsync <ArgumentException>(() => commands.SetCategorySeoData(categoryId, seo)); Assert.Equal(nameof(categoryId), ex.ParamName); }
public async Task SetCategorySeoData_Should_Set_The_Seo_Data_With_The_Specified_Values() { var category = Category.Create("code", "name", "url"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Category>(It.IsAny <Guid>())) .Returns(Task.FromResult(category)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid categoryId = category.Id; SeoData seo = new SeoData { Title = "title", Description = "description" }; var commands = new CategoryCommands(repository, eventBus); await commands.SetCategorySeoData(categoryId, seo); Assert.Equal(seo.Title, category.Seo.Title); Assert.Equal(seo.Description, category.Seo.Description); }