public ChangeCredentialsStatus ChangeEmail(IUserBasic userBasic, string newEmail) { if (!ValidationExpressions.IsValidEmail(newEmail)) { return(ChangeCredentialsStatus.EmailNotValid); } ChangeCredentialsStatus changeCredentialsStatus; try { using (IDataStoreContext dataStoreContext = this.DataStore.CreateContext()) changeCredentialsStatus = dataStoreContext.wm_Users_UpdateEmail(userBasic.UserId, newEmail); } catch (Exception ex) { _Log.Error("Error at Users_UpdateUserName", ex); throw new DataStoreException(ex, true); } if (changeCredentialsStatus == ChangeCredentialsStatus.Success) { _Log.InfoFormat("User {0} changed email from {1} to {2}.", userBasic.UserId, userBasic.Email, newEmail); userBasic.Email = newEmail; } return(changeCredentialsStatus); }
internal static Message Create(IDataStore dataStore, IApplicationSettings applicationSettings, IApplication application , IUserBasic author, MessageBoardThread messageBoardThread, Random random) { MessageManager manager = new MessageManager(dataStore); Message message = new Message( author , messageBoardThread , "Message Subject" + random.Next(1000000, 10000000) , "Message Body" + random.Next(1000000, 10000000)); message.MessageStatus = DebugUtility.GetRandomEnum <MessageStatus>(random); BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(message); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Assert.Greater(message.MessageId, 0); Message dsMessage = manager.GetMessage(message.MessageId); Assert.IsNotNull(dsMessage); return(dsMessage); }
private void Test_UserLocking_Valid(AccountStatus accountStatus) { IMembershipSettings membershipSettings = Workmate.Components.InstanceContainer.MembershipSettings; membershipSettings.MaxInvalidPasswordAttempts = 3; IApplicationSettings applicationSettings = Workmate.Components.InstanceContainer.ApplicationSettings; WorkmateRoleProvider roleProvider = new WorkmateRoleProvider(); WorkmateMembershipProvider membershipProvider = new WorkmateMembershipProvider(); string password = "******"; IUserBasic userBasic = CreateUser(applicationSettings, this.Application, this.DummyDataManager, roleProvider, membershipProvider, password, accountStatus); IUserBasic validatedUser; ValidateUserStatus validateUserStatus; for (int i = 0; i < membershipSettings.MaxInvalidPasswordAttempts; i++) { validateUserStatus = membershipProvider.ValidateUser(this.Application.ApplicationId, userBasic.UserName, "465", out validatedUser); Assert.AreEqual(ValidateUserStatus.WrongPassword, validateUserStatus); } // by the next attempt we expect the user to be locked validateUserStatus = membershipProvider.ValidateUser(this.Application.ApplicationId, userBasic.UserName, "123", out validatedUser); Assert.AreEqual(ValidateUserStatus.UserIsLockedOut, validateUserStatus); // test unlock Assert.IsTrue(membershipProvider.UnlockUser(userBasic.UserId)); userBasic = membershipProvider.GetUserBasic(userBasic.UserId, false); Assert.AreEqual(accountStatus, userBasic.AccountStatus); }
public void Test_CreateUpdateDeleteSystemProfileImageFile() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); SystemProfileImageManager manager = new SystemProfileImageManager(this.DataStore); SystemProfileImage record = Test_SystemProfileImages.CreateSystemProfileImage(this.DataStore, this.Application.ApplicationId, this.Random); SystemProfileImage recordToCompare; for (int i = 0; i < this.DefaultUpdateTestIterations; i++) { PopulateWithRandomValues(record, this.DummyDataManager, this.Random); recordToCompare = record; manager.Update(record); record = manager.GetSystemProfileImage(record.ImageId); string errors = string.Empty; // TODO (Roman): relax datetime comparisons Assert.IsTrue(DebugUtility.ArePropertyValuesEqual(record, recordToCompare, out errors), errors); Trace.WriteLine("Update test successfull."); } Delete(this.DataStore, record); }
public ChangePasswordStatus ResetPassword(int applicationId, IUserBasic userBasic, string newPassword) { string text = this.GenerateSalt(); ValidatePasswordStatus result = ValidatePasswordStatus.Valid; if (!this.IsPasswordValid(newPassword, text, out result)) { return((ChangePasswordStatus)result); } ChangePasswordStatus changePasswordStatus; try { using (IDataStoreContext dataStoreContext = this.DataStore.CreateContext()) { changePasswordStatus = dataStoreContext.wm_Users_SetPassword(userBasic.UserId, this.EncodePassword(newPassword, text, this.PasswordFormat), text, (byte)this.PasswordFormat) == 0 ? ChangePasswordStatus.NoRecordRowAffected : ChangePasswordStatus.Success; } } catch (Exception ex) { _Log.Error("Error at ResetPassword.Users_SetPassword", ex); throw new DataStoreException(ex, true); } if (changePasswordStatus == ChangePasswordStatus.Success) { _Log.InfoFormat("User {0} changed password", userBasic.UserId); } return(changePasswordStatus); }
public ChangeCredentialsStatus ChangeUserName(IUserBasic userBasic, string newUserName) { string userName = newUserName.RemoveMaliciousTags() .RemoveScriptTags() .RemoveMaliciousSQLCharacters() .DefuseScriptTags(); if (userName != newUserName) { return(ChangeCredentialsStatus.UserNameNotValid); } ChangeCredentialsStatus changeCredentialsStatus; try { using (IDataStoreContext dataStoreContext = this.DataStore.CreateContext()) changeCredentialsStatus = dataStoreContext.wm_Users_UpdateUserName(userBasic.UserId, newUserName); } catch (Exception ex) { _Log.Error("Error at Users_UpdateUserName", ex); throw new DataStoreException(ex, true); } if (changeCredentialsStatus == ChangeCredentialsStatus.Success) { _Log.InfoFormat("User {0} changed username from {1} to {2}.", userBasic.UserId, userBasic.UserName, newUserName); userBasic.UserName = newUserName; } return(changeCredentialsStatus); }
public void Test_ThreadRatingCaluclations() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); CMSSection section = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random); CMSThread thread = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random); CMSThreadRatingManager manager = new CMSThreadRatingManager(this.DataStore); for (int i = 0; i < 10; i++) { userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); CMSThreadRating record = new CMSThreadRating(userBasic, thread, (short)i); BusinessObjectActionReport <RatingDataRepositoryActionStatus> report = manager.Create(record); Assert.AreEqual(RatingDataRepositoryActionStatus.Success, report.Status); } CMSThreadManager threadManager = new CMSThreadManager(this.DataStore); thread = threadManager.GetThread(section.CMSSectionType, thread.CMSThreadId); Assert.AreEqual(10, thread.CMSTotalRatings); Assert.AreEqual(45, thread.CMSRatingSum); Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file }
private bool IsAuthorized(IPrincipal user, out IPrincipal authorizedUser) { bool isAuthorized = false; if (user != null && user.Identity.IsAuthenticated && user.Identity is System.Web.Security.FormsIdentity) { // we are authenticated, so let's check whether the cookie has the correct format WMUserPrincipal principal; try { principal = new WMUserPrincipal((FormsIdentity)user.Identity); authorizedUser = principal; } catch (Exception) { // this means we have a dodgy session cookie, so redirect authorizedUser = WMUserPrincipal.AnonymousInstance; return(false); } IWorkmateMembershipProvider provider = InstanceContainer.WorkmateMembershipProvider; if (principal.WMUserIdentity.LastRecordCheckUtc.AddSeconds(provider.LastRecordCheckWindowInSeconds) < DateTime.UtcNow) { IUserBasic userBasic = provider.GetUserBasic(principal.WMUserIdentity.UserId, true); if (userBasic != null) { this.UpdateAuthenticationCookie(userBasic); isAuthorized = true; } } else if (FormsAuthentication.SlidingExpiration) {// refresh the cookie if we have sliding expiration // check whether we should update the last activity date if (principal.WMUserIdentity.LastActivityUpdate.AddSeconds(provider.LastActivityUpdateWindowInSeconds) < DateTime.UtcNow) { // we have to update the lastactivity date... IUserBasic userBasic = provider.GetUserBasic(principal.WMUserIdentity.UserId, true); if (userBasic != null) { this.UpdateAuthenticationCookie(userBasic); isAuthorized = true; } } else { // refresh the cookie this.RefreshAuthenticationCookie(principal.WMUserIdentity); isAuthorized = true; } } } else { authorizedUser = WMUserPrincipal.AnonymousInstance; } return(isAuthorized); }
public void Test_CreateTempFileAndMove() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); CMSSection section = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random); CMSThread thread = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random); CMSContent content = Test_CMSContents.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random); CMSFileManager manager = new CMSFileManager(this.DataStore); ASCIIEncoding encoding = new ASCIIEncoding(); string contentString = "Some String " + this.Random.Next(1000000, 10000000); CMSFile tempFile = CreateTemporaryFile(this.DataStore, this.Application.ApplicationId, userBasic, encoding.GetBytes(contentString), this.Random); int fileId; manager.MoveTemporaryFileToFiles(tempFile.CMSFileId, content.CMSContentId, "FileName", "FriendlyFileName", null, out fileId); CMSFile file = manager.GetFile(fileId); Assert.IsNotNull(file); // TODO (Roman): do all the value asserts Assert.AreEqual(contentString, encoding.GetString(file.Content)); // TODO (Roman): check that tempFile doesn't exist any more Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file Assert.IsNull(manager.GetFile(file.CMSFileId)); }
public ActionResult Login(LoginDetailsModel loginDetailsModel) { if (ModelState.IsValid) { // do validation IUserBasic userBasic = null; ValidateUserStatus status = InstanceContainer.TicketManager.LogUserIn( this.RequestContextData.ApplicationThemeInfo.ApplicationId , loginDetailsModel.UserName , loginDetailsModel.Password , loginDetailsModel.RememberMe , out userBasic); if (status == ValidateUserStatus.Valid) { Response.Redirect(System.Web.Security.FormsAuthentication.GetRedirectUrl(userBasic.UserName, false)); return(null); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } return(View(loginDetailsModel)); }
public void Test_CreateUpdateDeleteThreadRating() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); CMSSection section = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random); CMSThread thread = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random); CMSThreadRatingManager manager = new CMSThreadRatingManager(this.DataStore); CMSThreadRating record = new CMSThreadRating(userBasic, thread, 1); BusinessObjectActionReport <RatingDataRepositoryActionStatus> report = manager.Create(record); Assert.AreEqual(RatingDataRepositoryActionStatus.Success, report.Status); CMSThreadRating recordToCompare; for (int i = 0; i < this.DefaultUpdateTestIterations; i++) { PopulateWithRandomValues(record, this.DummyDataManager, this.Random); recordToCompare = record; manager.Update(record); record = manager.GetThreadRating(thread, userBasic); string errors = string.Empty; // TODO (Roman): relax datetime comparisons Assert.IsTrue(DebugUtility.ArePropertyValuesEqual(record, recordToCompare, out errors), errors); Trace.WriteLine("Update test successfull."); } Delete(this.DataStore, thread, userBasic); Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file }
private void UploadWholeFile(HttpContext context, List <FilesStatus> statuses) { IUserBasic user = context.User.Identity as IUserBasic; HttpPostedFile httpPostedFile; for (int i = 0; i < context.Request.Files.Count; i++) { httpPostedFile = context.Request.Files[i]; ArticleAttachment articleAttachment = new ArticleAttachment(this.RequestContextData.ApplicationThemeInfo.ApplicationId, user); articleAttachment.Content = ReadStream(httpPostedFile.InputStream, httpPostedFile.ContentLength); articleAttachment.ContentSize = httpPostedFile.ContentLength; articleAttachment.ContentType = httpPostedFile.ContentType; articleAttachment.FileName = httpPostedFile.FileName; UrlHelper urlHelper = new UrlHelper(context.Request.RequestContext); string action = urlHelper.RouteUrl(MagicStrings.FormatRouteName( this.RequestContextData.ApplicationThemeInfo.ApplicationGroup, "Articles_FileUploadHandler")); var report = InstanceContainer.ArticleAttachmentManager.CreateTemporaryFile(articleAttachment); if (report.Status != Workmate.Components.Contracts.DataRepositoryActionStatus.Success) { // TODO (Roman): errorhandling statuses.Add(new FilesStatus(articleAttachment, report.Message, action)); } else { statuses.Add(new FilesStatus(articleAttachment, action)); } } }
public void Test_Gets() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); CMSSection section = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random); CMSThread thread = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random); List <CMSContent> records = new List <CMSContent>(); CMSContentManager manager = new CMSContentManager(this.DataStore); for (int i = 0; i < 10; i++) { records.Add(Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random)); } List <CMSContent> dsRecords = manager.GetContents(this.Application.ApplicationId, section.CMSSectionType); Assert.GreaterOrEqual(dsRecords.Count, records.Count); foreach (CMSContent record in records) { Assert.AreEqual(1, dsRecords.Count(c => c.CMSContentId == record.CMSContentId)); } foreach (CMSContent record in records) { Delete(this.DataStore, record); } Test_CMSSections.Delete(this.DataStore, section); }
public void Test_CreateUpdateDeleteContent() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); CMSSection section = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random); CMSThread thread = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random); CMSContentManager manager = new CMSContentManager(this.DataStore); CMSContent record = Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random); CMSContent recordToCompare; for (int i = 0; i < this.DefaultUpdateTestIterations; i++) { PopulateWithRandomValues(record, this.DummyDataManager, this.Random); recordToCompare = record; manager.Update(record); record = manager.GetContent(record.CMSContentId); string errors = string.Empty; // TODO (Roman): relax datetime comparisons Assert.IsTrue(DebugUtility.ArePropertyValuesEqual(record, recordToCompare, out errors), errors); Trace.WriteLine("Update test successfull."); } Delete(this.DataStore, record); Test_CMSSections.Delete(this.DataStore, section); }
public void Test_ResetPassword() { IMembershipSettings membershipSettings = Workmate.Components.InstanceContainer.MembershipSettings; IApplicationSettings applicationSettings = Workmate.Components.InstanceContainer.ApplicationSettings; WorkmateRoleProvider roleProvider = new WorkmateRoleProvider(); WorkmateMembershipProvider membershipProvider = new WorkmateMembershipProvider(); string password = "******"; string newPassword = "******"; IUserBasic userBasic = CreateUser(applicationSettings, this.Application, this.DummyDataManager, roleProvider, membershipProvider, password, AccountStatus.Valid); IUserBasic validatedUserBasic; ValidateUserStatus validateUserStatus = membershipProvider.ValidateUser(this.Application.ApplicationId, userBasic.Email, password, out validatedUserBasic); Assert.AreEqual(ValidateUserStatus.Valid, validateUserStatus); ChangePasswordStatus changePasswordStatus = membershipProvider.ResetPassword(this.Application.ApplicationId, userBasic, newPassword); Assert.AreEqual(ChangePasswordStatus.Success, changePasswordStatus); validateUserStatus = membershipProvider.ValidateUser(this.Application.ApplicationId, userBasic.Email, newPassword, out validatedUserBasic); Assert.AreEqual(ValidateUserStatus.Valid, validateUserStatus); }
public void Test_SendQueuedEmailPickup() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); EmailManager manager = new EmailManager(this.DataStore); IEmail record = Create(this.DataStore, this.Random, this.Application, userBasic, EmailPriority.SendImmediately, EmailStatus.Unsent); List <IEmail> emails; emails = manager.PutInSendQueue(int.MaxValue, int.MaxValue, 1); Assert.AreEqual(1, emails.Count); Assert.AreEqual(emails[0].EmailId, record.EmailId, "Please ensure that there are no unsent emails in the database"); Assert.AreEqual(EmailStatus.Queued, emails[0].Status); Assert.AreEqual(EmailStatus.Queued, manager.GetEmail(emails[0].EmailId).Status); record = manager.GetEmail(emails[0].EmailId); Thread.Sleep(100); emails = manager.PutInSendQueue(10000, int.MaxValue, 1); Assert.AreEqual(0, emails.Count); Thread.Sleep(100); emails = manager.PutInSendQueue(0, int.MaxValue, 1); Assert.AreEqual(1, emails.Count); Delete(this.DataStore, record); }
public void Test_CreateUpdateDeleteEmail() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); EmailManager manager = new EmailManager(this.DataStore); IEmail record = Create(this.DataStore, this.Random, this.Application, userBasic); Delete(this.DataStore, record); }
internal CMSFile(int applicationId, IUserBasic fileOwner, FileType fileType) { this.CMSUserId = fileOwner == null ? null : (int?)fileOwner.UserId; this.CMSFileType = fileType; this.ApplicationId = applicationId; this.IsTemporary = false; }
internal static void Delete(IDataStore dataStore, CMSContent content, IUserBasic userBasic) { CMSContentUserManager manager = new CMSContentUserManager(dataStore); BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Delete(new CMSContentUser(userBasic, content)); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Trace.WriteLine("Successfully deleted contentUser " + content.CMSContentId + " -> " + userBasic.UserId); }
public Message(IUserBasic author, MessageBoardThread messageBoardThread, string subject, string formattedBody, int?parentMessageId, short messageLevel) { this._CMSContent = new CMSContent(author.UserId, messageBoardThread.CMSThread, 0, 0, subject, formattedBody, true); this.MessageBoardThread = messageBoardThread; this.ParentMessageId = parentMessageId; this.MessageLevel = messageLevel; }
/// <summary> /// Updates the authentication cookie. /// </summary> /// <param name="userBasic">The user basic.</param> public void UpdateAuthenticationCookie(IUserBasic userBasic) { WMUserIdentity identity = WMUserIdentity.Create(userBasic, true, DateTime.UtcNow, DateTime.UtcNow); AuthenticationCookieManager.UpdateAuthenticationCookie <WMUserIdentity>( _WorkmateMembershipProvider.AuthenticationTimeoutInSeconds , _WorkmateMembershipProvider.PersistentAuthenticationTimeoutInSeconds , identity); }
public MessageRating GetMessageRating(Message message, IUserBasic userBasic) { CMSContentRating contentRating = _CMSContentRatingManager.GetContentRating(message.CMSContent, userBasic); if (contentRating != null) { return(new MessageRating(contentRating)); } return(null); }
/// <summary> /// Writes the authentication cookie. /// </summary> /// <param name="userBasic">The user basic.</param> /// <param name="rememberMe">if set to <c>true</c> [remember me].</param> public void WriteAuthenticationCookie(IUserBasic userBasic, bool rememberMe) { WMUserIdentity identity = WMUserIdentity.Create(userBasic, true, DateTime.UtcNow, DateTime.UtcNow); AuthenticationCookieManager.WriteAuthenticationCookie <WMUserIdentity>( userBasic.UserName , _WorkmateMembershipProvider.AuthenticationTimeoutInSeconds , _WorkmateMembershipProvider.PersistentAuthenticationTimeoutInSeconds , identity , rememberMe); }
public void Test_SendEmails() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); EmailManager manager = new EmailManager(this.DataStore); List <IEmail> highPriorityEmails = new List <IEmail>(); for (int i = 0; i < 3; i++) { highPriorityEmails.Add(Create(this.DataStore, this.Random, this.Application, userBasic, EmailPriority.SendImmediately, EmailStatus.Unsent)); } List <IEmail> lowPriorityEmails = new List <IEmail>(); for (int i = 0; i < 3; i++) { lowPriorityEmails.Add(Create(this.DataStore, this.Random, this.Application, userBasic, EmailPriority.CanWait, EmailStatus.Unsent)); } List <IEmail> emails; emails = manager.PutInSendQueue(int.MaxValue, int.MaxValue, 4); Assert.AreEqual(4, emails.Count); Assert.AreEqual(emails[0].EmailId, highPriorityEmails[0].EmailId); Assert.AreEqual(emails[1].EmailId, highPriorityEmails[1].EmailId); Assert.AreEqual(emails[2].EmailId, highPriorityEmails[2].EmailId); Assert.AreEqual(emails[3].EmailId, lowPriorityEmails[0].EmailId); for (int i = 0; i < 4; i++) { Assert.AreEqual(EmailStatus.Queued, emails[i].Status); Assert.AreEqual(EmailStatus.Queued, manager.GetEmail(emails[i].EmailId).Status); } manager.SetToSent(emails[0].EmailId, EmailStatus.Sent, emails[0].Priority); manager.SetToSent(emails[1].EmailId, EmailStatus.Sent, emails[1].Priority); manager.SetToSent(emails[2].EmailId, EmailStatus.Sent, emails[2].Priority); manager.SetToSent(emails[3].EmailId, EmailStatus.Sent, emails[3].Priority); emails = manager.PutInSendQueue(int.MaxValue, int.MaxValue, 4); Assert.AreEqual(2, emails.Count); Assert.AreEqual(emails[0].EmailId, lowPriorityEmails[1].EmailId); Assert.AreEqual(emails[1].EmailId, lowPriorityEmails[2].EmailId); foreach (IEmail email in highPriorityEmails) { Delete(this.DataStore, email); } foreach (IEmail email in lowPriorityEmails) { Delete(this.DataStore, email); } }
public void Test_UpdateContentBlock() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); ContentPlaceholderGroup contentPlaceholderGroup = Test_ContentPlaceholderGroup.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random); ContentPlaceholderManager manager = new ContentPlaceholderManager(this.DataStore); ContentBlockManager contentBlockManager = new ContentBlockManager(this.DataStore); string key = "test_content_block"; int contentBlockId; Dictionary <string, string> lookup; ContentUpdateStatus contentUpdateStatus = manager.UpdateContentBlock(this.Application.ApplicationId, userBasic , key, "Body1", out contentBlockId); // TODO (Roman): Html testing... Assert.AreEqual(ContentUpdateStatus.Success, contentUpdateStatus); Assert.Greater(contentBlockId, 0); ContentBlock contentBlock1 = contentBlockManager.GetContentBlock(contentBlockId); Assert.IsNotNull(contentBlock1); Assert.AreEqual(ContentBlockStatus.Active, contentBlock1.ContentBlockStatus); Assert.AreEqual("Body1", contentBlock1.FormattedBody); lookup = manager.GetContentPlaceholderBodies(this.Application.ApplicationId); Assert.IsNotNull(lookup); Assert.IsTrue(lookup.ContainsKey(key)); Assert.AreEqual(lookup[key], "Body1"); contentUpdateStatus = manager.UpdateContentBlock(this.Application.ApplicationId, userBasic , key, "Body2", out contentBlockId); Assert.AreEqual(ContentUpdateStatus.Success, contentUpdateStatus); Assert.Greater(contentBlockId, 0); ContentBlock contentBlock2 = contentBlockManager.GetContentBlock(contentBlockId); Assert.IsNotNull(contentBlock2); Assert.AreEqual(ContentBlockStatus.Active, contentBlock2.ContentBlockStatus); Assert.AreEqual("Body2", contentBlock2.FormattedBody); contentBlock1 = contentBlockManager.GetContentBlock(contentBlock1.ContentBlockId); Assert.IsNotNull(contentBlock1); Assert.AreEqual(ContentBlockStatus.Inactive, contentBlock1.ContentBlockStatus); Assert.AreEqual("Body1", contentBlock1.FormattedBody); lookup = manager.GetContentPlaceholderBodies(this.Application.ApplicationId); Assert.IsNotNull(lookup); Assert.IsTrue(lookup.ContainsKey(key)); Assert.AreEqual(lookup[key], "Body2"); }
public void Test_AssignNewProfileImage() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); ProfileImageManager manager = new ProfileImageManager(this.DataStore); ProfileImage record = Test_ProfileImages.CreateProfileImage(this.DataStore, this.Application.ApplicationId, userBasic, this.Random); ProfileImage record2 = Test_ProfileImages.CreateProfileImage(this.DataStore, this.Application.ApplicationId, userBasic, this.Random); Assert.IsNull(manager.GetProfileImage(record.ImageId)); Delete(this.DataStore, record2); }
internal static void Delete(IDataStore dataStore, CMSThread thread, IUserBasic userBasic) { CMSThreadRatingManager manager = new CMSThreadRatingManager(dataStore); CMSThreadRating threadRating = manager.GetThreadRating(thread, userBasic); BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Delete(threadRating); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Assert.IsNull(manager.GetThreadRating(thread, userBasic)); Trace.WriteLine("Successfully deleted threadRating " + threadRating.CMSThreadId + " -> " + threadRating.CMSUserId); }
public PrivateMessage(IUserBasic author, Folder folder, MessageStatus messageStatus, MessageType messageType, string subject, string formattedBody) { this._CMSContent = new CMSContent( author.UserId , folder.CMSThread , (byte)messageStatus , (byte)messageType , subject , formattedBody , true); this.Folder = folder; }
public void Test_CreateUpdateDeleteContentBlock() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); ContentPlaceholderGroup contentPlaceholderGroup = Test_ContentPlaceholderGroup.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random); ContentPlaceholder contentPlaceholder = Test_ContentPlaceholders.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, contentPlaceholderGroup, this.Random); ContentPlaceholderHistory contentPlaceholderHistory = Test_ContentPlaceholderHistorys.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, contentPlaceholder, this.Random); ContentBlockManager manager = new ContentBlockManager(this.DataStore); ContentBlock record = Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic, contentPlaceholderHistory, this.Random); Delete(this.DataStore, record); Test_ContentPlaceholders.Delete(this.DataStore, contentPlaceholder); Test_ContentPlaceholderGroup.Delete(this.DataStore, contentPlaceholderGroup); }
public void Test_Delete_Section() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); CMSSection section = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random); CMSThread thread = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random); CMSContent content = Test_CMSContents.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random); Test_CMSSections.Delete(this.DataStore, section); CMSThreadManager threadManager = new CMSThreadManager(this.DataStore); CMSContentManager contentManager = new CMSContentManager(this.DataStore); Assert.IsNull(threadManager.GetThread(section.CMSSectionType, thread.CMSThreadId)); Assert.IsNull(contentManager.GetContent(content.CMSContentId)); }