コード例 #1
0
        public async Task ShouldDelete()
        {
            Guid userId = Guid.NewGuid();

            _reviewRepositoryMock.GetById(Arg.Any <Guid>()).Returns(new Review("", "", 1, userId));

            Exception exception = await Record.ExceptionAsync(() => _reviewService.Delete(userId.ToString(), Guid.NewGuid().ToString()));

            Assert.Null(exception);
            _reviewRepositoryMock.Received(1).Delete(Arg.Any <Review>());
            await _reviewRepositoryMock.Received(1).Save();

            await _cacheDatabaseUtilsMock.Received(1).Remove(Arg.Any <string>());
        }
コード例 #2
0
        public async Task ShouldGetAllCommentsFromDatabase()
        {
            Comment[] insertedsComments = { new Comment("text", Guid.NewGuid(), Guid.NewGuid()) };
            _cacheDatabaseMock.Get(Arg.Any <string>()).Returns(null as string);
            _reviewRepositoryMock.AlreadyExists(Arg.Any <Guid>()).Returns(true);
            _commentRepositoryMock.CountFromReview(Arg.Any <Guid>()).Returns(1);
            _commentRepositoryMock.GetAllFromReview(Arg.Any <Guid>(), Arg.Any <PaginationDTO>()).Returns(insertedsComments);

            Exception exception = await Record.ExceptionAsync(() => _commentService.GetAllFromReview(Guid.NewGuid().ToString(), new PaginationDTO(1, 10)));

            Assert.Null(exception);
            await _cacheDatabaseMock.Received(1).Set(Arg.Any <string>(), Arg.Any <string>());

            _jsonUtilsMock.Received(1).Serialize(Arg.Any <object>());
        }