public void Parse_No_Services() { var sourceService = new Mock <ISourceService>(); var input = "hot fuzz"; sourceService.Setup(x => x.Query(input)).Returns(new SourceResponse { Items = new List <WatchItem> { new WatchItem { Title = "Hot Fuzz", Offers = new List <Offer> { new Offer { MonetizationType = MonetizationType.FlatRate, Urls = new SourceUrls { StandardWeb = "netflix" } }, new Offer { MonetizationType = MonetizationType.FlatRate, Urls = new SourceUrls { StandardWeb = "amazon" } }, }, } } }); var userService = new Mock <IUserService>(); userService.Setup(x => x.GetUserServicePreferences(It.IsAny <long>())) .Returns(new[] { new UserServicePreference { Preference = -1, MonetizationType = new MonetizationType { TypeName = MonetizationType.FlatRate }, Service = new Service { Name = "amazon", Urls = { new ServiceUrl { Url = "amazon" //todo: fix so .com works } } }, }, new UserServicePreference { Preference = -1, MonetizationType = new MonetizationType { TypeName = MonetizationType.FlatRate }, Service = new Service { Name = "netflix", Urls = { new ServiceUrl { Url = "netflix" //todo: fix so .com works } } }, }, }); var service = new WatchService(sourceService.Object, userService.Object, GetStreamingServiceService()); var result = service.GetHowToWatch(input, 1); //order of result is changed based on the provided user preference result.Should().Be("Hot Fuzz is not available on any of your flat rate streaming services"); }
public void Parse_AvoidService() { var sourceService = new Mock <ISourceService>(); var input = "hot fuzz"; sourceService.Setup(x => x.Query(input)).Returns(new SourceResponse { Items = new List <WatchItem> { new WatchItem { Title = "Hot Fuzz", Offers = new List <Offer> { new Offer { MonetizationType = MonetizationType.FlatRate, Urls = new SourceUrls { StandardWeb = "netflix" } }, new Offer { MonetizationType = MonetizationType.FlatRate, Urls = new SourceUrls { StandardWeb = "amazon" } }, }, } } }); var userService = new Mock <IUserService>(); userService.Setup(x => x.GetUserServicePreferences(It.IsAny <long>())) .Returns(new[] { new UserServicePreference { MonetizationType = new MonetizationType { TypeName = MonetizationType.FlatRate }, Service = new Service { Name = "amazon", Urls = { new ServiceUrl { Url = "amazon" //todo: fix so .com works } } }, Preference = -1, } }); var service = new WatchService(sourceService.Object, userService.Object, GetStreamingServiceService()); var result = service.GetHowToWatch(input, 1); result.Should().Be("Hot Fuzz can be watched for free on Netflix"); }