Beispiel #1
0
        public void TaskSuccessTest()
        {
            var sendUserInvitationTask   = new SendUserInvitation(DbContext, new DummyEmailService(), new HtmlService(), new TokenService(), new GetInstallation(DbContext));
            var testUserInvitation       = TestsModel.UserInvitation;
            var sendUserInvitationResult = sendUserInvitationTask.DoTask(testUserInvitation);

            Assert.IsTrue(sendUserInvitationResult.Success);
            Assert.IsNull(sendUserInvitationResult.Exception);
            Assert.AreNotEqual(sendUserInvitationResult.Data, Guid.Empty);

            var userInvitationId      = sendUserInvitationResult.Data;
            var getUserInvitationTask = new GetUserInvitation(DbContext);
            var userInvitation        = getUserInvitationTask.DoTask(userInvitationId)?.Data;

            Assert.IsNotNull(userInvitation);
            Assert.AreEqual(testUserInvitation.InvitedByUserId, userInvitation.InvitedByUserId);
            Assert.AreEqual(testUserInvitation.Type, userInvitation.Type);
            Assert.AreEqual(testUserInvitation.Email, userInvitation.Email);
            Assert.IsNotNull(userInvitation.SentOn);

            userInvitation.CreatedUser = TestsModel.User;
            userInvitation.CreatedUser.AuthenticationId = userInvitation.CreatedUser.Person.Email = null;
            userInvitation.CreatedUser.Type             = UserType.Unassigned;

            var task = new AcceptUserInvitation(DbContext, new DummyEmailService(), new HtmlService(), new TokenService(),
                                                new AddPerson(DbContext, new FormattingService()), new AddArtistMember(DbContext), new AddArtistManager(DbContext), new GetInstallation(DbContext));
            var result = task.DoTask(userInvitation);

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

            var newUser = result.Data;

            Assert.AreEqual(userInvitation.Email, newUser.AuthenticationId);
            Assert.AreEqual(userInvitation.Type, newUser.Type);
            Assert.AreEqual(userInvitation.CreatedUser.Person.FirstName, newUser.Person.FirstName);
            Assert.AreEqual(userInvitation.CreatedUser.Person.MiddleName, newUser.Person.MiddleName);
            Assert.AreEqual(userInvitation.CreatedUser.Person.LastName, newUser.Person.LastName);
            Assert.AreEqual(userInvitation.CreatedUser.Person.NameSuffix, newUser.Person.NameSuffix);
            Assert.AreEqual(userInvitation.CreatedUser.Person.Email, newUser.Person.Email);
            Assert.AreEqual(userInvitation.CreatedUser.Person.Phone, newUser.Person.Phone);
            Assert.AreEqual(userInvitation.CreatedUser.Person.Address.Street, newUser.Person.Address.Street);
            Assert.AreEqual(userInvitation.CreatedUser.Person.Address.City, newUser.Person.Address.City);
            Assert.AreEqual(userInvitation.CreatedUser.Person.Address.Region, newUser.Person.Address.Region);
            Assert.AreEqual(userInvitation.CreatedUser.Person.Address.Country.Name, newUser.Person.Address.Country.Name);
            Assert.AreEqual(userInvitation.CreatedUser.Person.Address.Country.IsoCode, newUser.Person.Address.Country.IsoCode);
        }
