public void TestOnlyAdminCanRemoveThreads() { var role = new Role(new[] { Permission.CreateChat, Permission.DeleteThread, }); var user = new User("TestUser", role); user.Login(); var chatDao = new ChatDao(); var httpContext = new HttpContext(); var chatService = new ChatService(httpContext, chatDao, new UserDao()); var chatId = chatService.NewChat(user); const string title = "A new thread"; const string message = "Let's discuss things..."; chatService.AddThread(chatId, user, user.Username, title, message); var chat = chatDao.GetChatById(chatId); var thread = chat.Threads.First(); chat = chatDao.GetChatById(chatId); Assert.That(chat.Threads.Count, Is.EqualTo(1)); chatService.DeleteThread(user, chat.Id, thread.ThreadId); chat = chatDao.GetChatById(chatId); Assert.That(chat.Threads.Count, Is.EqualTo(0)); }
public JsonResult GetAdminMess() { string adminmess = ""; if (Session[commonConst.user_client] != null) { userLogin a = Session[commonConst.user_client] as userLogin; ViewBag.Name = a.Name_user; } if (Session[commonConst.user_employee] != null) { userLogin a = Session[commonConst.user_employee] as userLogin; ViewBag.NameEmployee = a.Name_user; adminmess = a.Name_user; } var dao = new ChatDao(); var result = dao.getAllMessAdmin(adminmess); return(Json( result, JsonRequestBehavior.AllowGet )); }
public ChatPresenter(ChatView chatView, ChatDao dao) { Logger.debug("Initalizing Chat Presenter.", origin: "ChatMail.ChatPresenter"); m_chatView = chatView; m_chatDao = dao; Login(); m_chatView.ShowUsername(m_currentUserDisplayname); }
public JsonResult Create(m_chat model) { var dao = new ChatDao(); var result = dao.Insert(model); return(Json(new { stutus = result })); }
public static void Chat(string selectedUser) { currentUser = selectedUser; ChatDao chatDao = new ChatDao(); ChatView chatView = new ChatView(chatDao); Thread chatThread = new Thread(new ParameterizedThreadStart(ChatView)); chatThread.Start(chatView); }
public void TestAddingChat() { var role = new Role(new[] { Permission.CreateChat }); var user = new User("TestUser", role); user.Login(); var chatDao = new ChatDao(); var chatService = new ChatService(new HttpContext(), chatDao, new UserDao()); var chatId = chatService.NewChat(user); var chat = chatDao.GetChatById(chatId); Assert.That(chat.CreatedBy, Is.EqualTo(user.Username)); }
public void TestAddingCommentToThread() { var role = new Role(new[] { Permission.CreateChat, Permission.DeleteThread, Permission.AddMessage }); var user = new User("TestUser", role); user.Login(); var chatDao = new ChatDao(); var httpContext = new HttpContext(); var chatService = new ChatService(httpContext, chatDao, new UserDao()); var chatId = chatService.NewChat(user); const string title = "A new thread"; const string message = "Let's discuss things..."; chatService.AddThread(chatId, user, user.Username, title, message); var chat = chatDao.GetChatById(chatId); var thread = chat.Threads.First(); var dev1 = new User("JaneDoe", role); var dev2 = new User("JohnDoe", role); dev1.Login(); dev2.Login(); var userDao = new UserDao(); userDao.SaveUser(dev1); userDao.SaveUser(dev2); chatService.AddCommentToThread(thread.ThreadId, chatId, "Hello, world!", dev1.Username); chatService.AddCommentToThread(thread.ThreadId, chatId, "Foo, bar, baz.", dev2.Username); chat = chatDao.GetChatById(chatId); var comments = chat.Threads.First().Comments; Assert.That(comments[0].Username, Is.EqualTo("JaneDoe")); Assert.That(comments[0].Message, Is.EqualTo("Hello, world!")); Assert.That(comments[1].Username, Is.EqualTo("JohnDoe")); Assert.That(comments[1].Message, Is.EqualTo("Foo, bar, baz.")); }
public void TestAddingThreadToChat() { var role = new Role(new[] { Permission.CreateChat, Permission.DeleteThread }); var user = new User("TestUser", role); user.Login(); var chatDao = new ChatDao(); var httpContext = new HttpContext(); var chatService = new ChatService(httpContext, chatDao, new UserDao()); var chatId = chatService.NewChat(user); const string title = "A new thread"; const string message = "Let's discuss things..."; chatService.AddThread(chatId, user, user.Username, title, message); var chat = chatDao.GetChatById(chatId); Assert.That(chat.CreatedBy, Is.EqualTo(user.Username)); Assert.That(chat.Threads.First().Username, Is.EqualTo(user.Username)); Assert.That(chat.Threads.First().Title, Is.EqualTo(title)); Assert.That(chat.Threads.First().Message, Is.EqualTo(message)); Assert.That(httpContext.Path, Is.EqualTo($"/{chatId}/threads/")); }
/// <summary> /// Constructor with Chat Data Access Object for MVPVM handling /// </summary> /// <param name="dao"></param> public ChatView(ChatDao dao) : this() { Logger.debug("Initializing Chat Presenter.", origin: "ChatMail.ChatView"); m_presenter = new ChatPresenter(this, dao); }
public ChatService() { _dao = new ChatDao(); }