public void ShouldHaveInstructionNotFoundCustomFailureWhenIdIsGuidEmpty() { // Arrange var id = Guid.Empty; var name = "name"; var description = "description"; var icon = "icon Url"; IEnumerable <string> tags = new List <string>() { "tag1", "tag2" }; var content = "content"; var image = "image"; var video = "video"; var version = 0; var command = new UpdateInstructionCommand(id, name, description, icon, tags, content, image, video, version); // Act var validationResult = _validator.Validate(command); var exists = validationResult.Errors.Any( a => a.PropertyName.Equals("Id") && a.ErrorMessage.Contains(CustomFailures.InstructionNotFound)); // Assert exists.Should().BeTrue(); }
public void ShouldHaveInstructionNameCannotStartOrEndWithWhiteSpaceValidationErrorWhenNameStartsOrEndsWithWhiteSpace(string symbols) { // Arrange var id = Guid.NewGuid(); var name = symbols; var description = "description"; var icon = "icon Url"; IEnumerable <string> tags = new List <string>() { "tag1", "tag2" }; var content = "content"; var image = "image"; var video = "video"; var version = 0; var command = new UpdateInstructionCommand(id, name, description, icon, tags, content, image, video, version); // Act var validationResult = _validator.Validate(command); var exists = validationResult.Errors.Any(a => a.PropertyName.Equals("Name") && a.ErrorMessage.Contains(ValidationFailures.InstructionNameCannotStartOrEndWithWhiteSpace)); // Assert exists.Should().BeTrue(); }
public void ShouldContainNoErrors() { // Arrange var id = Guid.NewGuid(); var name = "name"; var description = "description"; var icon = "icon Url"; IEnumerable <string> tags = new List <string>() { "tag1", "tag2" }; var content = "content"; var image = "image"; var video = "video"; var version = 0; var command = new UpdateInstructionCommand(id, name, description, icon, tags, content, image, video, version); // Act var validationResult = _validator.Validate(command); var exists = validationResult.Errors.Count > 0; // Assert exists.Should().BeFalse(); }
public void ShouldHaveInstructionTagMandatoryValidationFailureWhenTagsContainsWhiteSpaceValue() { // Arrange var id = Guid.NewGuid(); var name = "name"; var description = "description"; var icon = "icon Url"; IEnumerable <string> tags = new List <string>() { "tag1", " ", "tag2" }; var content = "content"; var image = "image"; var video = "video"; var version = 0; var command = new UpdateInstructionCommand(id, name, description, icon, tags, content, image, video, version); // Act var validationResult = _validator.Validate(command); var exists = validationResult.Errors.Any( a => a.PropertyName.Contains("Tags[1]") && a.ErrorMessage.Contains(ValidationFailures.InstructionTagMandatory)); // Assert exists.Should().BeTrue(); }
public async override Task <string> Handle(UpdateInstructionCommand request, CancellationToken cancellationToken) { Entity = repo.Find(request.ID); if (Entity == null) { throw new InvalidOperationException($"Can't Update Because Not find Entity {request} with Id : {request.ID}"); } Entity.Description = request.Description; Entity.ImageUrl = request.ImageUrl; Entity.Step = request.Step; Result = repo.Update(Entity); return(Result); }