public void TaskListsServiceMethodRemoveShareShouldARemoveAUserFromTheTaskListShares() { // Arrange var unitOfWorkMock = new Mock<IUnitOfWork>(); var repository = new TaskListsMemoryRepository(); var notesRepository = new NotesMemoryRepository(); var taskList = new TaskList { PartitionKey = TaskListsMemoryRepository.User1RowKey, RowKey = repository.TaskList1RowKey }; var service = new TaskListsService(unitOfWorkMock.Object, repository, notesRepository); var taskListSharesCount = repository.TaskListShares.Count; // Act service.RemoveShare(taskList, TaskListsMemoryRepository.User3RowKey); // Assert Assert.IsTrue(repository.TaskListShares.Count == taskListSharesCount - 1); }
public void TaskListsServiceMethodUpdateShouldUpdateATaskList() { // Arrange var unitOfWorkMock = new Mock<IUnitOfWork>(); var repository = new TaskListsMemoryRepository(); var notesRepository = new NotesMemoryRepository(); var service = new TaskListsService(unitOfWorkMock.Object, repository, notesRepository); var result = service.Get(TaskListsMemoryRepository.User1RowKey, repository.TaskList1RowKey); // Act result.Title = "Test title"; service.Update(result); var updatedResult = service.Get(TaskListsMemoryRepository.User1RowKey, repository.TaskList1RowKey); // Assert Assert.IsTrue(updatedResult.Title == "Test title"); }
public void TaskListsServiceMethodHasPermissionToEditShouldReturnTrueForAUserInTheShare() { // Arrange var user = new User { PartitionKey = TaskListsMemoryRepository.IdentityProvider, RowKey = TaskListsMemoryRepository.User1RowKey }; var unitOfWorkMock = new Mock<IUnitOfWork>(); var repository = new TaskListsMemoryRepository(); var notesRepository = new NotesMemoryRepository(); var taskList = new TaskList { PartitionKey = TaskListsMemoryRepository.User1RowKey, RowKey = repository.TaskList1RowKey, Owner = user}; var service = new TaskListsService(unitOfWorkMock.Object, repository, notesRepository); // Act var result = service.HasPermissionToEdit(user, taskList); // Assert Assert.IsTrue(result); }
public void TaskListsServiceMethodLoadShouldReturnAllTaskLists() { // Arrange var unitOfWorkMock = new Mock<IUnitOfWork>(); var repository = new TaskListsMemoryRepository(); var notesRepository = new NotesMemoryRepository(); var service = new TaskListsService(unitOfWorkMock.Object, repository, notesRepository); // Act var result = service.Load(); // Assert Assert.IsInstanceOfType(result, typeof(IQueryable<TaskList>)); Assert.IsTrue(result.Count() == 2); }
public void TaskListsServiceMethodGetShouldReturnNullForANonExistingTaskList() { // Arrange var unitOfWorkMock = new Mock<IUnitOfWork>(); var repository = new TaskListsMemoryRepository(); var notesRepository = new NotesMemoryRepository(); var service = new TaskListsService(unitOfWorkMock.Object, repository, notesRepository); // Act var result = service.Get(TaskListsMemoryRepository.User1RowKey, repository.TaskList3RowKey); // Assert Assert.IsNull(result); }
public void TaskListsServiceMethodGetShouldReturnATaskList() { // Arrange var unitOfWorkMock = new Mock<IUnitOfWork>(); var repository = new TaskListsMemoryRepository(); var notesRepository = new NotesMemoryRepository(); var service = new TaskListsService(unitOfWorkMock.Object, repository, notesRepository); // Act var result = service.Get(TaskListsMemoryRepository.User1RowKey, repository.TaskList1RowKey); // Assert Assert.IsInstanceOfType(result, typeof(TaskList)); Assert.IsNotNull(result); }
public void TaskListsServiceMethodGetSharedShouldReturnAllTaskListsThatTheUserIsInTheShare() { // Arrange var user = new User { PartitionKey = TaskListsMemoryRepository.IdentityProvider, RowKey = TaskListsMemoryRepository.User3RowKey }; var unitOfWorkMock = new Mock<IUnitOfWork>(); var taskListsRepository = new TaskListsMemoryRepository(); var notesRepository = new NotesMemoryRepository(); var service = new TaskListsService(unitOfWorkMock.Object, taskListsRepository, notesRepository); // Act var result = service.GetShared(user); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IEnumerable<TaskList>)); Assert.IsTrue(result.Count() == 2); }
public void TaskListsServiceMethodDeleteShouldDeleteATaskList() { // Arrange var unitOfWorkMock = new Mock<IUnitOfWork>(); var repository = new TaskListsMemoryRepository(); var notesRepository = new NotesMemoryRepository(); var service = new TaskListsService(unitOfWorkMock.Object, repository, notesRepository); var result = service.Get(TaskListsMemoryRepository.User1RowKey, repository.TaskList1RowKey); var user = new User { PartitionKey = TaskListsMemoryRepository.IdentityProvider, RowKey = TaskListsMemoryRepository.User1RowKey }; var note = new Note { PartitionKey = TaskListsMemoryRepository.User1RowKey, RowKey = repository.Note1RowKey, Owner = user }; result.Notes.Add(note); // Act service.Delete(result); result = service.Get(TaskListsMemoryRepository.User1RowKey, repository.TaskList1RowKey); // Assert Assert.IsNull(result); }
public void TaskListsServiceMethodCreateShouldCreateATaskList() { // Arrange var user = new User { PartitionKey = TaskListsMemoryRepository.IdentityProvider, RowKey = TaskListsMemoryRepository.User1RowKey }; var unitOfWorkMock = new Mock<IUnitOfWork>(); var repository = new TaskListsMemoryRepository(); var notesRepository = new NotesMemoryRepository(); var taskList = new TaskList { PartitionKey = TaskListsMemoryRepository.User1RowKey, RowKey = repository.TaskList3RowKey, Owner = user }; var service = new TaskListsService(unitOfWorkMock.Object, repository, notesRepository); // Act service.Create(taskList); var result = service.Get(NotesMemoryRepository.User1RowKey, repository.TaskList3RowKey); // Assert Assert.IsInstanceOfType(result, typeof(TaskList)); Assert.IsNotNull(result); }