Exemple #1
0
        private void LoadTaskData()
        {
            TaskListService          objListService = new TaskListService();
            DataTable                DT             = objListService.GetAllTask(this.DBConnectionString);
            List <ToDoListTaskClass> TaskList       = new List <ToDoListTaskClass>();

            for (int i = 0; i < DT.Rows.Count; i++)
            {
                DataRow           dr      = DT.Rows[i];
                ToDoListTaskClass objTask = new ToDoListTaskClass();
                objTask.Id          = Convert.ToInt32(dr["Id"]);
                objTask.Description = dr["Description"].ToString();
                objTask.TodoListId  = Convert.ToInt32(dr["ToDoListId"]);
                objTask.Important   = Convert.ToBoolean(dr["Important"]);
                objTask.Archived    = Convert.ToBoolean(dr["Archieved"]);
                objTask.Owner       = dr["Owner"].ToString();
                if (dr["DueDate"].ToString() != "")
                {
                    objTask.DueDate = Convert.ToDateTime(dr["DueDate"].ToString());
                }
                objTask.Title = dr["Title"].ToString();
                TaskList.Add(objTask);
            }
            ViewState["TaskList"] = TaskList;
        }
Exemple #2
0
        public async Task CreateAsync_GivenCurrentUserNotRouteAdmin_ExceptionThrown()
        {
            // Arrange.
            var userThatIsRouteSubButNotAdmin = ValidUser;

            Seed(TripFlipDbContext, userThatIsRouteSubButNotAdmin);
            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);

            CurrentUserService = CreateCurrentUserService(
                userThatIsRouteSubButNotAdmin.Id, userThatIsRouteSubButNotAdmin.Email);

            int validTaskListId   = TaskListEntityToSeed.Id;
            var createTaskListDto = Get_CreateTaskListDto(routeId: validTaskListId);

            var taskListService = new TaskListService(TripFlipDbContext, Mapper,
                                                      CurrentUserService);

            // Act + Assert
            await Assert.ThrowsExceptionAsync <ArgumentException>(async() =>
                                                                  await taskListService.CreateAsync(createTaskListDto));
        }
        public async Task UpdateAsync_ValidData_Successful()
        {
            // Arrange.
            Seed(TripFlipDbContext, ValidUser);
            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TaskListEntitiesToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEditorRoleEntityToSeed);

            CurrentUserService = CreateCurrentUserService(ValidUser.Id,
                                                          ValidUser.Email);

            var updateTaskListDto = GetUpdateTaskListDto();
            var taskListService   = new TaskListService(TripFlipDbContext, Mapper, CurrentUserService);

            // Act.
            var resultTaskListDto =
                await taskListService.UpdateAsync(updateTaskListDto);

            var comparer = new TaskListDtoComparer();

            // Assert.
            Assert.AreEqual(0,
                            comparer.Compare(resultTaskListDto, _expectedReturnTaskListDto));
        }
Exemple #4
0
        public async Task CreateAsync_GivenInvalidCurrentUser_ExceptionThrown(
            string displayName, ICurrentUserService currentUserService)
        {
            // Arrange.
            Seed(TripFlipDbContext, NonExistentUser);
            Seed(TripFlipDbContext, NotRouteSubscriberUser);
            Seed(TripFlipDbContext, NotTripSubscriberUser);

            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberAdminRoleEntityToSeed);

            CurrentUserService = currentUserService;

            int validTaskListId   = TaskListEntityToSeed.Id;
            var createTaskListDto = Get_CreateTaskListDto(routeId: validTaskListId);

            var taskListService = new TaskListService(TripFlipDbContext, Mapper,
                                                      CurrentUserService);

            // Act + Assert.
            await Assert.ThrowsExceptionAsync <NotFoundException>(async() =>
                                                                  await taskListService.CreateAsync(createTaskListDto), displayName);
        }
        public async Task DeleteById_ExistentTaskListId_Successful()
        {
            // Arrange.
            Seed(TripFlipDbContext, ValidUser);
            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TaskListEntityToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberAdminRoleEntityToSeed);

            CurrentUserService = CreateCurrentUserService(ValidUser.Id,
                                                          ValidUser.Email);

            var existentTaskListId = 1;
            var taskListService    = new TaskListService(TripFlipDbContext, Mapper,
                                                         CurrentUserService);

            // Act.
            await taskListService.DeleteByIdAsync(existentTaskListId);

            var taskListEntity = await TripFlipDbContext
                                 .TaskLists
                                 .FindAsync(existentTaskListId);

            // Assert.
            Assert.IsNull(taskListEntity);
        }
