Пример #1
0
        public async Task User_Should_Not_Comment_If_Not_Allowed()
        {
            var photoService = A.Fake <IPhotoService>();
            var photo        = GetPhoto();
            var user         = GetUser();
            var guid         = Guid.NewGuid();

            A.CallTo(() => photoService.GetPhoto(photo.PhotoId)).Returns(photo);
            var reactionService = new ReactionServiceBuilder()
                                  .WithGuid(guid)
                                  .WithPhotoService(photoService)
                                  .WithPermissionsService(new AllPermissionsDeniedService())
                                  .Build();
            var comment = await reactionService.AddComment("1234", "albumId", "This photo rocks !", user);

            comment.Should().BeNull();
        }
Пример #2
0
        public async Task Comment_Should_Be_Stored()
        {
            var photoService = A.Fake <IPhotoService>();
            var photo        = GetPhoto();
            var user         = GetUser();
            var guid         = Guid.NewGuid();
            var unitOfWork   = new UnitOfWorkBuilder().Build();

            A.CallTo(() => photoService.GetPhoto(photo.PhotoId)).Returns(photo);
            var reactionService = new ReactionServiceBuilder()
                                  .WithGuid(guid)
                                  .WithPhotoService(photoService)
                                  .WithUnitOfWork(unitOfWork)
                                  .WithPermissionsService(new AllPermissionsGrantedService())
                                  .Build();
            var comment = await reactionService.AddComment("1234", "albumId", "This photo rocks !", user);

            var storedComment = await unitOfWork.Comments.GetAll(x => x.ReactionId == guid.ToString());

            storedComment.Should().NotBeNull();
            storedComment.Should().NotBeEmpty();
            storedComment.Should().ContainSingle();
            storedComment.Should().Contain(comment);
        }