public void CreateUserTest()
 {
     IUserManager m = ObjectFactory.GetInstance<IUserManager>();
     User user1 = new User();
     m.CreateUser(user1);
     Assert.IsNotNull(user1.UniqueId);
 }
 public void CreateTaskList(User creatorUser, TaskList listData)
 {
     listData.Creator = creatorUser;
     _repository.Create(listData);
     _userListsRepo.Create(creatorUser.UniqueId, listData.Id, creatorUser.UniqueId);
     _listUsersRepo.Create(listData.Id, creatorUser.UniqueId, creatorUser.Name);
 }
 public UserEntity(User user)
     : base(user.Provider, user.NameIdentifier)
 {
     UniqueId = user.UniqueId;
     Name = user.Name;
     Email = user.Email;
 }
        public TaskListTest()
        {
            IoC.Configure();

            _user = new User();
            IUserManager um = ObjectFactory.GetInstance<IUserManager>();
            um.CreateUser(_user);

            _taskListManager = ObjectFactory.GetInstance<ITaskListManager>();
        }
 public Note CopyNote(User user, string destListId, string destListCreatorId, Note noteData)
 {
     var newNote = new Note()
     {
         Name = noteData.Name,
         Description = noteData.Description,
         Creator = user,
         ParentList = new TaskList() { Id = destListId, Creator = new User() { UniqueId = destListCreatorId } }
     };
     _noteManager.CreateNote(user, destListId, destListCreatorId, newNote);
     return newNote;
 }
        public void ShareNoteTest()
        {
            var n = CreateNote();

            var user = new User();
            IUserManager um = ObjectFactory.GetInstance<IUserManager>();
            um.CreateUser(user);

            _noteManager.ShareNote(_user.UniqueId, _taskList.Id, n.Id, user.UniqueId);

            var n2 = _noteManager.GetNote(_user.UniqueId, _taskList.Id, n.Id);
            Assert.IsTrue(n2.Users.Contains(user));
        }
        public NoteTest()
        {
            IoC.Configure();

            _user = new User();
            IUserManager um = ObjectFactory.GetInstance<IUserManager>();
            um.CreateUser(_user);

            _taskList = new TaskList() { Name = "new list", Creator = _user, Users = new List<User>() { _user } };
            _taskListManager = ObjectFactory.GetInstance<ITaskListManager>();
            _taskListManager.CreateTaskList(_user, _taskList);

            _noteManager = ObjectFactory.GetInstance<INoteManager>();
        }
        public void MoveNote(User user, string destListId, string destListCreatorId, 
            string sourceListId, string sourceListCreatorId, Note noteData)
        {
            var newList = _taskListManager.GetTaskList(user.UniqueId, destListId, destListCreatorId);
            if (newList == null)
            {
                // TODO exception
            }

            // TODO para simular uma transacao isto devia ser feito directamente nos repos
            _noteManager.DeleteNote(user.UniqueId, sourceListId, sourceListCreatorId, noteData.Id);

            // TODO nao pode ser um create porque senao muda-se o id
            _noteManager.CreateNote(user, destListId, destListCreatorId, noteData);
        }
        public void ShareListTest()
        {
            var tl = CreateTaskList();

            var user = new User();
            IUserManager um = ObjectFactory.GetInstance<IUserManager>();
            um.CreateUser(user);

            _taskListManager.ShareTaskList(_user.UniqueId, tl.Id, _user.UniqueId, user.UniqueId);

            var tl2 = _taskListManager.GetTaskList(_user.UniqueId, tl.Id, _user.UniqueId);
            Assert.IsTrue(tl2.Users.Contains(user));

            var tl3 = _taskListManager.GetTaskList(user.UniqueId, tl.Id, _user.UniqueId);
            Assert.IsNotNull(tl3);
        }
        public void CreateNote(User user, string listId, string creatorId, Note noteData)
        {
            noteData.Creator = user;

            var list = _taskListManager.GetTaskList(user.UniqueId, listId, creatorId);
            noteData.ParentList = list;

            _repository.Create(noteData);
            // TODO create specific repo for note shares
            _userNotesRepo.Create(user.UniqueId, noteData.Id, listId);
            _noteUsersRepo.Create(noteData.Id, user.UniqueId, listId);

            foreach (var u in list.Users)
            {
                var notif = new Notification() { Task = noteData, User = u, Type = Notification.NotificationType.Insert };
                _noticationMgr.CreateNotification(user.UniqueId, notif);
            }
        }
        public static void ConfigureTestEnv()
        {
            ObjectFactory.Initialize(ex =>
            {
                ex.Scan(scan =>
                {
                    scan.TheCallingAssembly();
                    scan.WithDefaultConventions();
                });

/*                ex.For<INotificationProcessor>().Use<DummyNotificationProcessor>();

                ex.For<IUserRepository>().Singleton().Use<PromptCloudNotes.InMemoryRepo.UserRepository>();
                ex.For<ITaskListRepository>().Singleton().Use<PromptCloudNotes.InMemoryRepo.TaskListRepository>();
                ex.For<INoteRepository>().Singleton().Use<PromptCloudNotes.InMemoryRepo.NoteRepository>();
                ex.For<INotificationRepository>().Singleton().Use<PromptCloudNotes.InMemoryRepo.NotificationRepository>();
                */
                ex.For<IUserManager>().HttpContextScoped().Use<UserManager>();
                ex.For<ITaskListManager>().HttpContextScoped().Use<TaskListManager>();
                ex.For<INoteManager>().HttpContextScoped().Use<NoteManager>();
                ex.For<ITaskManager>().HttpContextScoped().Use<TaskManager>();
                ex.For<INotificationManager>().HttpContextScoped().Use<NotificationManager>();
            });

            DependencyResolver.SetResolver(new SmDependencyResolver(ObjectFactory.Container));

            // generate dummy data in test environment 
            var user = new User();
            user.Name = "Sandra Fernandes";
            var um = ObjectFactory.GetInstance<IUserManager>();
            um.CreateUser(user);

            var list = new TaskList() { Name = "Dummy list", Description = "Dummy description" };
            var tlm = ObjectFactory.GetInstance<ITaskListManager>();
            tlm.CreateTaskList(user, list);

            var note = new Note() { Name = "note name", Description = "note description" };
            var nm = ObjectFactory.GetInstance<INoteManager>();
            nm.CreateNote(user, list.Id, user.UniqueId, note);
        }
        public void CreateUser(User userData)
        {
            // validate user, example, check if the username is used, or the email address

            _repository.Create(userData);
        }
 public void Update(string provider, string userId, User userData)
 { }
 public void Create(User user)
 {
     _users.Add(user);
     user.UniqueId = Guid.NewGuid().ToString();
 }
 public void Share(string listId, User user)
 {
     var list = _lists.First(l => l.Id == listId);
     list.Users.Add(user);
 }