コード例 #1
0
 public void CustomFactoryRegistersCorrectly()
 {
     CustomFactory.Register();
     Assert.That(CustomFactory.Default, Is.Not.Null);
     ProxyFooPolicies.ClearProxyModule();
     Assert.That(CustomFactory.IsClear);
 }
コード例 #2
0
        public void CustomFactoryGenericMethod()
        {
            var factory = new CustomFactory(_comparerB);

            var comparer = factory.GetObjectsComparer <B>();

            Assert.AreEqual(_comparerB, comparer);
        }
コード例 #3
0
 public MonoObjectPool(Func <Object> createMethod, Action <T> onShowMethod = null, Action <T> onHideMethod = null,
                       int initCount = 0)
 {
     _onHideMethod = onHideMethod;
     _createMethod = createMethod;
     _onShowMethod = onShowMethod;
     Factory       = new CustomFactory <T>(Create);
     for (int i = 0; i < initCount; i++)
     {
         CacheStack.Push(Factory.Create());
     }
 }
コード例 #4
0
        public void CustomFactoryIsStoredPerProxyModule()
        {
            CustomFactory.Register();
            Assert.That(CustomFactory.Default, Is.Not.Null);
            var proxyModule   = new ProxyModule();
            var customFactory = CustomFactory.FromProxyModule(proxyModule);

            Assert.That(customFactory, Is.Not.Null);
            Assert.That(customFactory, Is.Not.SameAs(CustomFactory.Default));
            ProxyFooPolicies.ClearProxyModule();
            Assert.That(CustomFactory.IsClear);
            Assert.That(CustomFactory.FromProxyModule(proxyModule), Is.Not.Null);
        }
コード例 #5
0
        public void CustomFactoryNongenericMethod()
        {
            var factory  = new CustomFactory(_comparerB);
            var comparer = factory.GetObjectsComparer(typeof(B));
            var b1       = new B();
            var b2       = new B();

            _comparerB.CalculateDifferences(b1, b2).Returns(new List <Difference>());

            var isEqual = comparer.Compare(typeof(B), b1, b2);

            Assert.IsTrue(isEqual);
            _comparerB.Received().CalculateDifferences(b1, b2);
        }
コード例 #6
0
ファイル: TestCommand.cs プロジェクト: rebus-org/GoCommando
        public void CanUseSuppliedCommandFactory()
        {
            var commandFactory = new CustomFactory();

            var commandInvoker = new CommandInvoker("null", typeof(CreatedByFactory), new Settings(), commandFactory: commandFactory);

            commandInvoker.Invoke(Enumerable.Empty<Switch>(), new EnvironmentSettings());

            Assert.That(commandInvoker.CommandInstance, Is.TypeOf<CreatedByFactory>());

            var createdByFactory = (CreatedByFactory)commandInvoker.CommandInstance;
            Assert.That(createdByFactory.CtorInjectedValue, Is.EqualTo("ctor!!"));

            Assert.That(commandFactory.WasProperlyReleased, Is.True, "The created command instance was NOT properly released after use!");
        }
コード例 #7
0
        public void CanUseSuppliedCommandFactory()
        {
            var commandFactory = new CustomFactory();

            var commandInvoker = new CommandInvoker("null", typeof(CreatedByFactory), new Settings(), commandFactory: commandFactory);

            commandInvoker.Invoke(Enumerable.Empty <Switch>(), new EnvironmentSettings());

            Assert.That(commandInvoker.CommandInstance, Is.TypeOf <CreatedByFactory>());

            var createdByFactory = (CreatedByFactory)commandInvoker.CommandInstance;

            Assert.That(createdByFactory.CtorInjectedValue, Is.EqualTo("ctor!!"));

            Assert.That(commandFactory.WasProperlyReleased, Is.True, "The created command instance was NOT properly released after use!");
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: PawelGerr/Tooling.Test
        private static void ExecuteReadingFilesExample_Recommended()
        {
            Console.WriteLine("== ExecuteReadingFilesExample_Recommended ==");

            IFile          file    = new FileAdapter();
            ICustomFactory factory = new CustomFactory();

            var viaFile = new ReadingFiles.Recommended.ViaFile(file, factory);

            viaFile.ReadFile_With_OpenText();
            viaFile.ReadFile_With_OpenRead();
            viaFile.ReadFile_With_Open();

            var viaFileInfo = new ReadingFiles.Recommended.ViaFileInfo(factory);

            viaFileInfo.ReadFile_With_OpenText();
            viaFileInfo.ReadFile_With_OpenRead();
            viaFileInfo.ReadFile_With_Open();

            Console.WriteLine();
        }
コード例 #9
0
        /// <summary>
        /// Загрузка списка физическх лиц
        /// </summary>
        private static void DataPhysicals()
        {
            try
            {
                string sql = "SELECT * FROM PhysicalClient";
                ConnectionClient.ConOpen();
                using (SqlCommand commmand = new SqlCommand(sql, ConnectionClient.connection))
                {
                    SqlDataReader reader = commmand.ExecuteReader();
                    while (reader.Read())
                    {
                        PhysicalClient physical = new PhysicalClient((int)reader["Id"], (string)reader["Name"], (string)reader["Surname"], (DateTime)reader["DateOfBirthday"], (int)reader["CityId"], (int)reader["StatusId"]);
                        Repository.physicalClients.Add(physical);
                        customersLoad.Add(CustomFactory.GetCustomerFactory(physical));
                    }

                    ConnectionClient.ConClose();
                }
            }
            catch (SqlException e) { errorMes.ErrorSQL(e.Message); }
            catch (Exception e) { errorMes.ErrorSQL(e.Message); }
            finally { ConnectionClient.ConClose(); }
        }
コード例 #10
0
        /// <summary>
        /// Загрузка списка ую.лиц
        /// </summary>
        private static void DataBusines()
        {
            try
            {
                string sql = "SELECT * FROM Busines";
                ConnectionClient.ConOpen();
                using (SqlCommand commmand = new SqlCommand(sql, ConnectionClient.connection))
                {
                    SqlDataReader reader = commmand.ExecuteReader();
                    while (reader.Read())
                    {
                        Busines busines = new Busines((int)reader["Id"], (string)reader["OrganizationName"],
                                                      (long)reader["INNCode"], (int)reader["StatusId"], (int)reader["CityId"], (string)reader["FIO"], (string)reader["PositionName"]);
                        Repository.busines.Add(busines);
                        customersLoad.Add(CustomFactory.GetCustomerFactory(busines));
                    }

                    ConnectionClient.ConClose();
                }
            }
            catch (SqlException e) { errorMes.ErrorSQL(e.Message); }
            catch (Exception e) { errorMes.ErrorSQL(e.Message); }
            finally { ConnectionClient.ConClose(); }
        }
コード例 #11
0
 static void Clear()
 {
     _default = null;
 }
コード例 #12
0
 static void Clear()
 {
     _default = null;
 }