Exemple #1
0
        public async Task ProcessRuleAsyncPass(string scenario, object expectedItem)
        {
            var expectedTodoItemEntity = (TodoItemEntity)expectedItem;
            var request  = CreateRequest((int)expectedTodoItemEntity.Id);
            var response = CreateResponse();

            var rule = new ResponseRule();
            await rule.ProcessAsync(request, response, RuleFactory.CreateEmptyListOfSaveRules());

            VerifyTodoItem.AssertTodoItem(expectedTodoItemEntity, response.Item);

            Assert.AreEqual(RuleStatusType.Passed, rule.Status);
            Assert.IsTrue(rule.ContinueProcessing);

            Assert.AreEqual(0, response.Notifications.Count);
        }
Exemple #2
0
        public async Task SaveAsyncTest()
        {
            // Arrange
            var todoItemEntity = TodoItemFactory.CreateTodoItemEntities(1).Single();
            var response       = new Response <TodoItemEntity> {
                Item = todoItemEntity
            };

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

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

            VerifyTodoItem.AssertTodoItem(response.Item, actualTodoItemEntity);
        }
Exemple #3
0
        public async Task HandleAsyncTest(int totalItems, int requestId)
        {
            var todoItemEntities = await PopulateTodoItems(totalItems);

            var expectedTodoItemEntity = todoItemEntities.SingleOrDefault(item => item.Id == requestId);

            var handler = new GetTodoItemRequestHandler(Context);

            var request = new GetTodoItemRequest {
                Id = requestId
            };
            var response = await handler.HandleAsync(request);

            Assert.IsNotNull(response);
            Assert.AreEqual(0, response.Notifications.Count);
            VerifyTodoItem.AssertTodoItem(expectedTodoItemEntity, response.Item);
        }
        public async Task HandleAsyncTest(int totalItems)
        {
            var todoItemEntities = await PopulateTodoItems(totalItems);

            var handler = new GetTodoItemsRequestHandler(Context);

            var request  = new GetTodoItemsRequest();
            var response = await handler.HandleAsync(request);

            Assert.IsNotNull(response?.Item);
            Assert.AreEqual(0, response.Notifications.Count);
            Assert.AreEqual(todoItemEntities.Count, response.Item.Count);

            foreach (var todoItemEntity in todoItemEntities)
            {
                var todoItem = response.Item.SingleOrDefault(item => item.Id == todoItemEntity.Id);
                VerifyTodoItem.AssertTodoItem(todoItemEntity, todoItem);
            }
        }
        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);
        }