示例#1
0
        public void Setup()
        {
            F = new Fixture();
            VoteRepository     = new Mock <IRepository <Votes> >();
            VoteSettings       = new Mock <ISettingsService <VoteSettings> >();
            MusicRequestEngine = new Mock <IMusicRequestEngine>();
            TvRequestEngine    = new Mock <ITvRequestEngine>();
            MovieRequestEngine = new Mock <IMovieRequestEngine>();
            MovieRequestEngine = new Mock <IMovieRequestEngine>();
            User = new Mock <ICurrentUser>();
            User.Setup(x => x.GetUser()).ReturnsAsync(new OmbiUser {
                UserName = "******", NormalizedUserName = "******", Id = "abc"
            });

            UserManager = MockHelper.MockUserManager(new List <OmbiUser> {
                new OmbiUser {
                    Id = "abc", UserName = "******", NormalizedUserName = "******"
                }
            });
            Rule   = new Mock <IRuleEvaluator>();
            Engine = new VoteEngine(VoteRepository.Object, User.Object, UserManager.Object, Rule.Object, VoteSettings.Object, MusicRequestEngine.Object,
                                    TvRequestEngine.Object, MovieRequestEngine.Object);

            F.Behaviors.OfType <ThrowingRecursionBehavior>().ToList()
            .ForEach(b => F.Behaviors.Remove(b));
            F.Behaviors.Add(new OmitOnRecursionBehavior());
        }
示例#2
0
        public async Task <RequestEngineResult> RequestMovie([FromBody] MovieRequestViewModel movie)
        {
            var result = await MovieRequestEngine.RequestMovie(movie);

            if (result.Result)
            {
                var voteResult = await VoteEngine.UpVote(result.RequestId, RequestType.Movie);

                if (voteResult.IsError)
                {
                    Log.LogError("Couldn't automatically add the vote for the movie {0} because {1}", movie.TheMovieDbId, voteResult.ErrorMessage);
                }
            }

            return(result);
        }
示例#3
0
        public async Task <RequestEngineResult> RequestTv([FromBody] TvRequestViewModel tv)
        {
            var result = await TvRequestEngine.RequestTvShow(tv);

            if (result.Result)
            {
                var voteResult = await VoteEngine.UpVote(result.RequestId, RequestType.TvShow);

                if (voteResult.IsError)
                {
                    Log.LogError("Couldn't automatically add the vote for the tv {0} because {1}", tv.TvDbId, voteResult.ErrorMessage);
                }
            }

            return(result);
        }
示例#4
0
 public void Setup()
 {
     F = new Fixture();
     VoteRepository     = new Mock <IRepository <Votes> >();
     VoteSettings       = new Mock <ISettingsService <VoteSettings> >();
     MusicRequestEngine = new Mock <IMusicRequestEngine>();
     TvRequestEngine    = new Mock <ITvRequestEngine>();
     MovieRequestEngine = new Mock <IMovieRequestEngine>();
     MovieRequestEngine = new Mock <IMovieRequestEngine>();
     User        = new Mock <IPrincipal>();
     UserManager = new Mock <OmbiUserManager>();
     UserManager.Setup(x => x.Users)
     .Returns(new EnumerableQuery <OmbiUser>(new List <OmbiUser> {
         new OmbiUser {
             Id = "abc"
         }
     }));
     Rule   = new Mock <IRuleEvaluator>();
     Engine = new VoteEngine(VoteRepository.Object, User.Object, UserManager.Object, Rule.Object, VoteSettings.Object, MusicRequestEngine.Object,
                             TvRequestEngine.Object, MovieRequestEngine.Object);
 }