diff options
author | crupest <crupest@outlook.com> | 2019-04-24 00:22:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-04-24 00:22:25 +0800 |
commit | 3d6938ca60691f73bc0b570e7ca4af4f8251741c (patch) | |
tree | f0b1f683254cdd80f20ea84ea6e044e80ef61fdd /Timeline.Tests/QCloudCosServiceUnitTest.cs | |
parent | 94cb3d601af2f658f93f8092f39c326c90c8d13f (diff) | |
download | timeline-3d6938ca60691f73bc0b570e7ca4af4f8251741c.tar.gz timeline-3d6938ca60691f73bc0b570e7ca4af4f8251741c.tar.bz2 timeline-3d6938ca60691f73bc0b570e7ca4af4f8251741c.zip |
Add ObjectExists implementation in cos. Remove Test host environment.
Diffstat (limited to 'Timeline.Tests/QCloudCosServiceUnitTest.cs')
-rw-r--r-- | Timeline.Tests/QCloudCosServiceUnitTest.cs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/Timeline.Tests/QCloudCosServiceUnitTest.cs b/Timeline.Tests/QCloudCosServiceUnitTest.cs index c02f70be..b99352b9 100644 --- a/Timeline.Tests/QCloudCosServiceUnitTest.cs +++ b/Timeline.Tests/QCloudCosServiceUnitTest.cs @@ -1,12 +1,24 @@ -using System; +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.DependencyInjection; +using System; using System.Collections.Generic; +using System.Threading.Tasks; using Timeline.Services; +using Timeline.Tests.Helpers; using Xunit; +using Xunit.Abstractions; namespace Timeline.Tests { - public class QCloudCosServiceUnitTest + public class QCloudCosServiceUnitTest : IClassFixture<WebApplicationFactory<Startup>> { + private readonly WebApplicationFactory<Startup> _factory; + + public QCloudCosServiceUnitTest(WebApplicationFactory<Startup> factory, ITestOutputHelper outputHelper) + { + _factory = factory.WithTestConfig(outputHelper); + } + [Fact] public void GenerateSignatureTest() { @@ -37,5 +49,22 @@ namespace Timeline.Tests Assert.Equal("q-sign-algorithm=sha1&q-ak=AKIDQjz3ltompVjBni5LitkWHFlFpwkn9U5q&q-sign-time=1417773892;1417853898&q-key-time=1417773892;1417853898&q-header-list=host;x-cos-content-sha1;x-cos-storage-class&q-url-param-list=&q-signature=0ab12f43e74cbe148d705cd9fae8adc9a6d39cc1", QCloudCosService.GenerateSign(credential, request, signValidTime)); } + + /* + [Fact] + public async Task ObjectExistsTest() + { + _factory.CreateDefaultClient().Dispose(); + + using (var serviceScope = _factory.Server.Host.Services.CreateScope()) + { + var services = serviceScope.ServiceProvider; + var service = services.GetRequiredService<IQCloudCosService>(); + Assert.True(await service.ObjectExists("avatar", "__default")); + Assert.False(await service.ObjectExists("avatar", "haha")); + Assert.False(await service.ObjectExists("haha", "haha")); + } + } + */ } } |