コード例 #1
0
        public void TaskSuccessTest()
        {
            var testUser = TestsModel.User;

            testUser.Type = UserType.SystemUser;
            var addUserTask   = new AddUser(DbContext, new AddPerson(DbContext, new FormattingService()), new FormattingService());
            var addUserResult = addUserTask.DoTask(testUser);

            Assert.IsTrue(addUserResult.Success);
            Assert.IsNull(addUserResult.Exception);

            var task = new UpdateUser(DbContext, new UpdatePerson(DbContext, new FormattingService()), new AddPerson(DbContext, new FormattingService()), new FormattingService());

            UpdateUserModel(testUser);
            var result = task.DoTask(testUser);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);
            Assert.IsNull(result.Data);

            var getUserTask       = new GetUser(DbContext);
            var user              = getUserTask.DoTask(testUser.Id)?.Data;
            var formattingService = new FormattingService();

            Assert.IsNotNull(user);
            Assert.AreEqual(formattingService.FormatSocialSecurityNumber(testUser.SocialSecurityNumber), user.SocialSecurityNumber);
            Assert.AreEqual(testUser.PerformingRightsOrganizationId, user.PerformingRightsOrganizationId);
            Assert.AreEqual(testUser.PerformingRightsOrganizationMemberNumber, user.PerformingRightsOrganizationMemberNumber);
            Assert.AreEqual(testUser.SoundExchangeAccountNumber, user.SoundExchangeAccountNumber);
            Assert.AreEqual(testUser.PublisherId, user.PublisherId);
            Assert.AreEqual(testUser.RecordLabelId, user.RecordLabelId);
            Assert.IsNotNull(user.Person);
            Assert.AreEqual(testUser.Person.FirstName, user.Person.FirstName);
            Assert.AreEqual(testUser.Person.MiddleName, user.Person.MiddleName);
            Assert.AreEqual(testUser.Person.LastName, user.Person.LastName);
            Assert.AreEqual(testUser.Person.NameSuffix, user.Person.NameSuffix);
            Assert.AreEqual(formattingService.FormatPhoneNumber(testUser.Person.Phone), user.Person.Phone);
            Assert.AreEqual(testUser.Person.Email, user.Person.Email);
            Assert.IsNotNull(user.Person.Address);
            Assert.AreEqual(testUser.Person.Address.Street, user.Person.Address.Street);
            Assert.AreEqual(testUser.Person.Address.City, user.Person.Address.City);
            Assert.AreEqual(testUser.Person.Address.Region, user.Person.Address.Region);
            Assert.AreEqual(testUser.Person.Address.PostalCode, user.Person.Address.PostalCode);
            Assert.IsNotNull(user.Person.Address.Country);
            Assert.AreEqual(testUser.Person.Address.Country.Name, user.Person.Address.Country.Name);
            Assert.AreEqual(testUser.Person.Address.Country.IsoCode, user.Person.Address.Country.IsoCode);

            var person           = user.Person;
            var removeUserTask   = new RemoveUser(DbContext);
            var removeUserResult = removeUserTask.DoTask(user);

            Assert.IsTrue(removeUserResult.Success);
            Assert.IsNull(removeUserResult.Exception);

            var removePersonTask   = new RemovePerson(DbContext);
            var removePersonResult = removePersonTask.DoTask(person);

            Assert.IsTrue(removePersonResult.Success);
            Assert.IsNull(removePersonResult.Exception);
        }
コード例 #2
0
        public void TaskFailTest()
        {
            var task   = new AddUser(EmptyDbContext, new AddPerson(EmptyDbContext, new FormattingService()), new FormattingService());
            var result = task.DoTask(new User());

            Assert.IsFalse(result.Success);
            Assert.IsNotNull(result.Exception);
        }
