コード例 #1
0
        public static void ClassCleanup()
        {
            using (var serviceScope = _factory.Server.Services.CreateScope())
            {
                var sqlExecuter = serviceScope.ServiceProvider.GetService <IRhetosComponent <ISqlExecuter> >().Value;

                sqlExecuter.ExecuteSql($@"
                    DELETE pp
                    FROM 
                        Common.PrincipalPermission pp
                        INNER JOIN Common.Principal p ON pp.PrincipalID = p.ID
                    WHERE p.Name like '{RandomNamePrefix}%';

                    DELETE m
                    FROM 
                        dbo.webpages_Membership m
                        INNER JOIN Common.Principal p ON p.AspNetUserId = m.UserId
                    WHERE p.Name like '{RandomNamePrefix}%';

                    DELETE p
                    FROM 
                        Common.Principal p
                    WHERE p.Name like '{RandomNamePrefix}%';");

                serviceScope.ServiceProvider.GetService <IRhetosComponent <IUnitOfWork> >().Value.CommitAndClose();
            }

            _factory.Dispose();
        }
コード例 #2
0
        /// <summary>
        /// This method must be implemented to satisfy the compiler because it's the only way to safely ensure that
        /// any future child classes will can have the ability to properly clean up their parent classes via Dispose().
        /// </summary>
        protected void Dispose(bool disposing)
        {
            // Ensure we don't get disposed of multiple times, which could cause memory leaks or null pointer exceptions.
            if (_isDisposed)
            {
                return;
            }

            // Only call Dispose() on other managed objects if we're told to.
            if (disposing)
            {
                // free managed resources
                _factory.Dispose();
            }

            // This location in the code is where you should always clean up any unmanaged resources, regardless of the state of
            // the `disposing` parameter.
            // If your code does hold references to unmanaged resources, you MUST also implement the finalizer yourself as follows:
            //
            // public ~TestClientManager()
            // {
            //     Dispose(false);
            // }
            //
            // This ensures that you will always clean up unmanaged resources when being destroyed by the garbage collector,
            // preventing memory leaks. If your class does NOT directly handle unmanaged resources, do not implement the finalizer.

            _isDisposed = true;
        }
コード例 #3
0
        public void Dispose()
        {
            factory?.Dispose();

            var client = new MongoClient(settings.ConnectionString);

            client.DropDatabase(settings.Database);
        }
コード例 #4
0
        public void Dispose()
        {
            ServiceProvider.GetService <ILogger <TestApplicationHost> >()
            ?.LogInformation($"Disposing test host ({_testMethodName}).");

            _sqliteConnection?.Dispose();
            _applicationFactory?.Dispose();
        }
コード例 #5
0
        public override void Dispose()
        {
            _agent?.Dispose();
            _factory?.Dispose();
            _client?.Dispose();

            base.Dispose();
        }
コード例 #6
0
ファイル: WebHostTestBase.cs プロジェクト: HelloMoonGame/api
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         Client?.Dispose();
         Factory?.Dispose();
     }
 }
コード例 #7
0
 public static void Cleanup()
 {
     ClientFactory?.Dispose();
     AdminClient?.Dispose();
     UserClient?.Dispose();
     ClientFactory = null;
     AdminClient   = null;
     UserClient    = null;
 }
コード例 #8
0
 public void Dispose()
 {
     if (!_disposed)
     {
         _client?.Dispose();
         _factory?.Dispose();
         _disposed = true;
     }
 }
コード例 #9
0
ファイル: WebHostTestBase.cs プロジェクト: HelloMoonGame/api
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         MailServiceMock.MailsSent.Clear();
         Client?.Dispose();
         Factory?.Dispose();
     }
 }
コード例 #10
0
        public void TearDown()
        {
            BearerToken = null;

            if (TestFactory != null)
            {
                TestFactory.Dispose();
                TestFactory = null;
            }
        }
 public void TearDown()
 {
     if (_storageClient != null)
     {
         _storageClient.Dispose();
     }
     if (_apiFactory != null)
     {
         _apiFactory.Dispose();
     }
 }
コード例 #12
0
        public void Shutdown()
        {
            _easyServices?.Dispose();
            _blankFactory?.Dispose();
            _carterFactory?.Dispose();
            _easyRoutingServices?.Dispose();

            _easyClient?.Dispose();
            _blankClient?.Dispose();
            _carterClient?.Dispose();
            _easyRoutingClient?.Dispose();
        }
コード例 #13
0
        protected virtual void Dispose(bool aIsDisposing)
        {
            if (!DisposedValue)
            {
                if (aIsDisposing)
                {
                    ServerWebApplicationFactory.Dispose();
                }

                DisposedValue = true;
            }
        }
コード例 #14
0
 private void Dispose(bool aIsDisposing)
 {
     if (!Disposed)
     {
         if (aIsDisposing)
         {
             WebApplicationFactory?.Dispose();
             ServiceScopeFactory?.Dispose();
         }
         Disposed = true;
     }
 }
コード例 #15
0
        private bool _disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    _webAppFactory.Dispose();
                }

                _disposedValue = true;
            }
        }
コード例 #16
0
 public void Dispose()
 {
     try
     {
         TestDataUtilities.CleanupBlobFile(_factory, _documentVersionId, _fileContentId);
     }
     finally
     {
         _factory.Dispose();
     }
     GC.SuppressFinalize(this);
 }
