예제 #1
0
 public void SetUp()
 {
     _repository = new Mock<ITasksRepository>();
     _tasksService = new TasksService(_repository.Object);
     _taskOne = new Task { Id = Guid.NewGuid(), Title = "Task One", Description = "Description One" };
     _taskTwo = new Task { Id = Guid.NewGuid(), Title = "Task Two", Description = "Description Two" };
 }
 public void Initialize()
 {
     _server = TestServer.Create<StartUp>();
     _repository = new TasksRepository(new RedisClient());
     _taskOne = _repository.Save(new Task { Title = "TaskOne" });
     _taskTwo = _repository.Save(new Task { Title = "TaskTwo" });
 }
예제 #3
0
        public void TaskMapper_ToModel()
        {
            var taskEntity = new Task { Id = Guid.NewGuid(), Title = "title", Description = "description", State = StateTask.InProgress };
            var taskModel = _taskMapper.ToModel(taskEntity);

            Assert.IsInstanceOfType(taskModel, typeof(TaskModel));
            Assert.AreEqual(taskEntity.Id, taskModel.id);
            Assert.AreEqual(StateTaskModel.InProgress, taskModel.state);
            Assert.AreEqual(taskEntity.Description, taskModel.description);
        }
예제 #4
0
 public TaskModel ToModel(Task entity)
 {
     return AutoMapper.Mapper.Map<TaskModel>(entity);
 }
        public void TasksRepository_Update()
        {
            var task = new Task { Title = "Task One" };
            var taskSaved = _repository.Save(task);
            taskSaved.Title = "Name Updated";

            var taskUpdated = _repository.Update(taskSaved);
            Assert.AreEqual(taskUpdated.Id, taskSaved.Id);
            Assert.AreEqual(taskUpdated.Title, taskSaved.Title);
            _repository.Delete(task.Id);
        }
예제 #6
0
 public Task Update(Task task)
 {
     return _tasksRepository.Update(task);
 }
예제 #7
0
 public Task Save(Task task)
 {
     return _tasksRepository.Save(task);
 }
예제 #8
0
 public bool IsValidTaskForUpdate(Task task)
 {
     return !string.IsNullOrWhiteSpace(task.Title) &&
             task.Id != null &&
             task.Id != Guid.Empty;
 }
예제 #9
0
 public bool IsValidTaskForInsert(Task task)
 {
     return !string.IsNullOrWhiteSpace(task.Title);
 }
예제 #10
0
 public Task Update(Task task)
 {
     return _redisClient.Store(task);
 }
예제 #11
0
 public Task Save(Task task)
 {
     task.Id = Guid.NewGuid();
     return _redisClient.Store(task);
 }