コード例 #3
0
        public void TaskSuccessTest()
        {
            var task     = new AddUser(DbContext, new AddPerson(DbContext, new FormattingService()), new FormattingService());
            var testUser = TestsModel.User;
            var result   = task.DoTask(testUser);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);
            Assert.IsNotNull(result.Data);

            var userId = result.Data;

            Assert.IsNotNull(userId);
            Assert.IsTrue(userId > 0);

            var getUserTask       = new GetUser(DbContext);
            var user              = getUserTask.DoTask(userId.Value)?.Data;
            var formattingService = new FormattingService();

            Assert.IsNotNull(user);
            Assert.AreEqual(testUser.Type, user.Type);
            Assert.AreEqual(testUser.Roles, user.Roles);
            Assert.AreEqual(testUser.AuthenticationId, user.AuthenticationId);
            Assert.IsNotNull(testUser.Person);
            Assert.AreEqual(testUser.Person.FirstName, user.Person.FirstName);
            Assert.AreEqual(testUser.Person.MiddleName, user.Person.MiddleName);
            Assert.AreEqual(testUser.Person.LastName, user.Person.LastName);
            Assert.AreEqual(testUser.Person.NameSuffix, user.Person.NameSuffix);
            Assert.AreEqual(testUser.Person.Email, user.Person.Email);
            Assert.AreEqual(formattingService.FormatPhoneNumber(testUser.Person.Phone), user.Person.Phone);
            Assert.IsNotNull(testUser.Person.Address.Country);
            Assert.AreEqual(testUser.Person.Address.Country.Name, user.Person.Address.Country.Name);
            Assert.AreEqual(testUser.Person.Address.Country.IsoCode, user.Person.Address.Country.IsoCode);
            Assert.AreEqual(formattingService.FormatSocialSecurityNumber(testUser.SocialSecurityNumber), user.SocialSecurityNumber);
            if (testUser.PerformingRightsOrganization != null)
            {
                Assert.AreEqual(testUser.PerformingRightsOrganization.Name, user.PerformingRightsOrganization.Name);
                Assert.IsNotNull(testUser.PerformingRightsOrganization.Country);
                Assert.IsNotNull(testUser.PerformingRightsOrganization.Country.Name);
            }
            Assert.AreEqual(testUser.PerformingRightsOrganizationMemberNumber, user.PerformingRightsOrganizationMemberNumber);
            Assert.AreEqual(testUser.SoundExchangeAccountNumber, user.SoundExchangeAccountNumber);

            var person           = user.Person;
            var removeUserTask   = new RemoveUser(DbContext);
            var removeUserResult = removeUserTask.DoTask(user);

            Assert.IsTrue(removeUserResult.Success);
            Assert.IsNull(removeUserResult.Exception);

            var removePersonTask   = new RemovePerson(DbContext);
            var removePersonResult = removePersonTask.DoTask(person);

            Assert.IsTrue(removePersonResult.Success);
            Assert.IsNull(removePersonResult.Exception);
        }