Exemple #6
0
        public async Task DeleteByIdAsync_GivenNotValidCurrentUser_ExceptionThrown(
            string displayName, ICurrentUserService currentUserService)
        {
            // Arrange.
            Seed(TripFlipDbContext, NonExistentUser);
            Seed(TripFlipDbContext, NotRouteSubscriberUser);
            Seed(TripFlipDbContext, NotTripSubscriberUser);

            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TaskListEntityToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberAdminRoleEntityToSeed);

            CurrentUserService = currentUserService;

            var validTaskListId = 1;
            var taskListService = new TaskListService(TripFlipDbContext, Mapper,
                                                      CurrentUserService);

            // Act + Assert.
            await Assert.ThrowsExceptionAsync <NotFoundException>(async() =>
                                                                  await taskListService.DeleteByIdAsync(validTaskListId), displayName);
        }
        public async Task GetAllByRouteIdAsync_GivenValidRouteId_Successful()
        {
            // Arrange
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TaskListEntitiesToSeed);

            CurrentUserService = CreateCurrentUserService(ValidUser.Id, ValidUser.Email);

            var taskListService = new TaskListService(TripFlipDbContext,
                                                      Mapper, CurrentUserService);

            var    paginationDto = GetPaginationDto();
            string searchString  = null;
            var    comparer      = new TaskListDtoComparer();

            // Act
            var result = await taskListService.GetAllByRouteIdAsync(1,
                                                                    searchString, paginationDto);

            var returnedTaskListDtos = result.Items.ToList();

            var expectedTaskListCount = _expectedGotAllTaskListDtos.Count();

            // Assert
            Assert.AreEqual(expectedTaskListCount, result.TotalCount);

            for (var i = 0; i < expectedTaskListCount; i++)
            {
                Assert.AreEqual(0,
                                comparer.Compare(returnedTaskListDtos[i], _expectedGotAllTaskListDtos[i]));
            }
        }
        public async Task CreateAsync_ValidData_Successful()
        {
            // Arrange.
            Seed(TripFlipDbContext, ValidUser);
            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberAdminRoleEntityToSeed);

            var comparer = new TaskListDtoComparer();

            CurrentUserService = CreateCurrentUserService(ValidUser.Id, ValidUser.Email);

            var taskListService = new TaskListService(TripFlipDbContext, Mapper,
                                                      CurrentUserService);

            var taskListEntity      = TaskListEntityToSeed;
            var expectedTaskListDto = Mapper.Map <TaskListDto>(taskListEntity);

            var createTaskListDto = Get_CreateTaskListDto(
                routeId: taskListEntity.Id,
                title: taskListEntity.Title);

            // Act.
            var resultTaskListDto = await taskListService.CreateAsync(createTaskListDto);

            // Arrange.
            Assert.AreEqual(0, comparer.Compare(expectedTaskListDto, resultTaskListDto));
        }
Exemple #9
0
        /// <summary>
        /// Delete current list
        /// </summary>
        public void DeleteList()
        {
            TaskListService.DeleteTaskList(_currentList);
            _currentList = _lists[0] ?? new UserTaskListModel();

            Update();
        }
        public int ChangePosition(string json)
        {
            int update = 0;
            var msg    = ser.Deserialize <List <JsonObj> >(json);

            for (int i = 0; i < msg.Count; i++)
            {
                var item = TaskListService.Get(msg[i].list);
                for (int j = 0; j < msg[i].cards.Length; j++)
                {
                    var card = CardService.Get(msg[i].cards[j]);
                    if (item.Cards.Contains(card))
                    {
                        if (item.Cards[j].Position != j)
                        {
                            item.Cards[j].Position = j;
                            update = CardService.Update(item.Cards[j]);
                        }
                    }
                    else
                    {
                        card.TaskListId = item.Id;
                        card.Position   = j;
                        update          = CardService.Update(card);
                    }
                }
            }

            return(update);
        }
