From fc64b2e82d6e000b088037c496aa88eb4f1c5f33 Mon Sep 17 00:00:00 2001 From: "sam.gerene" Date: Sun, 18 Feb 2018 11:13:42 +0100 Subject: [PATCH] [Update] unittest categories add WebServicesDependent --- .../CdpServicesDalTestFixture.cs | 8 +++-- .../CdpServicesDalTestFixture.cs | 8 +++-- .../SessionTestFixture.cs | 2 +- CDP4WspDal.NetCore.Tests/WSPDalTestFixture.cs | 34 ++++++++----------- CDP4WspDal.Tests/SessionTestFixture.cs | 2 +- CDP4WspDal.Tests/WSPDalTestFixture.cs | 2 ++ appveyor.yml | 1 + 7 files changed, 30 insertions(+), 27 deletions(-) diff --git a/CDP4ServicesDal.NetCore.Tests/CdpServicesDalTestFixture.cs b/CDP4ServicesDal.NetCore.Tests/CdpServicesDalTestFixture.cs index b11a13c76..e2c4c6c5b 100644 --- a/CDP4ServicesDal.NetCore.Tests/CdpServicesDalTestFixture.cs +++ b/CDP4ServicesDal.NetCore.Tests/CdpServicesDalTestFixture.cs @@ -127,6 +127,7 @@ public void VerifyThatCdpServicesDalCanBeConstructed() } [Test] + [Category("WebServicesDependent")] public async Task VerifyThatOpenReturnsDTOs() { var uriBuilder = new UriBuilder(this.credentials.Uri) { Path = "/Data/Restore" }; @@ -143,6 +144,7 @@ public async Task VerifyThatOpenReturnsDTOs() } [Test] + [Category("WebServicesDependent")] public async Task VerifThatAClosedDalCannotBeClosedAgain() { var dal = new CdpServicesDal(); @@ -522,6 +524,7 @@ public void VerifyThatWritingMultipleOperationContainersIsNotSupported() } [Test] + [Category("WebServicesDependent")] public async Task Verify_that_opens_returns_expected_result() { var uri = new Uri("https://cdp4services-test.rheagroup.com"); @@ -532,10 +535,9 @@ public async Task Verify_that_opens_returns_expected_result() Assert.NotNull(result); } - - ///EngineeringModel/9ec982e4-ef72-4953-aa85-b158a95d8d56/iteration - + [Test] + [Category("WebServicesDependent")] public async Task Verify_that_multiple_read_requests_can_be_made_in_parallel() { var uri = new Uri("https://cdp4services-test.rheagroup.com"); diff --git a/CDP4ServicesDal.Tests/CdpServicesDalTestFixture.cs b/CDP4ServicesDal.Tests/CdpServicesDalTestFixture.cs index d27fbe9a2..f1ded6e6d 100644 --- a/CDP4ServicesDal.Tests/CdpServicesDalTestFixture.cs +++ b/CDP4ServicesDal.Tests/CdpServicesDalTestFixture.cs @@ -127,6 +127,7 @@ public void VerifyThatCdpServicesDalCanBeConstructed() } [Test] + [Category("WebServicesDependent")] public async Task VerifyThatOpenReturnsDTOs() { var uriBuilder = new UriBuilder(this.credentials.Uri) { Path = "/Data/Restore" }; @@ -143,6 +144,7 @@ public async Task VerifyThatOpenReturnsDTOs() } [Test] + [Category("WebServicesDependent")] public async Task VerifThatAClosedDalCannotBeClosedAgain() { var dal = new CdpServicesDal(); @@ -522,6 +524,7 @@ public void VerifyThatWritingMultipleOperationContainersIsNotSupported() } [Test] + [Category("WebServicesDependent")] public async Task Verify_that_opens_returns_expected_result() { var uri = new Uri("https://cdp4services-test.rheagroup.com"); @@ -532,10 +535,9 @@ public async Task Verify_that_opens_returns_expected_result() Assert.NotNull(result); } - - ///EngineeringModel/9ec982e4-ef72-4953-aa85-b158a95d8d56/iteration - + [Test] + [Category("WebServicesDependent")] public async Task Verify_that_multiple_read_requests_can_be_made_in_parallel() { var uri = new Uri("https://cdp4services-test.rheagroup.com"); diff --git a/CDP4WspDal.NetCore.Tests/SessionTestFixture.cs b/CDP4WspDal.NetCore.Tests/SessionTestFixture.cs index 59f263be7..2123d52d7 100644 --- a/CDP4WspDal.NetCore.Tests/SessionTestFixture.cs +++ b/CDP4WspDal.NetCore.Tests/SessionTestFixture.cs @@ -83,7 +83,7 @@ public void TearDown() /// The . /// [Test] - [Category("WSP_dependent")] + [Category("WebServicesDependent")] public async Task Verify_That_Session_Open_Populates_cache() { var dal = new WspDal(); diff --git a/CDP4WspDal.NetCore.Tests/WSPDalTestFixture.cs b/CDP4WspDal.NetCore.Tests/WSPDalTestFixture.cs index efee3b4ef..6d9f5b95c 100644 --- a/CDP4WspDal.NetCore.Tests/WSPDalTestFixture.cs +++ b/CDP4WspDal.NetCore.Tests/WSPDalTestFixture.cs @@ -31,7 +31,9 @@ namespace CDP4WspDal.Tests using System.Diagnostics; using System.IO; using System.Linq; - using System.Reflection; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Text; using System.Threading; using System.Threading.Tasks; using CDP4Common.CommonData; @@ -126,8 +128,14 @@ public void VerifyThatCdpServicesDalCanBeConstructed() } [Test] + [Category("WebServicesDependent")] public async Task VerifyThatOpenReturnsDTOs() { + var uriBuilder = new UriBuilder(this.credentials.Uri) { Path = "/Data/Restore" }; + var httpClient = new HttpClient(); + httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes($"{credentials.UserName}:{credentials.Password}"))); + await httpClient.PostAsync(uriBuilder.Uri, null); + var dal = new WspDal(); var result = await dal.Open(this.credentials, new CancellationToken()); @@ -137,6 +145,7 @@ public async Task VerifyThatOpenReturnsDTOs() } [Test] + [Category("WebServicesDependent")] public async Task VerifThatAClosedDalCannotBeClosedAgain() { var dal = new WspDal(); @@ -207,7 +216,7 @@ public void VerifyThatAWspThatIsNotOpenCannotBeClosed() } [Test] - [Category("WSP_dependent")] + [Category("WebServicesDependent")] public async Task VerifyThatReadReturnsCorrectDTO() { this.dal = new WspDal(); @@ -244,7 +253,7 @@ public async Task VerifyThatReadReturnsCorrectDTO() /// Verify that the App does not crash /// [Test] - [Category("WSP_dependent")] + [Category("WebServicesDependent")] public async Task IntegrationTest() { this.dal = new WspDal(); @@ -359,7 +368,7 @@ public void VerifyThatWSPPostBodyIsCorrectlyResolves() } [Test] - [Category("WSP_dependent")] + [Category("WebServicesDependent")] public async Task VerifyThatReadIterationWorks() { var dal = new WspDal { Session = this.session }; @@ -388,7 +397,7 @@ public async Task VerifyThatReadIterationWorks() } [Test] - [Category("WSP_dependent")] + [Category("WebServicesDependent")] [Category("Performance")] public async Task AssemblerSynchronizePerformanceTest() { @@ -501,7 +510,7 @@ public void VerifyThatWritingMultipleOperationContainersIsNotSupported() } [Test] - [Category("WSP_dependent")] + [Category("WebServicesDependent")] public async Task Verify_that_person_can_be_Posted() { var uri = new Uri("http://ocdt-dev.rheagroup.com"); @@ -547,18 +556,5 @@ private void SetDalToBeOpen(WspDal dal) var credentialsProperty = typeof(WspDal).GetProperty("Credentials"); credentialsProperty.SetValue(dal, this.credentials); } - - /// - /// Gets the directory of the executing assembly - /// - /// - private string GetAssemblyDirectory() - { - string codeBase = Assembly.GetExecutingAssembly().CodeBase; - var uri = new UriBuilder(codeBase); - string path = Uri.UnescapeDataString(uri.Path); - var directory = Path.GetDirectoryName(path); - return directory; - } } } \ No newline at end of file diff --git a/CDP4WspDal.Tests/SessionTestFixture.cs b/CDP4WspDal.Tests/SessionTestFixture.cs index 59f263be7..2123d52d7 100644 --- a/CDP4WspDal.Tests/SessionTestFixture.cs +++ b/CDP4WspDal.Tests/SessionTestFixture.cs @@ -83,7 +83,7 @@ public void TearDown() /// The . /// [Test] - [Category("WSP_dependent")] + [Category("WebServicesDependent")] public async Task Verify_That_Session_Open_Populates_cache() { var dal = new WspDal(); diff --git a/CDP4WspDal.Tests/WSPDalTestFixture.cs b/CDP4WspDal.Tests/WSPDalTestFixture.cs index 3528e72a3..fe1833e9b 100644 --- a/CDP4WspDal.Tests/WSPDalTestFixture.cs +++ b/CDP4WspDal.Tests/WSPDalTestFixture.cs @@ -128,6 +128,7 @@ public void VerifyThatCdpServicesDalCanBeConstructed() } [Test] + [Category("WebServicesDependent")] public async Task VerifyThatOpenReturnsDTOs() { var uriBuilder = new UriBuilder(this.credentials.Uri) { Path = "/Data/Restore" }; @@ -144,6 +145,7 @@ public async Task VerifyThatOpenReturnsDTOs() } [Test] + [Category("WebServicesDependent")] public async Task VerifThatAClosedDalCannotBeClosedAgain() { var dal = new WspDal(); diff --git a/appveyor.yml b/appveyor.yml index 0945069e1..93163220f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -32,6 +32,7 @@ test: categories: except: - WebServicesDependent + - AppVeyorExclusion after_test: - .\tools\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:user -target:".\tools\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe" -targetargs:".\CDP4Common.Tests\bin\Debug\net462\CDP4Common.Tests.dll .\CDP4JsonSerializer.Tests\bin\Debug\net462\CDP4JsonSerializer.Tests.dll " -filter:"+[CDP4Common*]* -[CDP4Common.Tests*]* +[CDP4JsonSerializer*]* -[CDP4JsonSerializer.Tests*]* " -output:"coverage.xml" - codecov -f "coverage.xml" -t b8924a0f-355e-4a9a-b304-f403231a6bcb