コード例 #4
0
        public void TaskSuccessTest()
        {
            var startTime = DateTime.UtcNow;
            var testUser  = TestsModel.User;

            testUser.Type = UserType.LabelAdministrator;
            var addUserTask   = new AddUser(DbContext, new AddPerson(DbContext, new FormattingService()), new FormattingService());
            var addUserResult = addUserTask.DoTask(testUser);

            Assert.IsTrue(addUserResult.Success);
            Assert.IsNull(addUserResult.Exception);

            var task = new LoginUser(DbContext, new GetInstallation(DbContext),
                                     new SeedSystemData(new SeedInstallation(DbContext),
                                                        new SeedCountries(DbContext),
                                                        new SeedPerformingRightsOrganizations(DbContext, new SeedCountries(DbContext)),
                                                        new SeedServices(DbContext),
                                                        new SeedPlatforms(DbContext, new ListServices(DbContext), new AddPlatform(DbContext))));
            var login = new Login
            {
                AuthenticationId    = testUser.AuthenticationId,
                AuthenticationToken = TestsModel.AuthenticationToken,
                TokenExpiration     = DateTime.UtcNow.AddHours(1)
            };
            var result = task.DoTask(login);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);
            Assert.IsNotNull(result.Data);

            if (result.Data != null)
            {
                var user = result.Data.User;

                Assert.IsNotNull(user);
                Assert.AreEqual(login.AuthenticationToken, result.Data.AuthenticationToken);
                Assert.AreEqual(login.AuthenticationId, user.AuthenticationId);
                Assert.IsTrue(login.LoginAt > startTime);
                Assert.IsTrue(login.LoginAt < DateTime.UtcNow);

                Assert.AreEqual(testUser.Type, user.Type);
                Assert.AreEqual(testUser.Roles, user.Roles);

                Assert.IsNotNull(user.Person);
                Assert.AreEqual(testUser.Person.FirstAndLastName, user.Person.FirstAndLastName);
                Assert.AreEqual(testUser.Person.MiddleName, user.Person.MiddleName);
                Assert.AreEqual(testUser.Person.NameSuffix, user.Person.NameSuffix);
                Assert.AreEqual(testUser.Person.Email, user.Person.Email);
                Assert.AreEqual(testUser.Person.Phone, user.Person.Phone);
                Assert.IsNotNull(user.Person.Address);
                Assert.AreEqual(testUser.Person.Address.Street, user.Person.Address.Street);
                Assert.AreEqual(testUser.Person.Address.City, user.Person.Address.City);
                Assert.AreEqual(testUser.Person.Address.Region, user.Person.Address.Region);
                Assert.AreEqual(testUser.Person.Address.PostalCode, user.Person.Address.PostalCode);
                Assert.AreEqual(testUser.Person.Address.Street, user.Person.Address.Street);
                Assert.IsNotNull(user.Person.Address.Country);
                Assert.AreEqual(testUser.Person.Address.Country.Name, user.Person.Address.Country.Name);
                Assert.AreEqual(testUser.Person.Address.Country.IsoCode, user.Person.Address.Country.IsoCode);
            }

            var getLoginTask   = new GetLogin(DbContext);
            var getLoginResult = getLoginTask.DoTask(login.AuthenticationToken);

            Assert.IsTrue(getLoginResult.Success);
            Assert.IsNull(getLoginResult.Exception);
            Assert.IsNotNull(getLoginResult.Data);

            if (getLoginResult.Data != null)
            {
                var user = getLoginResult.Data.User;

                Assert.IsNotNull(user);
                Assert.AreEqual(login.AuthenticationToken, getLoginResult.Data.AuthenticationToken);
                Assert.AreEqual(login.AuthenticationId, user.AuthenticationId);
                Assert.IsTrue(login.LoginAt > startTime);
                Assert.IsTrue(login.LoginAt < DateTime.UtcNow);

                Assert.AreEqual(testUser.Type, user.Type);
                Assert.AreEqual(testUser.Roles, user.Roles);

                Assert.IsNotNull(user.Person);
                Assert.AreEqual(testUser.Person.FirstAndLastName, user.Person.FirstAndLastName);
                Assert.AreEqual(testUser.Person.MiddleName, user.Person.MiddleName);
                Assert.AreEqual(testUser.Person.NameSuffix, user.Person.NameSuffix);
                Assert.AreEqual(testUser.Person.Email, user.Person.Email);
                Assert.AreEqual(testUser.Person.Phone, user.Person.Phone);
                Assert.IsNotNull(user.Person.Address);
                Assert.AreEqual(testUser.Person.Address.Street, user.Person.Address.Street);
                Assert.AreEqual(testUser.Person.Address.City, user.Person.Address.City);
                Assert.AreEqual(testUser.Person.Address.Region, user.Person.Address.Region);
                Assert.AreEqual(testUser.Person.Address.PostalCode, user.Person.Address.PostalCode);
                Assert.AreEqual(testUser.Person.Address.Street, user.Person.Address.Street);
                Assert.IsNotNull(user.Person.Address.Country);
                Assert.AreEqual(testUser.Person.Address.Country.Name, user.Person.Address.Country.Name);
                Assert.AreEqual(testUser.Person.Address.Country.IsoCode, user.Person.Address.Country.IsoCode);
            }

            var person           = testUser.Person;
            var removeUserTask   = new RemoveUser(DbContext);
            var removeUserResult = removeUserTask.DoTask(testUser);

            Assert.IsTrue(removeUserResult.Success);
            Assert.IsNull(removeUserResult.Exception);

            var removePersonTask   = new RemovePerson(DbContext);
            var removePersonResult = removePersonTask.DoTask(person);

            Assert.IsTrue(removePersonResult.Success);
            Assert.IsNull(removePersonResult.Exception);
        }
コード例 #5
0
        public void TaskSuccessTest()
        {
            var addUserTask   = new AddUser(DbContext, new AddPerson(DbContext, new FormattingService()), new FormattingService());
            var testUser      = TestsModel.User;
            var addUserResult = addUserTask.DoTask(testUser);

            Assert.IsTrue(addUserResult.Success);
            Assert.IsNull(addUserResult.Exception);
            Assert.IsNotNull(addUserResult.Data);

            var userId = addUserResult.Data;

            Assert.IsNotNull(userId);
            Assert.IsTrue(userId > 0);

            var paymentService = new ListServices(DbContext).DoTask(null).Data.SingleOrDefault(s => s.Name.ToLower() == "payment");

            Assert.IsNotNull(paymentService);

            var allPlatforms     = new ListPlatforms(DbContext).DoTask(null).Data.ToList();
            var paymentPlatforms = new List <Platform>();

            foreach (var platform in allPlatforms)
            {
                paymentPlatforms.AddRange(from service in platform.Services where service.Id == paymentService.Id select platform);
            }

            var paymentPlatform = paymentPlatforms[new Random().Next(0, paymentPlatforms.Count)];

            var userAccount = new UserAccount
            {
                IsPreferred = true,
                Platform    = paymentPlatform,
                User        = testUser,
                Username    = "******" + DateTime.Now.Ticks
            };

            var task   = new AddUserAccount(DbContext);
            var result = task.DoTask(userAccount);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);
            Assert.IsNotNull(result.Data);

            var getUserAccountTask   = new GetUserAccount(DbContext);
            var getUserAccountResult = getUserAccountTask.DoTask(userAccount.Id);

            Assert.IsTrue(getUserAccountResult.Success);
            Assert.IsNull(getUserAccountResult.Exception);
            Assert.IsNotNull(getUserAccountResult.Data);

            Assert.AreEqual(userAccount.PlatformId, getUserAccountResult.Data.PlatformId);
            Assert.AreEqual(userAccount.UserId, getUserAccountResult.Data.UserId);
            Assert.AreEqual(userAccount.IsPreferred, getUserAccountResult.Data.IsPreferred);
            Assert.AreEqual(userAccount.Username, getUserAccountResult.Data.Username);

            var person           = testUser.Person;
            var removeUserTask   = new RemoveUser(DbContext);
            var removeUserResult = removeUserTask.DoTask(testUser);

            Assert.IsTrue(removeUserResult.Success);
            Assert.IsNull(removeUserResult.Exception);

            var removePersonTask   = new RemovePerson(DbContext);
            var removePersonResult = removePersonTask.DoTask(person);

            Assert.IsTrue(removePersonResult.Success);
            Assert.IsNull(removePersonResult.Exception);
        }
