示例#1
0
        public void Should_Have_Validation_Error_When_Invalid_Command()
        {
            var notificationHandler = ServiceProvider.GetRequiredService <INotificationHandler>();
            var command             = AddVoteCommandMock.GetInvalidDto();

            //call
            command.IsValid();

            //assert
            Assert.Contains(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidEmployeeId);
            Assert.Contains(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidTaskId);
            Assert.Contains(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidComment);
        }
示例#2
0
        public async Task Should_Raise_Notification_When_Command_Is_Invalid()
        {
            //parameters
            var command = AddVoteCommandMock.GetInvalidDto();

            //call
            var handler = GetVoteHandler();

            var result = await handler.Handle(command, new System.Threading.CancellationToken());

            //assert
            Assert.Null(result);
            Assert.True(_notificationHandler.HasNotification());
            Assert.Contains(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidEmployeeId);
            Assert.Contains(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidTaskId);
            Assert.Contains(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidComment);
        }