public async Task ListFilesInSingleRequest() { var httpClient = Substitute.For <IHttpClientHelper>(); var container = TestBootstrapper.Init(httpClient); var dropboxResponse = new DropboxApiResponseListFiles { entries = new[] { new Entry { name = "Item 1" } } }; httpClient.PostAsync(new Uri("https://api.dropboxapi.com/2/files/list_folder"), @"{""path"":"""", ""recursive"": true}", Arg.Any <string>(), Arg.Any <CancellationToken>()) .Returns(Task.FromResult(JsonConvert.SerializeObject(dropboxResponse))); var sut = container.Resolve <IDropboxHelper>(); var files = await sut.GetFilesAsync("", CancellationToken.None); Assert.NotEmpty(files); Assert.Equal(1, files.Count); Assert.Equal("Item 1", files[0].Name); }
public async Task MigrateAsync() { var container = TestBootstrapper.Init(); var destRepo = container.ResolveNamed <IBlogPostRepository>("SqlServer") as BlogPostSqlServerRepository; await destRepo.UpdateDatabaseAsync(CancellationToken.None); }
public async Task ListFilesOverMultipleRequests() { var httpClient = Substitute.For <IHttpClientHelper>(); var container = TestBootstrapper.Init(httpClient); var dropboxResponse = new DropboxApiResponseListFiles { has_more = true, cursor = "mycursor", entries = new[] { new Entry { name = "Item 1" }, new Entry { name = "Item 2" }, new Entry { name = "Item 3" }, } }; var dropboxResponse2 = new DropboxApiResponseListFiles { has_more = false, cursor = "", entries = new[] { new Entry { name = "Item 4" }, new Entry { name = "Item 5" }, } }; httpClient.PostAsync(new Uri("https://api.dropboxapi.com/2/files/list_folder"), @"{""path"":"""", ""recursive"": true}", Arg.Any <string>(), Arg.Any <CancellationToken>()) .Returns(Task.FromResult(JsonConvert.SerializeObject(dropboxResponse))); httpClient.PostAsync(new Uri("https://api.dropboxapi.com/2/files/list_folder/continue"), @"{""cursor"": ""mycursor""}", Arg.Any <string>(), Arg.Any <CancellationToken>()) .Returns(Task.FromResult(JsonConvert.SerializeObject(dropboxResponse2))); var sut = container.Resolve <IDropboxHelper>(); var files = await sut.GetFilesAsync("", CancellationToken.None); Assert.NotEmpty(files); Assert.Equal(5, files.Count); Assert.Equal("Item 1", files[0].Name); Assert.Equal("Item 2", files[1].Name); Assert.Equal("Item 3", files[2].Name); Assert.Equal("Item 4", files[3].Name); Assert.Equal("Item 5", files[4].Name); }
public void UpdateImagePathsTests(string source, string imageFolder, string expectedResult) { var container = TestBootstrapper.Init(); var renderer = container.Resolve <IBlogPostRenderer>() as BlogPostMarkdownRenderer; var result = renderer?.UpdateImagePaths(source, imageFolder); Assert.Equal(expectedResult, result); }
public async Task ListFiles() { var httpClient = new HttpClientHelper(); var container = TestBootstrapper.Init(httpClient); var sut = container.Resolve <IDropboxHelper>(); var files = await sut.GetFilesAsync("", CancellationToken.None); Assert.NotEmpty(files); }
public void GetSummaryText_WhenContentIsLessThanSummarySize() { var container = TestBootstrapper.Init(); var settings = container.Resolve <Settings>(); var sut = new BlogPostSummaryHelper(settings); var result = sut.GetSummaryText("abc"); Assert.Equal("abc", result); }
public async Task GivenAMeetupEventId_WithRSVPs_ThenResultsShouldHaveValues() { var container = TestBootstrapper.Init(); var factory = container.Resolve <ITileProviderFactory>(); var sut = factory.CreateMeetupComTileProvider(242414971); var tiles = await sut.GetTilesAsync(); Assert.That(tiles.Count, Is.GreaterThan(0)); }
public async Task GetPosts() { var container = TestBootstrapper.Init(); var repo = container.ResolveNamed <IBlogPostRepository>("SqlServer"); var posts = await repo.GetAllAsync(null, CancellationToken.None); foreach (var post in posts) { Console.WriteLine(post.Title); } }
public async Task RssGeneratorTests() { var container = TestBootstrapper.Init(); var settings = container.Resolve <Settings>(); var sut = container.Resolve <IFeedGenerator>(); var results = await sut.GenerateRssAsync(CancellationToken.None); Assert.NotNull(results); Assert.StartsWith("<?xml", results); Assert.Contains(settings.SiteHomeUri, results); }
public async Task RunSync() { var container = TestBootstrapper.Init(); var sourceRepo = container.ResolveNamed <IBlogPostRepository>("Dropbox"); var destRepo = (BlogPostSqlServerRepository)container.ResolveNamed <IBlogPostRepository>("SqlServer"); //destRepo.CreateDatabase(); //await destRepo.UpdateDatabaseAsync(CancellationToken.None); var helper = container.Resolve <SyncHelper>(); await helper.SynchronizeBlogPostsAsync(sourceRepo, destRepo, false, null, CancellationToken.None); }
public async Task IncrementalSyncTest() { var container = TestBootstrapper.Init(); var sourceRepo = container.ResolveNamed <IBlogPostRepository>("Dropbox"); var destRepo = (BlogPostSqlServerRepository)container.ResolveNamed <IBlogPostRepository>("SqlServer"); //destRepo.CreateDatabase(); //await destRepo.UpdateDatabaseAsync(CancellationToken.None); var helper = container.Resolve <SyncHelper>(); // Grab this from the database, then make a change in Dropbox to manually test the incremental sync const string testCursor = "AAEr_QdeOumu08_iV7Ah9wDoQ8zbWmBs2dtILwYs3e9ij-ZmBIT-93Ova_DP37JJG3sPeetCRZDYICDWc0BtmLAP03LvTw6oqHhSI8EF_YLZxInkyEr9-G5fhpLdVTiO4Rui9FmZTnEAakQB8437HUBb"; await helper.SynchronizeBlogPostsAsync(sourceRepo, destRepo, true, testCursor, CancellationToken.None); }
public async Task AddPost() { var container = TestBootstrapper.Init(); var post = new BlogPost { Id = Guid.NewGuid(), Title = "My Post", Route = "/mypost", HtmlText = "<body>Post Body</body>", HtmlShortText = "short body", PublishDate = new DateTime(2017, 03, 07) }; var repo = container.ResolveNamed <IBlogPostRepository>("SqlServer"); await repo.AddOrUpdateAsync(post, CancellationToken.None); }