Exemple #11
0
        private void BindTaskList(bool IncludeArchieved)
        {
            TaskListService objListService = new TaskListService();
            DataTable       DT;

            if (IncludeArchieved == true)
            {
                DT = objListService.GetAllTaskListWithUnarchieved(this.DBConnectionString);
            }
            else
            {
                DT = objListService.GetAllTaskList(this.DBConnectionString);
            }
            List <ToDoListClass> ToDoList = new List <ToDoListClass>();

            for (int i = 0; i < DT.Rows.Count; i++)
            {
                DataRow dr = DT.Rows[i];
                dr["Title"] = dr["Title"] + "(" + dr["count"] + ")";
            }
            lstTaskListV.DataSource     = DT;
            lstTaskListV.DataTextField  = "Title";
            lstTaskListV.DataValueField = "Id";
            lstTaskListV.DataBind();
        }
        public int Update(TaskListViewModel data)
        {
            var         map      = mapper.CreateMapper();
            TaskListDTO taskList = map.Map <TaskListDTO>(data);
            int         i        = taskList.Id = TaskListService.Update(taskList);

            return(i);
        }
        public int Delete(int listId)
        {
            var         map      = mapper.CreateMapper();
            TaskListDTO taskList = TaskListService.Get(listId);
            int         i        = TaskListService.Delete(taskList);

            return(i);
        }
Exemple #14
0
        private void CreateMocks()
        {
            var mockBehavior = MockBehavior.Strict;

            _mockDbContext   = new Mock <DbContext>(mockBehavior);
            _mockRepository  = new Mock <Repository <Task> >(mockBehavior, _mockDbContext.Object);
            _mockUnityOfWork = new Mock <UnitOfWork>(mockBehavior, _mockDbContext.Object);
            _taskListService = new TaskListService(_mockUnityOfWork.Object);
        }
Exemple #15
0
        private void UpdateData()
        {
            _lists = TaskListService.GetAllTaskLists();

            if (_currentList != null)
            {
                _currentList = TaskListService.GetTaskList(_currentList.Name);
            }
        }
Exemple #16
0
        public async Task UpdateAsync_NonExistentTaskList_ExceptionThrown()
        {
            // Arrange.
            var updateTaskListDto = GetUpdateTaskListDto();
            var taskListService   = new TaskListService(TripFlipDbContext, Mapper, CurrentUserService);

            // Act + Assert.
            await Assert.ThrowsExceptionAsync <NotFoundException>(async() =>
                                                                  await taskListService.UpdateAsync(updateTaskListDto));
        }
        public int Create(string name, int id)
        {
            var         map      = mapper.CreateMapper();
            BoardDTO    board    = BoardService.Get(id);
            TaskListDTO taskList = new TaskListDTO {
                Name = name, BoardId = board.Id
            };
            int i = taskList.Id = TaskListService.Create(taskList);

            return(i);
        }
Exemple #18
0
        public void CreateList(string listName)
        {
            var newList = new UserTaskListModel()
            {
                Name = listName
            };

            TaskListService.CreateTaskList(newList);
            _currentList = newList;
            Update();
        }
Exemple #19
0
        public async Task GetByIdAsync_NonExistentTaskListId_ExceptionThrown()
        {
            // Arrange.
            var nonExistentTaskListId = 1;

            var taskListService = new TaskListService(TripFlipDbContext, Mapper,
                                                      CurrentUserService);

            // Act + Assert.
            await Assert.ThrowsExceptionAsync <NotFoundException>(async() =>
                                                                  await taskListService.GetByIdAsync(nonExistentTaskListId));
        }