コード例 #6
0
        public void TaskSuccessTest()
        {
            var addUserTask     = new AddUser(DbContext, new AddPerson(DbContext, new FormattingService()), new FormattingService());
            var testArtistUser1 = TestsModel.User;

            testArtistUser1.Type  = UserType.SystemUser;
            testArtistUser1.Roles = SystemUserRoles.ArtistMember;
            var testArtistUser1Id = addUserTask.DoTask(testArtistUser1);

            Assert.IsTrue(testArtistUser1Id.Data.HasValue);
            addUserTask = new AddUser(DbContext, new AddPerson(DbContext, new FormattingService()), new FormattingService());
            var testArtistUser2 = TestsModel.User;

            testArtistUser2.Type  = UserType.SystemUser;
            testArtistUser1.Roles = SystemUserRoles.ArtistMember | SystemUserRoles.VisualArtist;
            var testArtistUser2Id = addUserTask.DoTask(testArtistUser2);

            Assert.IsTrue(testArtistUser2Id.Data.HasValue);
            addUserTask = new AddUser(DbContext, new AddPerson(DbContext, new FormattingService()), new FormattingService());
            var testManagerUser = TestsModel.User;

            testManagerUser.Roles = SystemUserRoles.ArtistManager;
            testManagerUser.Type  = UserType.SystemUser;
            var testManagerUserId = addUserTask.DoTask(testManagerUser);

            Assert.IsTrue(testManagerUserId.Data.HasValue);
            addUserTask = new AddUser(DbContext, new AddPerson(DbContext, new FormattingService()), new FormattingService());
            var testLabelUser = TestsModel.User;

            testLabelUser.Type = UserType.LabelAdministrator;
            var testLabelUserId = addUserTask.DoTask(testLabelUser);

            Assert.IsTrue(testLabelUserId.Data.HasValue);
            addUserTask = new AddUser(DbContext, new AddPerson(DbContext, new FormattingService()), new FormattingService());
            var testPublisherUser = TestsModel.User;

            testPublisherUser.Type = UserType.PublisherAdministrator;
            var testPublisherUserId = addUserTask.DoTask(testPublisherUser);

            Assert.IsTrue(testPublisherUserId.Data.HasValue);
            addUserTask = new AddUser(DbContext, new AddPerson(DbContext, new FormattingService()), new FormattingService());
            var testAdminUser   = TestsModel.User;
            var testAdminUserId = addUserTask.DoTask(testAdminUser);

            Assert.IsTrue(testAdminUserId.Data.HasValue);

            var task   = new ListUsers(DbContext);
            var result = task.DoTask(null);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);

            var users = result.Data;

            Assert.IsNotNull(users);
            Assert.IsTrue(users.Count >= 6);

            var user1 = users.SingleOrDefault(u => u.Id == testArtistUser1Id.Data.Value);

            Assert.IsNotNull(user1);
            Assert.AreEqual(testArtistUser1.Type, user1.Type);
            Assert.AreEqual(testArtistUser1.AuthenticationId, user1.AuthenticationId);
            Assert.AreEqual(testArtistUser1.SocialSecurityNumber, user1.SocialSecurityNumber);
            Assert.AreEqual(testArtistUser1.SoundExchangeAccountNumber, user1.SoundExchangeAccountNumber);
            Assert.IsNotNull(user1.Person);
            Assert.AreEqual(testArtistUser1.Person.FirstName, user1.Person.FirstName);
            Assert.AreEqual(testArtistUser1.Person.MiddleName, user1.Person.MiddleName);
            Assert.AreEqual(testArtistUser1.Person.LastName, user1.Person.LastName);
            Assert.AreEqual(testArtistUser1.Person.NameSuffix, user1.Person.NameSuffix);
            Assert.AreEqual(testArtistUser1.Person.Email, user1.Person.Email);
            Assert.AreEqual(testArtistUser1.Person.Phone, user1.Person.Phone);
            Assert.IsNotNull(user1.Person.Address);
            Assert.AreEqual(testArtistUser1.Person.Address.Street, user1.Person.Address.Street);
            Assert.AreEqual(testArtistUser1.Person.Address.City, user1.Person.Address.City);
            Assert.AreEqual(testArtistUser1.Person.Address.Region, user1.Person.Address.Region);
            Assert.AreEqual(testArtistUser1.Person.Address.PostalCode, user1.Person.Address.PostalCode);
            Assert.IsNotNull(user1.Person.Address.Country);
            Assert.AreEqual(testArtistUser1.Person.Address.Country.Name, user1.Person.Address.Country.Name);
            Assert.AreEqual(testArtistUser1.Person.Address.Country.IsoCode, user1.Person.Address.Country.IsoCode);
            Assert.AreEqual(testArtistUser1.PerformingRightsOrganizationId, user1.PerformingRightsOrganizationId);

            var user2 = users.SingleOrDefault(u => u.Id == testPublisherUserId.Data);

            Assert.IsNotNull(user2);
            Assert.AreEqual(testPublisherUser.Type, user2.Type);
            Assert.AreEqual(testPublisherUser.AuthenticationId, user2.AuthenticationId);
            Assert.AreEqual(testPublisherUser.SocialSecurityNumber, user2.SocialSecurityNumber);
            Assert.AreEqual(testPublisherUser.SoundExchangeAccountNumber, user2.SoundExchangeAccountNumber);
            Assert.IsNotNull(user2.Person);
            Assert.AreEqual(testPublisherUser.Person.FirstName, user2.Person.FirstName);
            Assert.AreEqual(testPublisherUser.Person.MiddleName, user2.Person.MiddleName);
            Assert.AreEqual(testPublisherUser.Person.LastName, user2.Person.LastName);
            Assert.AreEqual(testPublisherUser.Person.NameSuffix, user2.Person.NameSuffix);
            Assert.AreEqual(testPublisherUser.Person.Email, user2.Person.Email);
            Assert.AreEqual(testPublisherUser.Person.Phone, user2.Person.Phone);
            Assert.IsNotNull(user2.Person.Address);
            Assert.AreEqual(testPublisherUser.Person.Address.Street, user2.Person.Address.Street);
            Assert.AreEqual(testPublisherUser.Person.Address.City, user2.Person.Address.City);
            Assert.AreEqual(testPublisherUser.Person.Address.Region, user2.Person.Address.Region);
            Assert.AreEqual(testPublisherUser.Person.Address.PostalCode, user2.Person.Address.PostalCode);
            Assert.IsNotNull(user2.Person.Address.Country);
            Assert.AreEqual(testPublisherUser.Person.Address.Country.Name, user2.Person.Address.Country.Name);
            Assert.AreEqual(testPublisherUser.Person.Address.Country.IsoCode, user2.Person.Address.Country.IsoCode);
            Assert.AreEqual(testPublisherUser.PerformingRightsOrganizationId, user2.PerformingRightsOrganizationId);
            Assert.AreEqual(testPublisherUser.PublisherId, user2.PublisherId);

            var user3 = users.SingleOrDefault(u => u.Id == testLabelUserId.Data);

            Assert.IsNotNull(user3);
            Assert.AreEqual(testLabelUser.Type, user3.Type);
            Assert.AreEqual(testLabelUser.AuthenticationId, user3.AuthenticationId);
            Assert.AreEqual(testLabelUser.SocialSecurityNumber, user3.SocialSecurityNumber);
            Assert.AreEqual(testLabelUser.SoundExchangeAccountNumber, user3.SoundExchangeAccountNumber);
            Assert.IsNotNull(user3.Person);
            Assert.AreEqual(testLabelUser.Person.FirstName, user3.Person.FirstName);
            Assert.AreEqual(testLabelUser.Person.MiddleName, user3.Person.MiddleName);
            Assert.AreEqual(testLabelUser.Person.LastName, user3.Person.LastName);
            Assert.AreEqual(testLabelUser.Person.NameSuffix, user3.Person.NameSuffix);
            Assert.AreEqual(testLabelUser.Person.Email, user3.Person.Email);
            Assert.AreEqual(testLabelUser.Person.Phone, user3.Person.Phone);
            Assert.IsNotNull(user3.Person.Address);
            Assert.AreEqual(testLabelUser.Person.Address.Street, user3.Person.Address.Street);
            Assert.AreEqual(testLabelUser.Person.Address.City, user3.Person.Address.City);
            Assert.AreEqual(testLabelUser.Person.Address.Region, user3.Person.Address.Region);
            Assert.AreEqual(testLabelUser.Person.Address.PostalCode, user3.Person.Address.PostalCode);
            Assert.IsNotNull(user3.Person.Address.Country);
            Assert.AreEqual(testLabelUser.Person.Address.Country.Name, user3.Person.Address.Country.Name);
            Assert.AreEqual(testLabelUser.Person.Address.Country.IsoCode, user3.Person.Address.Country.IsoCode);
            Assert.AreEqual(testLabelUser.PerformingRightsOrganizationId, user3.PerformingRightsOrganizationId);
            Assert.AreEqual(testLabelUser.RecordLabelId, user3.RecordLabelId);

            result = task.DoTask(UserType.SystemUser);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);

            users = result.Data;
            Assert.IsNotNull(users);
            Assert.IsTrue(users.Count >= 2);

            user1 = users.SingleOrDefault(u => u.Id == testArtistUser1Id.Data.Value);
            Assert.IsNotNull(user1);
            Assert.AreEqual(testArtistUser1.Type, user1.Type);
            Assert.AreEqual(testArtistUser1.AuthenticationId, user1.AuthenticationId);
            Assert.AreEqual(testArtistUser1.SocialSecurityNumber, user1.SocialSecurityNumber);
            Assert.AreEqual(testArtistUser1.SoundExchangeAccountNumber, user1.SoundExchangeAccountNumber);
            Assert.IsNotNull(user1.Person);
            Assert.AreEqual(testArtistUser1.Person.FirstName, user1.Person.FirstName);
            Assert.AreEqual(testArtistUser1.Person.MiddleName, user1.Person.MiddleName);
            Assert.AreEqual(testArtistUser1.Person.LastName, user1.Person.LastName);
            Assert.AreEqual(testArtistUser1.Person.NameSuffix, user1.Person.NameSuffix);
            Assert.AreEqual(testArtistUser1.Person.Email, user1.Person.Email);
            Assert.AreEqual(testArtistUser1.Person.Phone, user1.Person.Phone);
            Assert.IsNotNull(user1.Person.Address);
            Assert.AreEqual(testArtistUser1.Person.Address.Street, user1.Person.Address.Street);
            Assert.AreEqual(testArtistUser1.Person.Address.City, user1.Person.Address.City);
            Assert.AreEqual(testArtistUser1.Person.Address.Region, user1.Person.Address.Region);
            Assert.AreEqual(testArtistUser1.Person.Address.PostalCode, user1.Person.Address.PostalCode);
            Assert.IsNotNull(user1.Person.Address.Country);
            Assert.AreEqual(testArtistUser1.Person.Address.Country.Name, user1.Person.Address.Country.Name);
            Assert.AreEqual(testArtistUser1.Person.Address.Country.IsoCode, user1.Person.Address.Country.IsoCode);
            Assert.AreEqual(testArtistUser1.PerformingRightsOrganizationId, user1.PerformingRightsOrganizationId);

            user2 = users.SingleOrDefault(u => u.Id == testArtistUser2Id.Data.Value);
            Assert.IsNotNull(user2);
            Assert.AreEqual(testArtistUser2.Type, user2.Type);
            Assert.AreEqual(testArtistUser2.AuthenticationId, user2.AuthenticationId);
            Assert.AreEqual(testArtistUser2.SocialSecurityNumber, user2.SocialSecurityNumber);
            Assert.AreEqual(testArtistUser2.SoundExchangeAccountNumber, user2.SoundExchangeAccountNumber);
            Assert.IsNotNull(user2.Person);
            Assert.AreEqual(testArtistUser2.Person.FirstName, user2.Person.FirstName);
            Assert.AreEqual(testArtistUser2.Person.MiddleName, user2.Person.MiddleName);
            Assert.AreEqual(testArtistUser2.Person.LastName, user2.Person.LastName);
            Assert.AreEqual(testArtistUser2.Person.NameSuffix, user2.Person.NameSuffix);
            Assert.AreEqual(testArtistUser2.Person.Email, user2.Person.Email);
            Assert.AreEqual(testArtistUser2.Person.Phone, user2.Person.Phone);
            Assert.IsNotNull(user2.Person.Address);
            Assert.AreEqual(testArtistUser2.Person.Address.Street, user2.Person.Address.Street);
            Assert.AreEqual(testArtistUser2.Person.Address.City, user2.Person.Address.City);
            Assert.AreEqual(testArtistUser2.Person.Address.Region, user2.Person.Address.Region);
            Assert.AreEqual(testArtistUser2.Person.Address.PostalCode, user2.Person.Address.PostalCode);
            Assert.IsNotNull(user2.Person.Address.Country);
            Assert.AreEqual(testArtistUser2.Person.Address.Country.Name, user2.Person.Address.Country.Name);
            Assert.AreEqual(testArtistUser2.Person.Address.Country.IsoCode, user2.Person.Address.Country.IsoCode);
            Assert.AreEqual(testArtistUser2.PerformingRightsOrganizationId, user2.PerformingRightsOrganizationId);
            Assert.AreEqual(testArtistUser2.PublisherId, user2.PublisherId);

            var person1 = testArtistUser1.Person;
            var person2 = testArtistUser2.Person;
            var person3 = testManagerUser.Person;
            var person4 = testLabelUser.Person;
            var person5 = testPublisherUser.Person;
            var person6 = testAdminUser.Person;

            var removeUserTask = new RemoveUser(DbContext);
            var removeResult1  = removeUserTask.DoTask(testArtistUser1);
            var removeResult2  = removeUserTask.DoTask(testArtistUser2);
            var removeResult3  = removeUserTask.DoTask(testManagerUser);
            var removeResult4  = removeUserTask.DoTask(testLabelUser);
            var removeResult5  = removeUserTask.DoTask(testPublisherUser);
            var removeResult6  = removeUserTask.DoTask(testAdminUser);

            Assert.IsTrue(removeResult1.Success);
            Assert.IsNull(removeResult1.Exception);

            Assert.IsTrue(removeResult2.Success);
            Assert.IsNull(removeResult2.Exception);

            Assert.IsTrue(removeResult3.Success);
            Assert.IsNull(removeResult3.Exception);

            Assert.IsTrue(removeResult4.Success);
            Assert.IsNull(removeResult4.Exception);

            Assert.IsTrue(removeResult5.Success);
            Assert.IsNull(removeResult5.Exception);

            Assert.IsTrue(removeResult6.Success);
            Assert.IsNull(removeResult6.Exception);

            var removePersonTask    = new RemovePerson(DbContext);
            var removePersonResult1 = removePersonTask.DoTask(person1);
            var removePersonResult2 = removePersonTask.DoTask(person2);
            var removePersonResult3 = removePersonTask.DoTask(person3);
            var removePersonResult4 = removePersonTask.DoTask(person4);
            var removePersonResult5 = removePersonTask.DoTask(person5);
            var removePersonResult6 = removePersonTask.DoTask(person6);

            Assert.IsTrue(removePersonResult1.Success);
            Assert.IsNull(removePersonResult1.Exception);

            Assert.IsTrue(removePersonResult2.Success);
            Assert.IsNull(removePersonResult2.Exception);

            Assert.IsTrue(removePersonResult3.Success);
            Assert.IsNull(removePersonResult3.Exception);

            Assert.IsTrue(removePersonResult4.Success);
            Assert.IsNull(removePersonResult4.Exception);

            Assert.IsTrue(removePersonResult5.Success);
            Assert.IsNull(removePersonResult5.Exception);

            Assert.IsTrue(removePersonResult6.Success);
            Assert.IsNull(removePersonResult6.Exception);
        }