コード例 #17
0
 private void Dispose(bool aIsDisposing)
 {
     if (!Disposed)
     {
         if (aIsDisposing)
         {
             Console.WriteLine("==== Disposing ====");
             WebApplicationFactory?.Dispose();
             ServiceScopeFactory?.Dispose();
         }
         Disposed = true;
     }
 }
コード例 #18
0
        protected virtual void Dispose(bool aIsDisposing)
        {
            if (!DisposedValue)
            {
                if (aIsDisposing)
                {
                    Console.WriteLine("==== Disposing ====");
                    ServerWebApplicationFactory?.Dispose();
                }

                DisposedValue = true;
            }
        }
コード例 #19
0
ファイル: TestFixture.cs プロジェクト: absreim/asp-todo-api
        public void Dispose()
        {
            var testConfig = new ConfigurationBuilder()
                             .AddUserSecrets <TestFixture>().Build();
            var contextOptions = new DbContextOptionsBuilder <TodoContext>()
                                 .UseCosmos(testConfig["AzureCosmosDB:ReadWriteKey"],
                                            databaseName: "Todos").Options;
            var context = new TodoContext(contextOptions);

            context.TodoItems.RemoveRange(context.TodoItems);
            context.SaveChanges();
            _factory.Dispose();
        }
コード例 #20
0
        // The bulk of the clean-up code is implemented in Dispose(bool)
        protected virtual void Dispose(bool disposing)
        {
            if (_factory != null)
            {
                _factory.Dispose();
                _factory = null;
            }

            if (_dbRunner != null)
            {
                _dbRunner.Dispose();
                _dbRunner = null;
            }
        }
コード例 #21
0
        public void Stop()
        {
            if (Client != null)
            {
                Client.Dispose();
                Client = null;
            }

            if (_factory != null)
            {
                _factory.Dispose();
                _factory = null;
            }

            UTHelpers.Down(_newFilePath);
        }
コード例 #22
0
        public async Task Get_EndpointsReturnSuccessAndCorrectContentType(string url)
        {
            // Arrange
            AuthenticationManager authenticationManager = new AuthenticationManager();

            authenticationManager.client = _factory.CreateClient();
            File.WriteAllBytes("rsaCert.pfx", Startup.RsaCertPfxBytes);
            Chilkat.Pfx pfx = new Chilkat.Pfx();
            if (File.Exists("rsaCert.pfx"))
            {
                pfx.LoadPfxFile("rsaCert.pfx", "12345");
            }

            File.Delete("rsaCert.pfx");

            // Act
            //public key from certificate
            //Chilkat package is used to process X509 certificate 2 from pfx file to JWKS (Json Web Key Set) from which it is possible
            //to extract public key X5c. Key is then compared with the one pulled from mocked server.
            string alias    = "my_ecc_key1";
            string password = "******";

            Chilkat.JavaKeyStore  jks      = pfx.ToJavaKeyStore(alias, password);
            Chilkat.StringBuilder sbJwkSet = new Chilkat.StringBuilder();
            jks.ToJwkSet(password, sbJwkSet);
            Chilkat.JsonObject jwkSet = new Chilkat.JsonObject();
            jwkSet.LoadSb(sbJwkSet);
            jwkSet.EmitCompact = false;
            var               jwksCheck  = jwkSet.Emit();
            JsonWebKeySet     jwkscheck  = new JsonWebKeySet(jwksCheck);
            List <JsonWebKey> keyList2   = new List <JsonWebKey>(jwkscheck.Keys);
            string            publicKey2 = keyList2[0].X5c[0];

            //response from server
            System.Net.Http.HttpResponseMessage response = await authenticationManager.client.GetAsync(url);

            //public key from endpoint
            string publicKey = authenticationManager.GetPublicKey(url);

            // Assert
            response.EnsureSuccessStatusCode(); // Status Code 200-299
            Assert.Equal(publicKey2, publicKey);
            authenticationManager.client.Dispose();
            _factory.Dispose();
        }
コード例 #23
0
 public void Dispose()
 {
     _factory?.Dispose();
     _agent?.Dispose();
     _client?.Dispose();
 }
コード例 #24
0
 public void Teardown()
 {
     _factory.Dispose();
 }
コード例 #25
0
ファイル: Setup.cs プロジェクト: kursatarslan/unittestSample
 public void OneTimeTearDown()
 {
     RunAndSwallowException(() => DriverManager.Stop());
     RunAndSwallowException(() => frontendServer?.Dispose());
     RunAndSwallowException(() => webAppFactory?.Dispose());
 }
コード例 #26
0
 public void Dispose()
 {
     Client?.Dispose();
     factory?.Dispose();
 }
コード例 #27
0
 public void Dispose()
 {
     _factory?.Dispose();
     Client?.Dispose();
 }
コード例 #28
0
ファイル: PagesApplication.cs プロジェクト: Melchy/Ridge
 public void Dispose()
 {
     WebApplicationFactory?.Dispose();
     GC.SuppressFinalize(this);
 }
コード例 #29
0
ファイル: ApiTest.cs プロジェクト: hakkisagdic/lottery
 public void Dispose()
 {
     factory.Dispose();
 }
コード例 #30
0
 public static void ClassCleanup()
 {
     _factory.Dispose();
 }