Beispiel #1
0
 public void CreateOrganizationWithNewAdmin(
     string organizationName,
     string userEmail,
     string password)
 {
     UsingTransaction(organizationName: organizationName, userEmail: userEmail, action: () =>
     {
         var user = userFactory.Create(new Email(userEmail), new Password(password), Role.Admin);
         userRepository.Add(user);                 // Save before organization creation to assign Id;
         var organization = organizationFactory.Create(organizationName, user);
         organizationRepository.Add(organization);
     });
 }
Beispiel #2
0
        public void ShouldThrowErrorIfUserNotAdmin()
        {
            OrganizationFactory organizationFactory = CreateOrganizationFactoryWithEmptyRepository();
            Action operation = () => organizationFactory.Create("name", userStub);

            Assert.Throws <DomainAssertionException>(operation);
        }
Beispiel #3
0
        public void ShouldThrowErrorIfNameUsed()
        {
            OrganizationFactory organizationFactory = CreateOrganizationFactoryWithBusyRepository();
            Action operation = () => organizationFactory.Create("name", adminStub);

            Assert.Throws <DomainAssertionException>(operation);
        }
Beispiel #4
0
        public void ShouldCreateOrganization()
        {
            OrganizationFactory organizationFactory = CreateOrganizationFactoryWithEmptyRepository();
            var organization = organizationFactory.Create("name", adminStub);

            Assert.IsType <Organization>(organization);
        }