Esempio n. 1
0
        public async Task Should_Create_A_Valid_Book()
        {
            var result = await _bookAppService.CreateAsync(
                new CreateUpdateBookDto {
                Name        = "New test book 3",
                Price       = 10.3F,
                PublishDate = DateTime.Now,
                Type        = BookType.ScienceFiction
            });

            //Assert
            result.Id.ShouldBeGreaterThan(0);
            result.Name.ShouldBe("New test book 3");
        }
Esempio n. 2
0
        public async Task Should_Create_A_Valid_Book()
        {
            var result = await _bookAppService.CreateAsync(
                new CreateUpdateBookDto
            {
                Name        = "New test book 42",
                Price       = 10,
                PublishDate = System.DateTime.Now,
                Type        = BookType.ScienceFiction
            }
                );

            result.Id.ShouldNotBe(Guid.Empty);
            result.Name.ShouldBe("New test book 42");
        }
Esempio n. 3
0
        public async Task Should_Create_A_Valid_Book()
        {
            // Act
            var result = await _bookAppService.CreateAsync(new CreateUpdateBookDto
            {
                Name        = "Deep into C#",
                Price       = 30.09f,
                PublishDate = new DateTime(2009, 8, 3),
                Type        = BookType.ScienceFiction
            });

            // Assert
            result.Id.ShouldNotBe(Guid.Empty);
            result.Name.ShouldBe("Deep into C#");
        }
        public virtual async Task <IActionResult> OnPostAsync()
        {
            var dto = ObjectMapper.Map <CreateEditBookViewModel, CreateUpdateBookDto>(ViewModel);
            await _service.CreateAsync(dto);

            return(NoContent());
        }
Esempio n. 5
0
        public async Task Should_Create_A_Valid_Book()
        {
            //Action
            var result = await _bookAppService.CreateAsync(
                new CreateUpdateBookDto
            {
                Name        = "The Kite Runner",
                Price       = 90,
                PublishDate = DateTime.Now,
                Type        = BookType.Fantastic
            }
                );

            //Assert
            result.Id.ShouldNotBe(Guid.Empty);
            result.Name.ShouldBe("The Kite Runner");
        }
Esempio n. 6
0
        public async Task Should_Create_A_Valid_Book()
        {
            //Act
            var result = await _bookAppService.CreateAsync(
                new CreateUpdateBookDto
            {
                Name        = "Test Book X1",
                Price       = 12,
                PublishDate = DateTime.Now,
                Type        = BookType.Horror
            }
                );

            //Assert
            result.Id.ShouldNotBe(Guid.Empty);
            result.Name.ShouldBe("Test Book X1");
        }
        public async Task Should_Create_A_Valid_Book()
        {
            var authors = await _authorAppService.GetListAsync(new GetAuthorListDto());

            var firstAuthor = authors.Items.First();

            var result = await _bookAppService.CreateAsync(new CreateUpdateBookDto()
            {
                AuthorId    = firstAuthor.Id,
                Name        = "2021科幻之旅",
                Type        = BookType.ScienceFiction,
                PublishDate = DateTime.Now,
                Price       = 11,
                IsTrue      = BookIsTrue.True
            });

            result.Id.ShouldNotBe(Guid.Empty);
            result.Name.ShouldBe("2021科幻之旅");
        }
        public async Task Should_Create_A_Valid_Book()
        {
            var authors = await _authorAppService.GetListAsync(new GetAuthorListDto());

            var firstAuthor = authors.Items.First();
            //Act
            var result = await _bookAppService.CreateAsync(
                new CreateUpdateBookDto
            {
                AuthorId    = firstAuthor.Id,
                Name        = "New test book 42",
                Price       = 10,
                PublishDate = System.DateTime.Now,
                Type        = BookType.ScienceFiction
            }
                );

            //Assert
            result.Id.ShouldNotBe(Guid.Empty);
            result.Name.ShouldBe("New test book 42");
        }
        public async Task Should_Create_A_Book()
        {
            var book = new CreateUpdateBookDto
            {
                Name        = "大话设计模式",
                Type        = BookType.Science,
                PublishDate = new DateTime(2007, 12, 1)
            };

            var result = await bookAppService.CreateAsync(book);

            result.Id.ShouldNotBe(Guid.Empty);
        }
Esempio n. 10
0
        public async Task Should_Create_A_Valid_Book()
        {
            var result = await _bookAppService.CreateAsync(new CreateUpdateBookDto()
            {
                Name        = "New test book 42",
                Price       = 23,
                PublishDate = DateTime.Now,
                Type        = BookType.Adventure
            });

            result.Id.ShouldNotBe(Guid.Empty);
            result.Name.ShouldBe("New test book 42");
        }
Esempio n. 11
0
        public async Task Should_Not_Create_A_BookMark_Without_Name()
        {
            var exception = await Assert.ThrowsAsync <AbpValidationException>(async() => {
                await _bookAppService.CreateAsync(
                    new CreateUpdateBookDto()
                {
                    Name        = "",
                    Type        = BookType.ScienceFiction,
                    PublishDate = DateTime.Now,
                    Price       = 11,
                });
            });

            exception.ValidationErrors.ShouldContain(err => err.MemberNames.Any(mem => mem == "Name"));
        }
        public async Task CreateAsync()
        {
            // Arrange
            var input = new BookCreateDto
            {
                Name = "daa85fbc8e654886af6caedd2a8e0e5c1af2850a74dd408a9fd6c979f5bc455ead802f60c95e4e26964125f2bee0e10ad55d"
            };

            // Act
            var serviceResult = await _bookAppService.CreateAsync(input);

            // Assert
            var result = await _bookRepository.FindAsync(c => c.Id == serviceResult.Id);

            result.ShouldNotBe(null);
            result.Name.ShouldBe("daa85fbc8e654886af6caedd2a8e0e5c1af2850a74dd408a9fd6c979f5bc455ead802f60c95e4e26964125f2bee0e10ad55d");
        }
Esempio n. 13
0
        public async Task <IActionResult> OnPostAsync()
        {
            await _bookAppService.CreateAsync(Book);

            return(NoContent());
        }
Esempio n. 14
0
 public async Task <BookDto> CreateAsync(CreateUpdateBookDto input)
 {
     return(await _bookAppService.CreateAsync(input));
 }
Esempio n. 15
0
 public virtual Task <BookDto> CreateAsync(BookCreateDto input)
 {
     return(_bookAppService.CreateAsync(input));
 }
Esempio n. 16
0
 public Task <BookDto> CreateAsync(CreateUpdateBookDto input)
 {
     return(_service.CreateAsync(input));
 }