Exemple #1
0
        public async Task Write(Employee employee)
        {
            var emailAlreadyExists = await EmployeeReader.Any(employee.Email.Address);

            if (emailAlreadyExists)
            {
                var notification = new Notification("Email already registred");
                NotificationStore.AddNotification(notification);

                return;
            }

            await EmployeeWriter.Write(employee);
        }
Exemple #2
0
        public async Task Any_When_EmailAddress_Exists_Should_Return_True(
            Employee employee)
        {
            var options = DbContextOptionsFactory.Create(nameof(Any_When_EmailAddress_Exists_Should_Return_True));

            using (var context = new EmployeeManagerContext(options))
            {
                context.Add(employee);
                await context.SaveChangesAsync();
            }

            using (var context = new EmployeeManagerContext(options))
            {
                var sut = new EmployeeReader(context);

                var actual = await sut.Any(employee.Email.Address);

                actual.Should().BeTrue();
            }
        }
Exemple #3
0
        public async Task Any_When_EmailAddress_Does_Not_Exist_Should_Return_False(
            Employee employee,
            string someEmployeeEmail)
        {
            var options = DbContextOptionsFactory.Create(nameof(Any_When_EmailAddress_Does_Not_Exist_Should_Return_False));

            using (var context = new EmployeeManagerContext(options))
            {
                context.Add(employee);
                await context.SaveChangesAsync();
            }

            using (var context = new EmployeeManagerContext(options))
            {
                var sut = new EmployeeReader(context);

                var actual = await sut.Any(someEmployeeEmail);

                actual.Should().BeFalse();
            }
        }