public async Task SetParentForCategory_Should_Throw_ArgumentException_If_ParentId_Is_Empty() { Repository.IRepository repository = new Mock <Repository.IRepository>().Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid categoryId = Guid.NewGuid(); Guid parentId = Guid.Empty; var commands = new CategoryCommands(repository, eventBus); var ex = await Assert.ThrowsAsync <ArgumentException>(() => commands.SetParentForCategory(categoryId, parentId)); Assert.Equal(nameof(parentId), ex.ParamName); }
public async Task SetParentForCategory_Should_Set_The_Parent_With_The_Specified_Value() { var category = Category.Create("code", "name", "url"); var parent = Category.Create("parent", "parent", "parent"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Category>(category.Id)) .Returns(Task.FromResult(category)); repositoryMock.Setup(r => r.GetByKeyAsync <Category>(parent.Id)) .Returns(Task.FromResult(parent)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid categoryId = category.Id; Guid parentId = parent.Id; var commands = new CategoryCommands(repository, eventBus); await commands.SetParentForCategory(categoryId, parentId); Assert.Equal(parent, category.Parent); }