Exemplo n.º 1
0
        public async Task SaveAsyncGuardAgainstNullTest(string scenario, object response, string parameterName)
        {
            var expectedResponse = (Response <TodoItemEntity>)response;

            var repository = new UpdateTodoItemRepository(Context);

            var expectedException = new ArgumentNullException(parameterName);
            await Verify.ThrowsExceptionAsync(() => repository.SaveAsync(expectedResponse), expectedException);
        }
Exemplo n.º 2
0
        public async Task SaveAsyncItemDoesNotExistTest()
        {
            var response = new Response <TodoItemEntity> {
                Item = TodoItemFactory.CreateTodoItemEntity(1)
            };

            var repository = new UpdateTodoItemRepository(Context);
            await repository.SaveAsync(response);

            AssertResponse(response, UpdateTodoItemRepository.TodoItemNotFoundNotificationId, "TodoItem 1 was not found.");
        }
Exemplo n.º 3
0
        public async Task SaveAsyncSuccessTest()
        {
            // Arrange
            var todoItemEntities = await PopulateTodoItems(1);

            var expectedResponse = new Response <TodoItemEntity> {
                Item = todoItemEntities.Single().Clone()
            };

            expectedResponse.Item.Description = "Updated";

            // The response is changed in the SaveAsync, so don't use the same expected response as the one used in the method.
            var response = expectedResponse.Clone();

            // Act
            var repository = new UpdateTodoItemRepository(Context);
            await repository.SaveAsync(response);

            // Assert
            var actualTodoItemEntity = await GetTodoItem(1);

            VerifyTodoItem.AssertTodoItem(expectedResponse.Item, actualTodoItemEntity);
            VerifyTodoItem.AssertTodoItem(expectedResponse.Item, response.Item);
        }