Exemplo n.º 1
0
        //internal static Task UpdateBook(Book sut)
        //{
        //    var connectionString = ConnectivityService.GetConnectionString("TEMP");
        //    var context = new BookOrganizer2DbContext(connectionString);
        //    var repository = new BookRepository(context);

        //    var bookService = new BookService(repository);
        //    var command = new Commands.Update
        //    {
        //        Id = sut.Id,
        //        Title
        //        Notes = sut.Notes
        //    };

        //    return bookService.Handle(command);
        //}

        public static Task CreateInvalidBook()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new BookRepository(context);
            var bookService      = new BookService(repository);

            var bookId  = new BookId(SequentialGuid.NewSequentialGuid());
            var command = new Commands.Create {
                Id = bookId
            };

            return(bookService.Handle(command));
        }
Exemplo n.º 2
0
        public static async Task <Book> CreateValidBook(string title = null)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new BookRepository(context);

            var bookService = new BookService(repository);

            var command = new Commands.Create
            {
                Id    = new BookId(SequentialGuid.NewSequentialGuid()),
                Title = title ?? "Book 1"
            };

            await bookService.Handle(command);

            return(await repository.GetAsync(command.Id));
        }