public void TrackingContextIsCachedForSolicitResponseOutboundMessage() { var transmitWorkId = Guid.NewGuid().ToString(); var trackingContext = new TrackingContext { ProcessActivityId = ActivityId.NewActivityId(), ProcessingStepActivityId = ActivityId.NewActivityId(), MessagingStepActivityId = ActivityId.NewActivityId() }; MessageMock.Setup(m => m.GetProperty(BtsProperties.IsSolicitResponse)).Returns(true); MessageMock.Setup(m => m.GetProperty(BtsProperties.OutboundTransportLocation)).Returns("outbound-transport-location"); MessageMock.Setup(m => m.GetProperty(BtsProperties.TransmitWorkId)).Returns(transmitWorkId); MessageMock.Setup(m => m.GetProperty(TrackingProperties.ProcessActivityId)).Returns(trackingContext.ProcessActivityId); MessageMock.Setup(m => m.GetProperty(TrackingProperties.ProcessingStepActivityId)).Returns(trackingContext.ProcessingStepActivityId); MessageMock.Setup(m => m.GetProperty(TrackingProperties.MessagingStepActivityId)).Returns(trackingContext.MessagingStepActivityId); CacheMock.Setup(c => c.Set(transmitWorkId, trackingContext, 60 + 1)); var sut = new ActivityTracker(); sut.Execute(PipelineContextMock.Object, MessageMock.Object); CacheMock.VerifyAll(); }
public async Task InitializeAsync(WebJobsTestEnvironment testEnvironment) { RandomNameResolver nameResolver = new RandomNameResolver(); CacheMock = CreateMockFunctionDataCache(); CacheMock .Setup(c => c.IsEnabled) .Returns(true); IFunctionDataCache cache = CacheMock.Object; Host = new HostBuilder() .ConfigureDefaultTestHost <CacheableBlobsEndToEndTests>(b => { b.AddAzureStorageBlobs().AddAzureStorageQueues(); b.AddAzureStorageCoreServices(); }) .ConfigureServices(services => { services.AddSingleton <INameResolver>(nameResolver) .AddSingleton(cache); }) .Build(); JobHost = Host.GetJobHost(); BlobServiceClient = new BlobServiceClient(testEnvironment.PrimaryStorageAccountConnectionString); BlobContainer = BlobServiceClient.GetBlobContainerClient(nameResolver.ResolveInString(ContainerName)); Assert.False(await BlobContainer.ExistsAsync()); await BlobContainer.CreateAsync(); OutputBlobContainer = BlobServiceClient.GetBlobContainerClient(nameResolver.ResolveInString(OutputContainerName)); await Host.StartAsync(); // Upload some test blobs BlockBlobClient blob = BlobContainer.GetBlockBlobClient(InputBlobName); await blob.UploadTextAsync(TestData); // Get information about the uploaded blob BlobProperties blobProperties = await blob.GetPropertiesAsync(); string blobId = blob.Uri.ToString(); string blobVersion = blobProperties.ETag.ToString(); _expectedBlobCacheKey = new FunctionDataCacheKey(blobId, blobVersion); }
public void GetPlexTvShowsTests() { var cachedTv = F.Build <PlexSearch>().Without(x => x.Directory).CreateMany().ToList(); cachedTv.Add(new PlexSearch { Directory = new List <Directory1> { new Directory1 { Type = "show", Title = "title1", Year = "2016", ProviderId = "1212", Seasons = new List <Directory1>() } } }); SettingsMock.Setup(x => x.GetSettings()).Returns(F.Create <PlexSettings>()); CacheMock.Setup(x => x.Get <List <PlexSearch> >(CacheKeys.PlexLibaries)).Returns(cachedTv); var movies = Checker.GetPlexTvShows(); Assert.That(movies.Any(x => x.ProviderId == "1212")); }
public void GetPlexMoviesTests() { var cachedMovies = F.Build <PlexSearch>().Without(x => x.Directory).CreateMany().ToList(); cachedMovies.Add(new PlexSearch { Video = new List <Video> { new Video { Type = "movie", Title = "title1", Year = "2016", ProviderId = "1212" } } }); CacheMock.Setup(x => x.Get <List <PlexSearch> >(CacheKeys.PlexLibaries)).Returns(cachedMovies); SettingsMock.Setup(x => x.GetSettings()).Returns(F.Create <PlexSettings>()); var movies = Checker.GetPlexMovies(); Assert.That(movies.Any(x => x.ProviderId == "1212")); }
public async Task SendRadarrMovie() { RadarrMock.Setup(x => x.GetSettingsAsync()) .ReturnsAsync(F.Build <RadarrSettings>().With(x => x.Enabled, true).Create()); RadarrApiMock.Setup(x => x.AddMovie(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Uri>(), It.IsAny <bool>())).Returns(new RadarrAddMovie { title = "Abc" }); CacheMock.Setup(x => x.GetOrSet <List <SonarrRootFolder> >(CacheKeys.RadarrRootFolders, It.IsAny <Func <List <SonarrRootFolder> > >(), It.IsAny <int>())) .Returns(F.CreateMany <SonarrRootFolder>().ToList()); var model = F.Create <RequestedModel>(); var result = await Sender.Send(model, 2.ToString()); Assert.That(result.Result, Is.True); Assert.That(result.Error, Is.False); Assert.That(result.MovieSendingEnabled, Is.True); RadarrApiMock.Verify(x => x.AddMovie(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), 2, It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Uri>(), It.IsAny <bool>()), Times.Once); }