Exemple #20
0
        public MainPresenter(IMainView view)
        {
            _view  = view;
            _lists = TaskListService.GetAllTaskLists();

            _view.ShowUserInfo(User.Email, User.FirstName + " " + User.LastName);

            if (_lists.Count > 0)
            {
                _currentList = _lists[0];
            }
        }
        private void командаЗарегистрировать_ItemClick(System.Object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!SaveCard())
            {
                UIService.ShowError("Сохранение не удалось. Выполните сохранение вручную");
                return;
            }
            KindsCardKind kind = Context.GetObject <KindsCardKind>(new Guid("AB801854-70AF-4B6C-AB48-1B59B5D11AA9"));

            DocsVision.BackOffice.ObjectModel.Task task = TaskService.CreateTask(kind);
            task.MainInfo.Name = "Проверка бухгалтерских документов " + Document.MainInfo.Name;
            task.Description   = "Проверка бухгалтерских документов " + Document.MainInfo.Name;
            string content = "Вы назначены ответственным за первичную проверку бухгалтерских документов и выставление согласущего куратора.";

            content = content + ". Пожалуйста, отметьте в родительском документе сотрудника в поле Куратор и отправьте документ на согласование";
            task.MainInfo.Content   = content;
            task.MainInfo.Author    = this.StaffService.GetCurrentEmployee();
            task.MainInfo.StartDate = DateTime.Now;
            task.MainInfo.Priority  = TaskPriority.Normal;
            task.Preset.AllowDelegateToAnyEmployee = true;
            TaskService.AddSelectedPerformer(task.MainInfo, Document.MainInfo.Registrar);
            //добавляем ссылку на родительскую карточку
            TaskService.AddLinkOnParentCard(task, TaskService.GetKindSettings(kind), this.Document);
            //добавляем ссылку на задание в карточку
            TaskListService.AddTask(this.Document.MainInfo.Tasks, task, this.Document);
            //создаем и сохраняем новый список заданий
            TaskList newTaskList = TaskListService.CreateTaskList();

            Context.SaveObject <DocsVision.BackOffice.ObjectModel.TaskList>(newTaskList);
            //записываем в задание
            task.MainInfo.ChildTaskList = newTaskList;
            Context.SaveObject <DocsVision.BackOffice.ObjectModel.Task>(task);
            string oErrMessageForStart;
            bool   CanStart = TaskService.ValidateForBegin(task, out oErrMessageForStart);

            if (CanStart)
            {
                TaskService.StartTask(task);
                StatesState oStartedState = StateService.GetStates(kind).FirstOrDefault(br => br.DefaultName == "Started");
                task.SystemInfo.State = oStartedState;

                UIService.ShowMessage("Документ успешно отправлен пользователю " + Document.MainInfo.Registrar.DisplayString, "Отправка задания");
            }

            else
            {
                UIService.ShowMessage(oErrMessageForStart, "Ошибка отправки задания");
            }

            Context.SaveObject <DocsVision.BackOffice.ObjectModel.Task>(task);

            changeState("Is registered");
        }
        public int Create(string name, int id, string description)
        {
            var         map      = mapper.CreateMapper();
            TaskListDTO taskList = TaskListService.Get(id);
            CardDTO     card     = new CardDTO {
                Name = name, TaskListId = taskList.Id, Description = description
            };

            int i = card.Id = CardService.Create(card);

            return(i);
        }
