public void CreateEntityWithValidInput() { // ARRANGE DTOModelA modelA = new DTOModelA { Id = 0, Name = "Pippo", Surname = "Poppi" }; DTOModelA result = new DTOModelA(); IEntityA mockEntityA = Substitute.For <EntityAMock>(); IRepositoryA mockRepositoryA = Substitute.For <RepositoryAMock>(); mockRepositoryA.CreateEntity(mockEntityA); IDataStore mockDataStore = Substitute.For <DataStoreMock>(); IDataSupplier mockDataSupplier = Substitute.For <DataSupplierMock>(); ICoreStore mockCoreStore = Substitute.For <CoreStoreMock>(); // ACT ICoreSupplier testCoreSupplier = CoreSupplier.Instance(mockCoreStore); testCoreSupplier.GetFeatureA.CreatePost(modelA); result = testCoreSupplier.GetFeatureA.DetailsGet(modelA); // ASSERT Assert.IsInstanceOf <DTOModelA>(result); Assert.AreEqual(modelA.Id, result.Id); }
public void Setup() { Reset(); _dataSupplier = new DataSupplier( SetupMock <IIdManager>()); }
public DayActivity(DateTime date) { Date = date; PsSucced = 100; PsMovedToManual = CountFilesByDate(manual); PsError = 1; InvoceSSucced = 47; InvoicesFailed = 3; psTotal = PsSucced + PsMovedToManual + PsError; invoiceTotal = InvoceSSucced + InvoicesFailed; using (IDataSupplier db = DataManager.GetDataSupplier()) { string sql = @"select COUNT(id) from user_action_tab where param_3=@docType and action_date between @date and DateAdd(day,1,@date)"; db.OpenQuery(); db.AddParameter("date", Date); db.AddParameter("docType", "18"); DataSet ds = db.GetData(sql); PsSucced = (int)ds.Tables[0].Rows[0][0]; db.OpenQuery(); db.AddParameter("date", Date); db.AddParameter("docType", "16"); ds = db.GetData(sql); InvoceSSucced = (int)ds.Tables[0].Rows[0][0]; } }
public void HasDependency(IDataSupplier dataSupplier, IDataDependency dependency) { if (ReferenceEquals(dataSupplier, null)) { throw new ArgumentNullException("dataSupplier"); } if (dataSupplier == null) { throw new Exception("Data provider " + dataSupplier + " is not a supplier of data"); } if (ReferenceEquals(dependency, null)) { dependency = dataSupplier.DefaultDependency; } if (!dataSupplier.IsSupplierOf(dependency)) { throw new Exception("Data provider " + dataSupplier + " is not a supplier of " + dependency); } if (DataSupplierDependencies == null) { DataSupplierDependencies = new List <Tuple <IDataSupplier, IDataDependency> >(); } DataSupplierDependencies.Add(new Tuple <IDataSupplier, IDataDependency>(dataSupplier, dependency)); }
public IDataCatalog Register(IDataSupplier dataSupplier) { if (dataSupplier == null) { return(this); } if (ReferenceEquals(dataSupplier.SuppliedTypes, null)) { return(this); } foreach (var type in dataSupplier.SuppliedTypes) { if (!Suppliers.ContainsKey(type)) { Suppliers[type] = new List <IDataSupplier>(); } var suppliers = Suppliers[type]; suppliers.Add(dataSupplier); } return(this); }
public SupplierRegistration(IDataSupplier supplier, Type type) { Supplier = supplier; CanSupplyScoped = supplier.CanSupplyScoped(type); CanSupplyUnscoped = supplier.CanSupplyUnscoped(type); var consumer = supplier as IDataConsumer; if (consumer != null) { var needs = consumer.GetConsumerNeeds(); if (needs != null) { if (needs.DataSupplyDependencies != null) { DependencyScore += needs.DataSupplyDependencies.Count; } if (needs.DataSupplierDependencies != null) { DependencyScore += needs.DataSupplierDependencies.Count * 2; } if (needs.DataDependencies != null) { DependencyScore += needs.DataDependencies.Count * 3; } } } if (CanSupplyScoped && CanSupplyUnscoped) { DependencyScore += 1; } }
public void AddSupplier( IDataSupplier supplier, IDataDependency dependencyToSupply) { if (supplier == null) { throw new ArgumentNullException("supplier"); } if (dependencyToSupply == null) { throw new ArgumentNullException("dependencyToSupply"); } lock (_lock) { var suppliedDependency = SuppliedDependencies .FirstOrDefault(d => d.Item1 == supplier && d.Item2.Equals(dependencyToSupply)); if (suppliedDependency != null) { return; } SuppliedDependencies.Add(new Tuple <IDataSupplier, IDataDependency>(supplier, dependencyToSupply)); } }
public IDataCatalog Register(IDataSupplier dataSupplier) { if (dataSupplier == null) { return(this); } if (!_types.Add(dataSupplier.GetType())) { return(this); } foreach (var type in dataSupplier.SuppliedTypes) { lock (_registrations) { SupplierRegistration[] registrations; if (_registrations.TryGetValue(type, out registrations)) { var newArray = new SupplierRegistration[registrations.Length + 1]; registrations.CopyTo(newArray, 0); newArray[newArray.Length - 1] = new SupplierRegistration(dataSupplier, type); _registrations[type] = newArray; } else { _registrations.Add(type, new[] { new SupplierRegistration(dataSupplier, type) }); } } } return(this); }
public ProxyPageRequester([NotNull] CrawlConfiguration config, [CanBeNull] IDataSupplier dataSupplier) : base(config) { _dataSupplier = dataSupplier; string value; if(_config.ConfigurationExtensions.TryGetValue("Proxy", out value)) _webProxy.Address = new Uri(value); }
void IDataConsumer.HasDependency(IDataSupplier dataSupplier, IDataDependency dependency) { if (_dataConsumer == null) { return; } _dataConsumer.HasDependency(dataSupplier, dependency); }
public static ICoreStore Instance(IDataSupplier dataSupplier) { if (CoreStoreIstance == null) { CoreStoreIstance = new CoreStore(dataSupplier); } return(CoreStoreIstance); }
public SearchController( [NotNull] IDataSupplier dataSupplier, [NotNull] ILoggerFactory loggerFactory, [NotNull] IGeoLocator locator) { _dataSupplier = dataSupplier; _logger = loggerFactory.CreateLogger<SearchController>(); _locator = locator; }
public static IDataSupplier Instance() { if (DataSupplierInstance == null) { DataSupplierInstance = new DataSupplier(); } return(DataSupplierInstance); }
public DataProvider(IDataProviderDependenciesFactory dependencies) { // DO NOT change the method signature of this constructor as // this would break all data providers in all applications that use // this framework!! Dependencies = dependencies; DataConsumer = dependencies.DataConsumerFactory.Create(); DataSupplier = dependencies.DataSupplierFactory.Create(); }
public HomeController( [NotNull] IPageDocument pageDocument, [NotNull] IDataSupplier dataSupplier, [NotNull] ILoggerFactory loggerFactory) { _logger = loggerFactory.CreateLogger<HomeController>(); _pageDocument = pageDocument; _dataSupplier = dataSupplier; }
public static IDataSupplier Instance(IDataStore dataStore) { if (DataSupplierInstance == null) { DataSupplierInstance = new DataSupplier(dataStore); } return(DataSupplierInstance); }
public static (bool success, Exception exception) ToFile(this IDataSupplier useOutputStream, string path) { try { new FileWriter(useOutputStream).WriteData(path); return(true, null); } catch (Exception ex) { return(false, ex); } }
public CDataSupplierProxy(String source = "DAL") { if (source.Equals("DAL")) { _supplier = new CDataSupplierDB(); } else { log.Fatal("Data supplier are not defined"); throw new ArgumentException(); } }
// TODO: add other ways to configure (json, in code) /// <summary> /// Initializes a new log4net logger provider using an XML file /// </summary> /// <param name="xmlConfig">path to an XML config file</param> /// <param name="dataSupplier">optional <see cref="IDataSupplier"/> implementation for saving log entries through it</param> public Log4NetLoggerProvider([NotNull] string xmlConfig, IDataSupplier dataSupplier = null) { XmlConfigurator.ConfigureAndWatch(new FileInfo(xmlConfig)); //setup DataSupplierAppenders, if any if (dataSupplier != null) foreach (IAppender appender in LogManager.GetRepository().GetAppenders()) { DataSupplierAppender dataSupplierAppender = appender as DataSupplierAppender; if (dataSupplierAppender != null) dataSupplierAppender.DataSupplier = dataSupplier; } }
public SuppliedDependency(IDataSupplier dataSupplier, IDataDependency dataDependency) { DataSupplier = dataSupplier; DataDependency = dataDependency; DependentSupplies = new List <IDataSupply>(); if (DataDependency != null && !DataSupplier.IsSupplierOf(DataDependency)) { throw new Exception("Supplier '" + DataSupplier + "' is not a supplier of '" + DataDependency + "'"); } DataSupply = DataSupplier.GetSupply(DataDependency); }
private List <IDataSupply> ResolveDataSupplierSupplies(IDataSupplier supplier, IDataDependency dataToSupply, bool addIfMissing) { #if DETAILED_TRACE Trace.WriteLine("Data context builder #" + Id + (addIfMissing ? " adding '" : " locating '") + dataToSupply + "' from' " + supplier + "'"); #endif var suppliedDependency = _suppliedDependencies == null ? null : _suppliedDependencies.FirstOrDefault(sd => Equals(sd.DataDependency, dataToSupply)); if (suppliedDependency != null) { #if DETAILED_TRACE Trace.WriteLine("Data context builder #" + Id + " dependency '" + dataToSupply + "' already has a supplier"); #endif return(new List <IDataSupply> { suppliedDependency.DataSupply }); } if (_parent != null) { var dependentSupplies = _parent.ResolveDataSupplierSupplies(supplier, dataToSupply, false); if (dependentSupplies != null) { #if DETAILED_TRACE Trace.WriteLine("Data context builder #" + Id + " parent was able to resolve the dependency"); #endif return(dependentSupplies); } } if (!addIfMissing) { return(null); } #if DETAILED_TRACE Trace.WriteLine("Data context builder #" + Id + " dependency on '" + dataToSupply + "' must be added"); #endif suppliedDependency = new SuppliedDependency(supplier, dataToSupply); AddSuppliedDependency(suppliedDependency); ResolveConsumerNeeds(supplier as IDataConsumer); return(new List <IDataSupply> { suppliedDependency.DataSupply }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationEnvironment appEnv, ILoggerFactory loggerFactory, IDataSupplier dataSupplier) { loggerFactory.MinimumLevel = LogLevel.Debug; loggerFactory .AddConsole() .AddLog4Net(Path.Combine(appEnv.ApplicationBasePath, "Log4Net.config"), dataSupplier); // The HTTP request pipeline. app.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseErrorPage(); app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll); } else app.UseErrorHandler("/Home/Error"); // Track data about exceptions from the application. Should be configured after all error handling middleware in the request pipeline. app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.UseIdentity(); //app.UseFacebookAuthentication(); app.UseGoogleAuthentication(); //app.UseMicrosoftAccountAuthentication(); //app.UseTwitterAuthentication(); // localization settings IList<CultureInfo> acceptedCultures = new List<CultureInfo> { new CultureInfo("en-US"), new CultureInfo("he-IL"), new CultureInfo("ru-RU") }; app.UseRequestLocalization(new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture(acceptedCultures[0]), SupportedCultures = acceptedCultures, SupportedUICultures = acceptedCultures }); app.UseMvc(routes => routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}")); }
private void Configure(AttributeSet attributes, IDataSupplier dataSupplier) { if (dataSupplier == null) { return; } if (attributes.SuppliesDatas != null) { foreach (var data in attributes.SuppliesDatas) { var dependency = _dataDependencyFactory.Create( data.DataType, data.Scope); // TODO: Is there a way to specify the action via attributes? dataSupplier.Add(dependency, (rc, dc, dep) => { }); } } }
public Program(IApplicationEnvironment env) { try { // creating infrastructure by ourselves instead of the hosting environment ServiceCollection services = new ServiceCollection(); Startup startup = new Startup(env); startup.ConfigureServices(services); IServiceProvider serviceProvider = services.BuildServiceProvider(); _dataSupplier = (IDataSupplier)serviceProvider.GetService(typeof(IDataSupplier)); ILoggerFactory loggerFactory = (ILoggerFactory)serviceProvider.GetService(typeof(ILoggerFactory)); startup.Configure(env, loggerFactory, _dataSupplier); _config = startup.Configuration; _logger = loggerFactory.CreateLogger<Program>(); } catch (Exception ex) { // just quit after displaying the exception Console.WriteLine($"Error occured while initializing the crawler: {ex}"); Console.ReadLine(); throw; } }
public FileWriter(IDataSupplier dataSupplier) { _dataSupplier = dataSupplier; }
public DbStringLocalizer([NotNull] IDataSupplier dataSupplier, CultureInfo cultureInfo = null) { _dataSupplier = dataSupplier; _cultureInfo = cultureInfo ?? new CultureInfo(DefaultCultureName); }
public DbStringLocalizerFactory([NotNull] IDataSupplier dataSupplier) { _dataSupplier = dataSupplier; }
public StatsPanel(IDataSupplier supplier) { InitializeComponent(); _supplier = supplier; }
void IDataScopeRules.AddSupplier(IDataSupplier supplier, IDataDependency dependency) { throw new NotImplementedException(); }
public DataController(IDataSupplier dataSupplier) { _dataSupplier = dataSupplier; }
void IDataConsumer.HasDependency(IDataSupplier dataSupplier, IDataDependency dependency) { _dataConsumer.HasDependency(dataSupplier, dependency); }
protected CoreStore(IDataSupplier dataSupplier) { CoreStore_DataSupplierInstance = dataSupplier; }
public void AddSupplier(IDataSupplier supplier, IDataDependency dependency) { }
void IDataScopeRules.AddSupplier(IDataSupplier supplier, IDataDependency dependencyToSupply) { _dataScopeRules.AddSupplier(supplier, dependencyToSupply); }
public static ILoggerFactory AddLog4Net([NotNull] this ILoggerFactory factory, [NotNull] string xmlConfig, IDataSupplier dataSupplier = null) { factory.AddProvider(new Log4NetLoggerProvider(xmlConfig, dataSupplier)); return factory; }