Exemplo n.º 1
0
        public async Task LikeStory_ShouldThrow_IfStoryNotExist()
        {
            var storiesRepoBuilder = new StoriesRepositoryBuilder();
            var storiesRepo        = storiesRepoBuilder
                                     .WithAll()
                                     .Build();

            var userStoriesRepoBuilder = new PeopleStoriesRepositoryBuilder();
            var userStoriesRepo        = userStoriesRepoBuilder
                                         .WithAll()
                                         .Build();

            var sut = new StoriesService(storiesRepo, null, userStoriesRepo, null, Mapper);

            var user = new GoUser {
                Id = "7"
            };

            var ex = await Assert.ThrowsAsync <ArgumentException>(async() => await sut.LikeStory("17", user));

            Assert.Equal("Story not exist!", ex.Message);

            storiesRepoBuilder.StoriesRepoMock.Verify();

            userStoriesRepoBuilder.PeopleStoriesRepoMock.Verify(d => d.AddAsync(It.IsAny <PeopleStories>()), Times.Never);
            userStoriesRepoBuilder.PeopleStoriesRepoMock.Verify(d => d.SaveChangesAsync(), Times.Never);
        }
Exemplo n.º 2
0
        public async Task LikeStory_ShouldNotAddUserStory_IfUserStoryAureadyExist()
        {
            var storiesRepoBuilder = new StoriesRepositoryBuilder();
            var storiesRepo        = storiesRepoBuilder
                                     .WithAll()
                                     .Build();

            var userStoriesRepoBuilder = new PeopleStoriesRepositoryBuilder();
            var userStoriesRepo        = userStoriesRepoBuilder
                                         .WithAll()
                                         .Build();

            var sut = new StoriesService(storiesRepo, null, userStoriesRepo, null, Mapper);

            var user = new GoUser {
                Id = "9"
            };

            await sut.LikeStory("7", user);

            storiesRepoBuilder.StoriesRepoMock.Verify();

            userStoriesRepoBuilder.PeopleStoriesRepoMock.Verify(d => d.AddAsync(It.IsAny <PeopleStories>()), Times.Never);
            userStoriesRepoBuilder.PeopleStoriesRepoMock.Verify(d => d.SaveChangesAsync(), Times.Never);
        }
Exemplo n.º 3
0
        public async Task LikeStory_ShouldAddNew_UserStory()
        {
            var storiesRepoBuilder = new StoriesRepositoryBuilder();
            var storiesRepo        = storiesRepoBuilder
                                     .WithAll()
                                     .Build();

            var userStoriesRepoBuilder = new PeopleStoriesRepositoryBuilder();
            var userStoriesRepo        = userStoriesRepoBuilder
                                         .WithAll()
                                         .Build();

            var sut = new StoriesService(storiesRepo, null, userStoriesRepo, null, Mapper);

            var user = new GoUser {
                Id = "7"
            };

            await sut.LikeStory("2", user);

            userStoriesRepoBuilder.PeopleStoriesRepoMock.Verify(r => r.AddAsync(It.IsAny <PeopleStories>()), Times.Once);

            userStoriesRepoBuilder.PeopleStoriesRepoMock.Verify(r => r.AddAsync(It.IsAny <PeopleStories>()), Times.Once);
        }