Exemple #23
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            Log.Initialize();
            ProbeEnvironment.Initialize();
            TempManager.Init(TempDir);
            Snippets.SnippetDeploy.DeploySnippets();
            CodeModel.SignatureDocumentor.Initialize();

            ThreadHelper.ThrowIfNotOnUIThread();

            // Proffer the service.	http://msdn.microsoft.com/en-us/library/bb166498.aspx
            var langService = new ProbeLanguageService(this);

            langService.SetSite(this);
            (this as IServiceContainer).AddService(typeof(ProbeLanguageService), langService, true);

            // Register a timer to call our language service during idle periods.
            var mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;

            if (_componentId == 0 && mgr != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize            = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf            = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf          = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out _componentId);
            }

            _errorTaskProvider = new ErrorTagging.ErrorTaskProvider(this);
            TaskListService.RegisterTaskProvider(_errorTaskProvider, out _errorTaskProviderCookie);

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (mcs != null)
            {
                Commands.InitCommands(mcs);
            }

            _functionScanner = new FunctionFileScanning.FFScanner();

            // Need to keep a reference to Events and DocumentEvents in order for DocumentSaved to be triggered.
            _dteEvents = Shell.DTE.Events;

            _dteDocumentEvents = _dteEvents.DocumentEvents;
            _dteDocumentEvents.DocumentSaved += DocumentEvents_DocumentSaved;

            Microsoft.VisualStudio.PlatformUI.VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged;
        }
        private void sendApproval(String role, StaffEmployee Performer, int performingType)
        {
            KindsCardKind kind = Context.GetObject <KindsCardKind>(new Guid("F841AEE1-6018-44C6-A6A6-D3BAE4A3439F"));    // Задание на согласование фин.документов

            DocsVision.BackOffice.ObjectModel.Task task = TaskService.CreateTask(kind);
            task.MainInfo.Name = "Согласование бухгалтерских документов " + Document.MainInfo.Name;
            task.Description   = "Согласование бухгалтерских документов " + Document.MainInfo.Name;
            string content = "Вы назначены " + role + " при согласовании бухгалтерских документов.";

            content = content + " Пожалуйста, отметьте свое решение кнопками Согласован или Не согласован и напишите соответствующий комментарий";
            task.MainInfo.Content   = content;
            task.MainInfo.Author    = this.StaffService.GetCurrentEmployee();
            task.MainInfo.StartDate = DateTime.Now;
            task.MainInfo.Priority  = TaskPriority.Normal;
            task.Preset.AllowDelegateToAnyEmployee = true;
            TaskService.AddSelectedPerformer(task.MainInfo, Performer);
            BaseCardSectionRow taskRow = (BaseCardSectionRow)task.GetSection(new System.Guid("20D21193-9F7F-4B62-8D69-272E78E1D6A8"))[0];

            taskRow["PerformanceType"] = performingType;
            addTaskRows(task);
            //добавляем ссылку на родительскую карточку
            TaskService.AddLinkOnParentCard(task, TaskService.GetKindSettings(kind), this.Document);
            //добавляем ссылку на задание в карточку
            TaskListService.AddTask(this.Document.MainInfo.Tasks, task, this.Document);
            //создаем и сохраняем новый список заданий
            TaskList newTaskList = TaskListService.CreateTaskList();

            Context.SaveObject <DocsVision.BackOffice.ObjectModel.TaskList>(newTaskList);
            //записываем в задание
            task.MainInfo.ChildTaskList = newTaskList;
            Context.SaveObject <DocsVision.BackOffice.ObjectModel.Task>(task);
            string oErrMessageForStart;
            bool   CanStart = TaskService.ValidateForBegin(task, out oErrMessageForStart);

            if (CanStart)
            {
                TaskService.StartTask(task);
                StatesState oStartedState = StateService.GetStates(kind).FirstOrDefault(br => br.DefaultName == "Started");
                task.SystemInfo.State = oStartedState;

                UIService.ShowMessage("Документ успешно отправлен пользователю " + Performer.DisplayString, "Отправка задания");
            }

            else
            {
                UIService.ShowMessage(oErrMessageForStart, "Ошибка отправки задания");
            }

            Context.SaveObject <DocsVision.BackOffice.ObjectModel.Task>(task);
        }
Exemple #25
0
        public async Task CreateAsync_GivenInvalidRouteId_ExceptionThrown()
        {
            // Arrange.
            var taskListService = new TaskListService(
                tripFlipDbContext: TripFlipDbContext,
                mapper: null,
                currentUserService: null);

            int nonExistentRouteId = 1;
            var createTaskListDto  = Get_CreateTaskListDto(routeId: nonExistentRouteId);

            // Act + Assert.
            await Assert.ThrowsExceptionAsync <NotFoundException>(async() =>
                                                                  await taskListService.CreateAsync(createTaskListDto));
        }
