public async Task UpdateCustomAttribute_Should_Update_Custom_Attribute_With_Specified_Values()
        {
            var attribute      = CustomAttribute.Create("attribute", "number");
            var repositoryMock = new Mock <Repository.IRepository>();

            repositoryMock.Setup(r => r.GetByKeyAsync <CustomAttribute>(It.IsAny <Guid>()))
            .Returns(Task.FromResult(attribute));

            Repository.IRepository        repository = repositoryMock.Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            Guid   attributeId          = attribute.Id;
            string name                 = "Size";
            string type                 = "string";
            string description          = "size description";
            string unitOfMeasure        = "unit";
            IEnumerable <object> values = new[] { "XS", "S", "M", "L", "XL" };

            var commands = new CustomAttributeCommands(repository, eventBus);
            await commands.UpdateCustomAttribute(attributeId, name, type, description, unitOfMeasure, values);

            Assert.Equal(name, attribute.Name);
            Assert.Equal(type, attribute.DataType);
            Assert.Equal(description, attribute.Description);
            Assert.Equal(unitOfMeasure, attribute.UnitOfMeasure);
            Assert.Equal(values, attribute.Values);
        }
        public async Task CreateNewCustomAttribute_Should_Create_A_New_Custom_Attribute_And_Return_The_Created_Attribute_Id()
        {
            var fakeCustomAttributeList = new List <CustomAttribute>();
            var repositoryMock          = new Mock <Repository.IRepository>();

            repositoryMock.Setup(r => r.Add(It.IsAny <CustomAttribute>()))
            .Callback <CustomAttribute>((attribute) => fakeCustomAttributeList.Add(attribute));

            Repository.IRepository        repository = repositoryMock.Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            string name                 = "Size";
            string type                 = "string";
            string description          = "size description";
            string unitOfMeasure        = "unit";
            IEnumerable <object> values = new[] { "XS", "S", "M", "L", "XL" };

            var commands    = new CustomAttributeCommands(repository, eventBus);
            var attributeId = await commands.CreateNewCustomAttribute(name, type, description, unitOfMeasure, values);

            var createdAttribute = fakeCustomAttributeList.FirstOrDefault(a => a.Id == attributeId);

            Assert.Equal(name, createdAttribute.Name);
            Assert.Equal(type, createdAttribute.DataType);
            Assert.Equal(description, createdAttribute.Description);
            Assert.Equal(unitOfMeasure, createdAttribute.UnitOfMeasure);
            Assert.Equal(values, createdAttribute.Values);
        }
        public async Task RestoreCustomAttribute_Should_Throw_ArgumentException_If_AttributeId_Is_Empty()
        {
            Repository.IRepository        repository = new Mock <Repository.IRepository>().Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            Guid attributeId = Guid.Empty;

            var commands = new CustomAttributeCommands(repository, eventBus);

            var ex = await Assert.ThrowsAsync <ArgumentException>(() => commands.RestoreCustomAttribute(attributeId));

            Assert.Equal(nameof(attributeId), ex.ParamName);
        }
        public async Task UpdateCustomAttribute_Should_Throw_ArgumentException_If_AttributeId_Is_Empty()
        {
            Repository.IRepository        repository = new Mock <Repository.IRepository>().Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            Guid   attributeId          = Guid.Empty;
            string name                 = "Size";
            string type                 = "string";
            string description          = "size description";
            string unitOfMeasure        = "unit";
            IEnumerable <object> values = new[] { "XS", "S", "M", "L", "XL" };

            var commands = new CustomAttributeCommands(repository, eventBus);

            var ex = await Assert.ThrowsAsync <ArgumentException>(() => commands.UpdateCustomAttribute(attributeId, name, type, description, unitOfMeasure, values));

            Assert.Equal(nameof(attributeId), ex.ParamName);
        }
        public async Task DeleteCustomAttribute_Should_Mark_CustomAttribute_As_Deleted()
        {
            var attribute      = CustomAttribute.Create("attribute", "number");
            var repositoryMock = new Mock <Repository.IRepository>();

            repositoryMock.Setup(r => r.GetByKeyAsync <CustomAttribute>(It.IsAny <Guid>()))
            .Returns(Task.FromResult(attribute));

            Repository.IRepository        repository = repositoryMock.Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            Guid attributeId = attribute.Id;

            var commands = new CustomAttributeCommands(repository, eventBus);
            await commands.DeleteCustomAttribute(attributeId);

            Assert.True(attribute.Deleted);
        }