public void CustomFactoryRegistersCorrectly() { CustomFactory.Register(); Assert.That(CustomFactory.Default, Is.Not.Null); ProxyFooPolicies.ClearProxyModule(); Assert.That(CustomFactory.IsClear); }
public void CustomFactoryGenericMethod() { var factory = new CustomFactory(_comparerB); var comparer = factory.GetObjectsComparer <B>(); Assert.AreEqual(_comparerB, comparer); }
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()); } }
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); }
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); }
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!"); }
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!"); }
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(); }
/// <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(); } }
/// <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(); } }
static void Clear() { _default = null; }