示例#1
0
        public void Should_Have_Validation_Error_When_Invalid_Password_Command()
        {
            var notificationHandler = ServiceProvider.GetRequiredService <INotificationHandler>();
            var command             = AddEmployeeCommandMock.GetInvalidPasswordDto();

            //call
            command.IsValid();

            //assert
            Assert.DoesNotContain(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidEmployeeName);
            Assert.DoesNotContain(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidEmployeeEmail);
            Assert.Contains(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidEmployeePassword);
        }
示例#2
0
        public async Task Should_AddEmployee()
        {
            //parameters
            var command = AddEmployeeCommandMock.GetValidDto();

            //call
            var handler = GetEmployeeHandler();

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

            //assert
            Assert.NotNull(result);
            Assert.False(_notificationHandler.HasNotification());
            Assert.Equal(command.Name, result.Name);
            Assert.Equal(command.Email, result.Email);
        }
示例#3
0
        public async Task Should_Raise_Notification_When_Command_Is_Invalid()
        {
            //parameters
            var command = AddEmployeeCommandMock.GetInvalidDto();

            //call
            var handler = GetEmployeeHandler();

            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.InvalidEmployeeName);
            Assert.Contains(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidEmployeeEmail);
            Assert.Contains(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidEmployeePassword);
        }