コード例 #7
0
        public void TaskSuccessTest()
        {
            var addUserTask = new AddUser(DbContext, new AddPerson(DbContext, new FormattingService()), new FormattingService());
            var testUser    = TestsModel.User;
            var testUserId  = addUserTask.DoTask(testUser);

            Assert.IsTrue(testUserId.Data.HasValue);

            var task   = new GetUser(DbContext);
            var result = task.DoTask(testUserId.Data.Value);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);

            var user = result.Data;

            Assert.IsNotNull(user);
            Assert.AreEqual(testUser.AuthenticationId, user.AuthenticationId);
            Assert.AreEqual(testUser.SocialSecurityNumber, user.SocialSecurityNumber);
            Assert.AreEqual(testUser.SoundExchangeAccountNumber, user.SoundExchangeAccountNumber);
            Assert.IsNotNull(testUser.Person);
            Assert.AreEqual(testUser.Person.FirstName, user.Person.FirstName);
            Assert.AreEqual(testUser.Person.MiddleName, user.Person.MiddleName);
            Assert.AreEqual(testUser.Person.LastName, user.Person.LastName);
            Assert.AreEqual(testUser.Person.NameSuffix, user.Person.NameSuffix);
            Assert.AreEqual(testUser.Person.Email, user.Person.Email);
            Assert.AreEqual(testUser.Person.Phone, user.Person.Phone);
            Assert.IsNotNull(testUser.Person.Address);
            Assert.AreEqual(testUser.Person.Address.Street, user.Person.Address.Street);
            Assert.AreEqual(testUser.Person.Address.City, user.Person.Address.City);
            Assert.AreEqual(testUser.Person.Address.Region, user.Person.Address.Region);
            Assert.AreEqual(testUser.Person.Address.PostalCode, user.Person.Address.PostalCode);
            Assert.IsNotNull(testUser.Person.Address.Country);
            Assert.AreEqual(testUser.Person.Address.Country.Name, user.Person.Address.Country.Name);
            Assert.AreEqual(testUser.Person.Address.Country.IsoCode, user.Person.Address.Country.IsoCode);
            if (testUser.PerformingRightsOrganization != null)
            {
                Assert.AreEqual(testUser.PerformingRightsOrganization.Name, user.PerformingRightsOrganization.Name);
                Assert.IsNotNull(testUser.PerformingRightsOrganization.Country);
                Assert.AreEqual(testUser.PerformingRightsOrganization.Country.Name, user.PerformingRightsOrganization.Country.Name);
            }
            if (testUser.Publisher != null)
            {
                Assert.AreEqual(testUser.Publisher.Name, user.Publisher.Name);
                Assert.AreEqual(testUser.Publisher.TaxId, user.Publisher.TaxId);
                Assert.AreEqual(testUser.Publisher.Email, user.Publisher.Email);
                Assert.AreEqual(testUser.Publisher.Phone, user.Publisher.Phone);
                Assert.IsNotNull(testUser.Publisher.PerformingRightsOrganization);
                Assert.AreEqual(testUser.Publisher.PerformingRightsOrganization.Name, user.Publisher.PerformingRightsOrganization.Name);
                Assert.IsNotNull(testUser.Publisher.PerformingRightsOrganization.Country);
                Assert.AreEqual(testUser.Publisher.PerformingRightsOrganization.Country.Name, user.Publisher.PerformingRightsOrganization.Country.Name);
                Assert.IsNotNull(testUser.Publisher.Address);
                Assert.AreEqual(testUser.Publisher.Address.Street, user.Publisher.Address.Street);
                Assert.AreEqual(testUser.Publisher.Address.City, user.Publisher.Address.City);
                Assert.AreEqual(testUser.Publisher.Address.Region, user.Publisher.Address.Region);
                Assert.AreEqual(testUser.Publisher.Address.PostalCode, user.Publisher.Address.PostalCode);
                Assert.IsNotNull(testUser.Publisher.Address.Country);
                Assert.AreEqual(testUser.Publisher.Address.Country.Name, user.Publisher.Address.Country.Name);
                Assert.AreEqual(testUser.Publisher.Address.Country.IsoCode, user.Publisher.Address.Country.IsoCode);
            }
            if (testUser.RecordLabel != null)
            {
                Assert.AreEqual(testUser.RecordLabel.Name, user.RecordLabel.Name);
                Assert.AreEqual(testUser.RecordLabel.TaxId, user.RecordLabel.TaxId);
                Assert.AreEqual(testUser.RecordLabel.Email, user.RecordLabel.Email);
                Assert.AreEqual(testUser.RecordLabel.Phone, user.RecordLabel.Phone);
                Assert.IsNotNull(testUser.RecordLabel.Address);
                Assert.AreEqual(testUser.RecordLabel.Address.Street, user.RecordLabel.Address.Street);
                Assert.AreEqual(testUser.RecordLabel.Address.City, user.RecordLabel.Address.City);
                Assert.AreEqual(testUser.RecordLabel.Address.Region, user.RecordLabel.Address.Region);
                Assert.AreEqual(testUser.RecordLabel.Address.PostalCode, user.RecordLabel.Address.PostalCode);
                Assert.IsNotNull(testUser.RecordLabel.Address.Country);
                Assert.AreEqual(testUser.RecordLabel.Address.Country.Name, user.RecordLabel.Address.Country.Name);
                Assert.AreEqual(testUser.RecordLabel.Address.Country.IsoCode, user.RecordLabel.Address.Country.IsoCode);
            }

            var person         = user.Person;
            var removeUserTask = new RemoveUser(DbContext);
            var removeResult   = removeUserTask.DoTask(user);

            Assert.IsTrue(removeResult.Success);
            Assert.IsNull(removeResult.Exception);

            var removePersonTask   = new RemovePerson(DbContext);
            var removePersonResult = removePersonTask.DoTask(person);

            Assert.IsTrue(removePersonResult.Success);
            Assert.IsNull(removePersonResult.Exception);
        }