示例#1
0
 public async Task FindAync_NotAllowed()
 {
     var auth  = IAuthMock.GetIOwnedReadNotAllowed();
     var uow   = IUnitOfWorkMock.Get(IBookRepositoryMock.GetFindAsync(_book));
     var books = new Books(uow, auth);
     await Assert.ThrowsAsync <NotAllowedException>(() => books.FindAsync(new Guid()));
 }
示例#2
0
        public async Task UpdateAsync_CheckResult()
        {
            var title        = "Book's title";
            var slug         = "books-title";
            var description  = "Book's description";
            var readAccess   = Access.Private;
            var writreAccess = Access.Private;

            var auth  = IAuthMock.GetIOwnedWriteAllowed();
            var uow   = IUnitOfWorkMock.Get(IBookRepositoryMock.GetFindAsync(_book));
            var books = new Books(uow, auth);
            var cmd   = new UpdateBookCommand(_book.Id, title, slug, description, readAccess, writreAccess);
            var book  = await books.UpdateAsync(cmd);

            Assert.Equal(title, book.Title);
            Assert.Equal(slug, book.Slug);
            Assert.Equal(description, book.Description);
            Assert.Equal(readAccess, book.ReadAccess);
            Assert.Equal(writreAccess, book.WriteAccess);
        }
示例#3
0
        public async Task CreateAsync_CheckResult()
        {
            var title        = "Book's title";
            var slug         = "books-title";
            var description  = "Book's description";
            var readAccess   = Access.Private;
            var writreAccess = Access.Private;

            var uow   = IUnitOfWorkMock.Get();
            var auth  = IAuthMock.Get();
            var books = new Books(uow, auth);
            var cmd   = new CreateBookCommand(title, slug, description, readAccess, writreAccess);
            var book  = await books.CreateAsync(cmd);

            Assert.Equal(title, book.Title);
            Assert.Equal(slug, book.Slug);
            Assert.Equal(description, book.Description);
            Assert.Equal(readAccess, book.ReadAccess);
            Assert.Equal(writreAccess, book.WriteAccess);
        }