Ejemplo n.º 1
0
        public TaskListView ListByDate(DateTime startDate, DateTime endDate)
        {
            // create request
            var request = new TaskListRequest { StartDate = startDate, EndDate = endDate };

            // declare response
            var response = this._taskService.ListByDate(request);

            // map
            var items = AutoMapper.Mapper.Map<List<TaskDto>, List<TaskItemModel>>(response.Items);

            // return Model
            return new TaskListView { Items = items };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Lists this instance.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>
        /// List of Task Dtos.
        /// </returns>
        public TaskListResponse ListByDate(TaskListRequest request)
        {
            // get list
            var entities = this._businessService.ListByDate(request.StartDate, request.EndDate);

            // map to dto list
            var dtos = AutoMapper.Mapper.Map<List<Task>, List<TaskDto>>(entities);

            // return response
            return new TaskListResponse
            {
                Items = dtos
            };
        }
Ejemplo n.º 3
0
        public void ListByDateReturnsListGreaterThenZero()
        {
            //
            var startDate = DateTime.Now.Date;
            var endDate = DateTime.Now.Date.AddDays(1);

            // Arrange
            var result = new List<Task>() { new Task { } };
            var repository = new MockRepository();
            var mockService = repository.StrictMultiMock<ITaskBusinessService>();
            mockService
                .Expect(f => f.ListByDate(startDate, endDate)) // ignore arguements below
                .IgnoreArguments()
                .Return(result);

            // proxy
            var stubProxy = MockRepository.GenerateStub<ITaskService>();
            stubProxy
                .Stub(m => m.ListByDate(Arg<TaskListRequest>.Is.Anything))
                .Return(new TaskListResponse()
                {
                    Items = new List<TaskDto>()
                    {
                        new TaskDto()
                        {
                            TaskId = 1
                        }
                    }
                });

            repository.ReplayAll();

            // service
            var service = new TaskService(mockService);

            // Act
            var request = new TaskListRequest
            {
                StartDate = startDate,
                EndDate = endDate
            };
            var response = service.ListByDate(request);

            // Assert
            Assert.IsTrue(response.Items.Count > 0);
        }