Beispiel #2
0
        public void TaskSuccessTest()
        {
            var task = new SendUserInvitation(DbContext, new DummyEmailService(), new HtmlService(), new TokenService(), new GetInstallation(DbContext));
            var testUserInvitation = TestsModel.UserInvitation;
            var result             = task.DoTask(testUserInvitation);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);
            Assert.AreNotEqual(result.Data, Guid.Empty);

            var userInvitationId      = result.Data;
            var getUserInvitationTask = new GetUserInvitation(DbContext);
            var userInvitation        = getUserInvitationTask.DoTask(userInvitationId)?.Data;

            Assert.IsNotNull(userInvitation);
            Assert.AreEqual(testUserInvitation.InvitedByUserId, userInvitation.InvitedByUserId);
            Assert.AreEqual(testUserInvitation.Type, userInvitation.Type);
            Assert.AreEqual(testUserInvitation.Email, userInvitation.Email);
            Assert.IsNotNull(userInvitation.SentOn);

            if (userInvitation.Publisher != null)
            {
                Assert.AreEqual(testUserInvitation.Publisher.Name, userInvitation.Publisher.Name);
                Assert.IsNotNull(userInvitation.Publisher.Address);
                Assert.AreEqual(testUserInvitation.Publisher.Address.Street, userInvitation.Publisher.Address.Street);
                Assert.AreEqual(testUserInvitation.Publisher.Address.City, userInvitation.Publisher.Address.City);
                Assert.AreEqual(testUserInvitation.Publisher.Address.Region, userInvitation.Publisher.Address.Region);
                Assert.AreEqual(testUserInvitation.Publisher.Address.PostalCode, userInvitation.Publisher.Address.PostalCode);
                Assert.IsNotNull(userInvitation.Publisher.Address.Country);
                Assert.AreEqual(testUserInvitation.Publisher.Address.Country.Name, userInvitation.Publisher.Address.Country.Name);
                Assert.AreEqual(testUserInvitation.Publisher.Address.Country.IsoCode, userInvitation.Publisher.Address.Country.IsoCode);
            }

            if (userInvitation.RecordLabel != null)
            {
                Assert.AreEqual(testUserInvitation.RecordLabel.Name, userInvitation.RecordLabel.Name);
                Assert.IsNotNull(userInvitation.RecordLabel.Address);
                Assert.AreEqual(testUserInvitation.RecordLabel.Address.Street, userInvitation.RecordLabel.Address.Street);
                Assert.AreEqual(testUserInvitation.RecordLabel.Address.City, userInvitation.RecordLabel.Address.City);
                Assert.AreEqual(testUserInvitation.RecordLabel.Address.Region, userInvitation.RecordLabel.Address.Region);
                Assert.AreEqual(testUserInvitation.RecordLabel.Address.PostalCode, userInvitation.RecordLabel.Address.PostalCode);
                Assert.IsNotNull(userInvitation.RecordLabel.Address.Country);
                Assert.AreEqual(testUserInvitation.RecordLabel.Address.Country.Name, userInvitation.RecordLabel.Address.Country.Name);
                Assert.AreEqual(testUserInvitation.RecordLabel.Address.Country.IsoCode, userInvitation.RecordLabel.Address.Country.IsoCode);
            }
            if (userInvitation.Artist != null)
            {
                Assert.AreEqual(testUserInvitation.Artist.Name, userInvitation.Artist.Name);
                Assert.AreEqual(testUserInvitation.Artist.TaxId, userInvitation.Artist.TaxId);
                Assert.AreEqual(testUserInvitation.Artist.HasServiceMark, userInvitation.Artist.HasServiceMark);
                Assert.AreEqual(testUserInvitation.Artist.WebsiteUrl, userInvitation.Artist.WebsiteUrl);
                Assert.AreEqual(testUserInvitation.Artist.PressKitUrl, userInvitation.Artist.PressKitUrl);
            }

            var resendUserInvitationTask = new ResendUserInvitation(DbContext, new DummyEmailService(), new HtmlService(), new TokenService(), new GetInstallation(DbContext));
            var resendResults            = resendUserInvitationTask.DoTask(testUserInvitation.Uuid);

            Assert.IsTrue(resendResults.Success);
            var resentInvitation = resendResults.Data;

            Assert.IsTrue(resentInvitation.SentOn > testUserInvitation.SentOn);

            var removeUserInvitationTask = new RemoveUserInvitation(DbContext);
            var removed = removeUserInvitationTask.DoTask(testUserInvitation.Uuid).Success;

            Assert.IsTrue(removed);
        }