Пример #1
0
        public void GivenTodoItem_TitleChanged()
        {
            var context = new DBContext();
            var gateway = new TodoItemGateway(context);

            Core.UseCases.AddTodoItem.Output actualOutput = null;

            var outputHandler = new Mock <Core.UseCases.IUseCaseOutputHandler <Core.UseCases.AddTodoItem.Output> > ();

            outputHandler.Setup(e => e.Handle(It.IsAny <Core.UseCases.AddTodoItem.Output> ()))
            .Callback <Core.UseCases.AddTodoItem.Output> (output => actualOutput = output);

            var addTodoItemBuilder = new Core.UseCases.AddTodoItem.InputBuilder();

            addTodoItemBuilder.WithTitle("My Title");
            var addTodoItem = new Core.UseCases.AddTodoItem.Interactor(outputHandler.Object, gateway);

            addTodoItem.Execute(addTodoItemBuilder.Build());

            InputBuilder builder = new InputBuilder();

            builder
            .WithTodoItemId(actualOutput.Id)
            .WithTitle("New Title");

            IUseCase <Input> updatedTitle = new Interactor(gateway);

            Exception ex = Record.Exception(() => updatedTitle.Execute(builder.Build()));

            Assert.Null(ex);
        }
Пример #2
0
        public void AddTodoItem(string[] input)
        {
            IUseCase <Core.UseCases.AddTodoItem.Input> addTodoItem = new Core.UseCases.AddTodoItem.Interactor(
                outputHandler,
                gateway
                );

            var builder = new Core.UseCases.AddTodoItem.InputBuilder();

            builder.WithTitle(input[1]);
            addTodoItem.Execute(builder.Build());
        }