Exemple #26
0
        public async Task GetAllByRouteIdAsync_GivenInvalidRouteId_ExceptionThrown()
        {
            // Arrange
            Seed(TripFlipDbContext, TaskListEntitiesToSeed);

            CurrentUserService = CreateCurrentUserService(ValidUser.Id, ValidUser.Email);

            var taskListService = new TaskListService(TripFlipDbContext,
                                                      Mapper, CurrentUserService);
            var    invalidRouteId = 2;
            var    paginationDto  = GetPaginationDto();
            string searchString   = null;

            // Act + Assert
            await Assert.ThrowsExceptionAsync <NotFoundException>(async() =>
                                                                  await taskListService.GetAllByRouteIdAsync(invalidRouteId,
                                                                                                             searchString, paginationDto));
        }
Exemple #27
0
        public async Task UpdateAsync_CurrentUserNotRouteEditor_ExceptionThrown()
        {
            // Arrange.
            Seed(TripFlipDbContext, UserWithoutRouteRoles);
            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TaskListEntitiesToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);

            CurrentUserService = CreateCurrentUserService(UserWithoutRouteRoles.Id,
                                                          UserWithoutRouteRoles.Email);

            var updateTaskListDto = GetUpdateTaskListDto();
            var taskListService   = new TaskListService(TripFlipDbContext, Mapper, CurrentUserService);

            // Act + Assert.
            await Assert.ThrowsExceptionAsync <ArgumentException>(async() =>
                                                                  await taskListService.UpdateAsync(updateTaskListDto));
        }
        public async Task GetByIdAsync_ExistentTaskListId_Successful()
        {
            // Arrange.
            var taskListEntityToSeed = TaskListEntityToSeed;

            Seed(TripFlipDbContext, taskListEntityToSeed);

            var existentTaskListId = taskListEntityToSeed.Id;
            var taskListService    = new TaskListService(TripFlipDbContext, Mapper,
                                                         CurrentUserService);

            var expectedTaskListDto = Mapper.Map <TaskListDto>(taskListEntityToSeed);
            var taskListDtoComparer = new TaskListDtoComparer();

            // Act.
            var resultTaskListDto = await taskListService.GetByIdAsync(existentTaskListId);

            // Act + Assert.
            Assert.AreEqual(0,
                            taskListDtoComparer.Compare(expectedTaskListDto, resultTaskListDto));
        }
Exemple #29
0
        public async Task DeleteByIdAsync_GivenCurrentUserNotRouteAdmin_ExceptionThrown()
        {
            // Arrange
            Seed(TripFlipDbContext, ValidUser);
            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TaskListEntityToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);

            CurrentUserService = CreateCurrentUserService(ValidUser.Id,
                                                          ValidUser.Email);

            var validTaskListId = 1;
            var taskListService = new TaskListService(TripFlipDbContext, Mapper,
                                                      CurrentUserService);

            // Act + Assert
            await Assert.ThrowsExceptionAsync <ArgumentException>(async() =>
                                                                  await taskListService.DeleteByIdAsync(validTaskListId));
        }
Exemple #30
0
        public async Task UpdateAsync_InvalidCurrentUser_ExceptionThrown(
            string displayName, ICurrentUserService currentUserService)
        {
            // Arrange.
            Seed(TripFlipDbContext, NonExistentUser);
            Seed(TripFlipDbContext, NotRouteSubscriberUser);
            Seed(TripFlipDbContext, NotTripSubscriberUser);

            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TaskListEntitiesToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);

            CurrentUserService = currentUserService;
            var updateTaskListDto = GetUpdateTaskListDto();
            var taskListService   = new TaskListService(TripFlipDbContext, Mapper, CurrentUserService);

            // Act + Assert.
            await Assert.ThrowsExceptionAsync <NotFoundException>(async() =>
                                                                  await taskListService.UpdateAsync(updateTaskListDto), displayName);
        }