/// <summary> /// Initializes a new instance of the EndToEndTestBase class. /// </summary> /// <param name="serviceDescriptor">Descriptor for the service that these tests will target.</param> protected EndToEndTestBase(ServiceDescriptor serviceDescriptor) { this.serviceDescriptor = serviceDescriptor; this.serviceWrapper = new ExternalHostedServiceWrapper(this.serviceDescriptor); this.TestCompleted = false; this.ResetDataSource(); }
public CurrencyProvider(IPreviousDayCalculator previousDayCalculator, ICurrencyConverter currencyConverter, IServiceWrapper serviceWrapper, IArchivedDataProvider archivedDataProvider) { _previousDayCalculator = previousDayCalculator; _currencyConverter = currencyConverter; _serviceWrapper = serviceWrapper; _archivedDataProvider = archivedDataProvider; }
public CreateUserHandler(IRepositoryWrapper repositoryWrapper, IMapper mapper, IServiceWrapper serviceWrapper, IModifier <AppUser, CreateUserCommand> modifier) : base(repositoryWrapper, mapper, modifier) { _serviceWrapper = serviceWrapper; _modifier = modifier; }
public RedisDistributedLock(RedisDistributedLockConfig config, IServiceWrapper <IConnectionMultiplexer> wrapper) { this._value = Guid.NewGuid().ToByteArray(); this._redis = new RedisHelper(wrapper.Value, config.DbNumber); throw new NotImplementedException(); }
private WindowsService(bool interactive, IServiceWrapper wrapper, ILogger logger, ICommandLineParser parser, IConsoleHarness console, IAssembly assembly, ServiceAttributeReader reader, WindowsServiceManager manager, HostFactory hostFactory) { Logger = logger; _metadata = reader.GetMetadata(this); _interactive = interactive; _assembly = assembly; Console = console; _manager = manager; _manager.SetMetadata(_metadata); _hostFactory = hostFactory; CommandLineParser = parser .SetApplicationName(reader.GetAttribute(this).DisplayName) .SetDescription(reader.GetAttribute(this).Description) .AddOption("quiet", "q", "Enable quiet mode. Will display only errors on the console.", noArgs => _metadata.Quiet = true) .AddOption("silent", "si", "Enable silent mode. Will display nothing (not even errors) on the console.", noArgs => _metadata.Silent = true) .AddOption("logtoconsole", "l", "Instructs the installer/uninstaller to log the output to the console.", noArgs => _manager.LogToConsole = true) .AddOption("debug", "d", "Pauses to attach a debugger.", noArgs => EnableDebugMode()) .AddOption("uninstall", "u", "Uninstalls the service.", noArgs => _manager.Uninstall()) .AddOption("install", "i", "Installs the service.", noArgs => _manager.Install()) .AddOption("installandstart", "is", "Installs and then starts the service.", noArgs => _manager.InstallAndStart()) .AddOption("start", "s", "Starts the service.", noArgs => _manager.StartService()) .AddOption("stop", "x", "Stops the service.", noArgs => _manager.StopService()) .AddOption("status", "st", "Displays the status of the service.", noArgs => _manager.ShowStatus()); Harness = wrapper.WrapService(this); }
/// <summary> /// Sets the service descriptor based on the provided ServiceDescriptorType enum and instantiates the /// service wrapper based on the ServiceType enum. The service is also started. /// </summary> /// <param name="serviceDescriptorType">Service descriptor enum to create corresponding service descriptor.</param> /// <param name="serviceType">Service type enum to create corresponding service wrapper.</param> private static void SetServiceDescriptorAndWrapper( ServiceDescriptorType serviceDescriptorType, ServiceType serviceType) { TestServiceUtil.ServiceUriGenerator = Microsoft.Test.OData.Tests.Client.ServiceGeneratorFactory.CreateServiceUriGenerator(); serviceDescriptor = GetServiceDescriptor(serviceDescriptorType); serviceWrapper = GetServiceWrapper(serviceType); }
public BusinessWrapperService(IServiceWrapper serviceWrapper, IRepositoryWrapper repositoryWrapper, IUtilService utilService) { this._repositoryWrapper = repositoryWrapper; this._serviceWrapper = serviceWrapper; this._utilService = utilService; }
public MassCrudController(FactoryManagementContext context, IRepositoryWrapper repositoryWrapper, IServiceWrapper serviceWrapper, ILoggerManager logger, IUtilService utilService) { _context = context; _repositoryWrapper = repositoryWrapper; _serviceWrapper = serviceWrapper; _logger = logger; _utilService = utilService; }
public void TestInitialize() { TestServiceWrapper = new WCFServiceWrapper(this.serviceDescriptor); TestServiceWrapper.StartService(); RetrieveServiceEdmModel(); TestClientContext = Activator.CreateInstance(typeof(TClientContext), ServiceBaseUri) as TClientContext; ResetDataSource(); }
public void DoWork() { using (var scope = _services.CreateScope()) { _serviceWrapper = scope.ServiceProvider.GetRequiredService <IServiceWrapper>(); var rabbitmqConfig = scope.ServiceProvider.GetRequiredService <IOptions <RabbitMqConfiguration> >(); _queueName = rabbitmqConfig.Value.QueueName; _logPath = rabbitmqConfig.Value.LogPath; } }
public PeopleController(IEISService <Person> service, IControllerService controllerService, IServiceWrapper services, IHostingEnvironment environment) : base(service) { _environment = environment; _controllerService = controllerService; _services = services; HttpResponseMessage response = _services.Roles.GetResponse(ApiUrl + "/api/Employee/Designations"); string stringData = response.Content.ReadAsStringAsync().Result; rolesList = JsonConvert.DeserializeObject <List <Role> >(stringData); }
public ODataWCFServiceTestsBase(ServiceDescriptor serviceDescriptor) { TestServiceUtil.ServiceUriGenerator = ServiceGeneratorFactory.CreateServiceUriGenerator(); this.serviceDescriptor = serviceDescriptor; TestServiceWrapper = new WCFServiceWrapper(this.serviceDescriptor); TestServiceWrapper.StartService(); RetrieveServiceEdmModel(); TestClientContext = Activator.CreateInstance(typeof(TClientContext), ServiceBaseUri) as TClientContext; ResetDataSource(); }
public async Task FileServiceGetsAllFiles() { //Arrange int count = 2; IServiceWrapper services = SetupServiceWrapper(count); //Act IEnumerable <FileData> files = services.Files.GetAll(); //Assert Assert.IsTrue(files.Count() > 0, $@"FileService.GetAll() should return {count} files: Actual count is {files.Count()}"); }
/// <summary> /// Inicializa un wrapper deacuerdo el nombre del proveedor /// Carga al wrapper el nombre /// </summary> /// <param name="providerName">Proveedor del wrapper. Este valor debe coincidir con un proveedor de metadata en el dispatcher</param> internal static void InitWrapper(string providerName) { //Si no se espesifica npmbre de provdor se da por entendido que se trata de un proveedor por defecto if (String.IsNullOrEmpty(providerName)) { providerName = _DefaultProviderName; } if (!_WraperPepository.ContainsKey(providerName)) { try { WrapperProviderElement provider = _ProviderSection.GetProvider(providerName); if (provider == null) { TechnicalException te; if (providerName.Equals(_DefaultProviderName)) { te = new TechnicalException(string.Concat("El proveedor de configuración del wrapper por defecto del lado del cliente, no existe, verifique en el archivo de configuracion si existe la seccion FwkWrapper y el proveedor por defecto")); } else { te = new TechnicalException(string.Concat("El proveedor de configuración del wrapper ", providerName, " del lado del cliente, no existe, verifique en el archivo de configuracion si existe la seccion FwkWrapper y el proveedor mencionado")); } te.ErrorId = "6000"; Fwk.Exceptions.ExceptionHelper.SetTechnicalException(te, typeof(WrapperFactory)); throw te; } ///No se almacenan mas providers con String.Empty //if (provider.Name.Equals(_ProviderSection.DefaultProviderName)) providerName = String.Empty; IServiceWrapper w = (IServiceWrapper)ReflectionFunctions.CreateInstance(provider.WrapperProviderType); w.ProviderName = provider.Name; w.SourceInfo = provider.SourceInfo; w.ServiceMetadataProviderName = provider.ServiceMetadataProviderName; w.AppId = provider.AppId; //w.DefaultCulture = provider.DefaultCulture; _WraperPepository.Add(providerName, w); } catch (Exception ex) { ServiceError wServiceError = ProcessConnectionsException.Process(ex); TechnicalException te = new TechnicalException(wServiceError.Assembly, wServiceError.Namespace, wServiceError.Class, wServiceError.Machine, wServiceError.UserName, wServiceError.Message, ex); throw te; } } }
public async Task FileServiceSearchesFilesById() { //Arrange int id = 1; IServiceWrapper services = SetupServiceWrapper(2); //Act IEnumerable <FileData> files = services.Files.Search(file => file.Id == id); //Assert Assert.IsTrue(files.Count() > 0, $@"FileService.Search() should return a single match: Actual count is {files.Count()}"); Assert.IsTrue(files.First().Id == id, $@"FileService.Search() should return file with ID {id}: Actual ID is {files.First().Id}"); }
public async Task FileServiceSearchesFilesByName() { //Arrange string name = "TESTFILE_1"; IServiceWrapper services = SetupServiceWrapper(2); //Act IEnumerable <FileData> files = services.Files.Search(file => file.Name == name); //Assert Assert.IsTrue(files.Count() > 0, $@"FileService.Search() should return a single match: Actual count is {files.Count()}"); Assert.IsTrue(files.First().Name == name, $@"FileService.Search() should return file with name {name}: Actual name is {files.First().Name}"); }
public void TestInitialize() { #if WIN8 || PORTABLELIB this.serviceWrapper = new ExternalHostedServiceWrapper(this.serviceDescriptor); #else this.serviceWrapper = new DefaultServiceWrapper(this.serviceDescriptor); #endif this.TestCompleted = false; this.serviceWrapper.StartService(); this.ResetDataSource(); this.CustomTestInitialize(); }
private void comboProviders_SelectedIndexChanged(object sender, EventArgs e) { current_wrap_provider = comboProviders.SelectedItem as wrap_provider; StringBuilder str = new StringBuilder("Wrapper name: " + current_wrap_provider.Name); str.AppendLine(); str.AppendLine("SourceInfo: " + current_wrap_provider.SourceInfo); str.AppendLine("WrapperProviderType: " + current_wrap_provider.WrapperProviderType); str.AppendLine("ApplicationId: " + current_wrap_provider.ApplicationId); txtRes.Text = str.ToString(); _IServiceWrapper = Fwk.Bases.WrapperFactory.GetWrapper(current_wrap_provider.Name); }
void setWrapper() { wrap_provider w = comboProviders.SelectedItem as wrap_provider; selectedWrapper = Fwk.Bases.WrapperFactory.GetWrapper(w.Name); StringBuilder str = new StringBuilder("Wrapper name: " + w.Name); str.AppendLine(); str.AppendLine("SourceInfo: " + w.SourceInfo); str.AppendLine("WrapperProviderType: " + w.WrapperProviderType); str.AppendLine("ApplicationId: " + w.ApplicationId); textBox1.Text = str.ToString(); }
void setWrapper() { wrap_provider w = comboProviders.SelectedItem as wrap_provider; selectedWrapper = Fwk.Bases.WrapperFactory.GetWrapper(w.Name); StringBuilder str = new StringBuilder("Wrapper name: " + w.Name); str.AppendLine(); str.AppendLine("SourceInfo: " + w.SourceInfo); str.AppendLine("WrapperProviderType: " + w.WrapperProviderType); str.AppendLine("ApplicationId: " + w.ApplicationId); textBox1.Text = str.ToString(); }
public async Task FileServiceDeletesMultipleFiles() { //Arrange int count = 2; IServiceWrapper services = SetupServiceWrapper(count); IEnumerable <int> ids = services.Files.GetAll().Select(file => file.Id); //Act await services.Files.DeleteRange(ids); IEnumerable <FileData> files = services.Files.GetAll(); //Assert Assert.IsTrue(files.Count() == 0, $@"FileService.GetAll() should return no entries: {files.Count()} entries found"); }
public async Task FileServiceDeletesFile() { //Arrange int count = 2; int id = 1; IServiceWrapper services = SetupServiceWrapper(count); //Act await services.Files.Delete(id); IEnumerable <FileData> files = services.Files.Search(file => file.Id == id); //Assert Assert.IsTrue(files.Count() == 0, $@"FileService.Search() should return no matches: {files.Count()} matches found"); }
public AuthController( FactoryManagementContext context, IRepositoryWrapper repositoryWrapper, IServiceWrapper serviceWrapper, ILoggerManager logger, IUtilService utilService, IBusinessService businessService) { _context = context; _repositoryWrapper = repositoryWrapper; _serviceWrapper = serviceWrapper; _logger = logger; _utilService = utilService; _businessService = businessService; }
public async Task FileServiceAddsFile() { //Arrange int count = 1; int id = 2; IServiceWrapper services = SetupServiceWrapper(count); FileData newFile = new StubFileData().GetNew(id); //Act await services.Files.Add(newFile); IEnumerable <FileData> files = services.Files.GetAll(); //Assert Assert.IsTrue(files.Count() > count, $@"FileService.GetAll() should return {count + 1} files: Actual count is {files.Count()}"); }
/// <summary> /// Levanta la seccion FwkWrapper.- /// Inicialisa el repositorio de wrappers. (no lo llena con los wrappers) /// </summary> static WrapperFactory() { try { //Obtiene la la configuracion del wrapper del archivo .config _ProviderSection = ConfigurationManager.GetSection("FwkWrapper") as WrapperProviderSection; if (_ProviderSection == null) { TechnicalException te = new TechnicalException(string.Concat("No se puede cargar la configuracion del wrapper en el cliente, verifique si existe la seccion [FwkWrapper] en el archivo de configuracion.")); te.ErrorId = "6000"; Fwk.Exceptions.ExceptionHelper.SetTechnicalException(te, typeof(WrapperFactory)); throw te; } _WraperPepository = new Dictionary <string, IServiceWrapper>(); _DefaultProviderName = _ProviderSection.DefaultProviderName; IServiceWrapper w = null; foreach (WrapperProviderElement provider in _ProviderSection.Providers) { w = (IServiceWrapper)ReflectionFunctions.CreateInstance(provider.WrapperProviderType); if (w == null) { TechnicalException te = new TechnicalException(string.Concat("No existe el tipo de wrapper: ", provider.WrapperProviderType)); te.ErrorId = "6000"; Fwk.Exceptions.ExceptionHelper.SetTechnicalException(te, typeof(WrapperFactory)); throw te; } w.ProviderName = provider.Name; w.SourceInfo = provider.SourceInfo; w.ServiceMetadataProviderName = provider.ServiceMetadataProviderName; w.AppId = provider.AppId; //w.DefaultCulture = provider.DefaultCulture; //if (provider.Name.Equals(_DefaultProviderName)) // _WraperPepository.Add(String.Empty, w); //else _WraperPepository.Add(provider.Name, w); } } catch (System.Configuration.ConfigurationErrorsException ex) { TechnicalException te = new TechnicalException(string.Concat("No se puede cargar la configuracion del wrapper en el cliente, verifique si existe la seccion [FwkWrapper] en el archivo de configuracion."), ex); te.ErrorId = "6000"; Fwk.Exceptions.ExceptionHelper.SetTechnicalException(te, typeof(WrapperFactory)); throw te; } }
/// <summary> /// Initializes a new instance of the EndToEndTestBase class. /// Initialization for the tests, called prior to running each test in this class. /// </summary> /// <param name="serviceDescriptor">Descriptor for the service that these tests will target.</param> protected EndToEndTestBase(ServiceDescriptor serviceDescriptor, ITestOutputHelper output) { TestServiceUtil.ServiceUriGenerator = ServiceGeneratorFactory.CreateServiceUriGenerator(); this.serviceDescriptor = serviceDescriptor; this.serviceWrapper = new DefaultServiceWrapper(this.serviceDescriptor); this.TestCompleted = false; this.serviceWrapper.StartService(); this.ResetDataSource(); this.CustomTestInitialize(); var helper = (TestOutputHelper)output; ITest test = (ITest)helper.GetType().GetField("test", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(helper); testClassName = test.TestCase.TestMethod.TestClass.Class.ToString(); testName = test.TestCase.TestMethod.Method.Name; }
public static void RegisterDatabase(IServiceWrapper wrapper) { wrapper.InitializeDatabase(); wrapper.InitializeRoles(); wrapper.InitializeCategories(); wrapper.InitializeStatuses(); wrapper.InitializePriorities(); wrapper.InitializeTypes(); WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfiles", "UserId", "UserName", autoCreateTables: false); string admin = "admin"; if (!WebSecurity.UserExists(admin)) { string salt = WebSecurityService.GetSalt(); WebSecurity.CreateUserAndAccount(admin, admin + "_Tt" + salt); wrapper.UpdateCreatedUser( new Model.UserModel { UserName = admin, webpages_Roles = new [] { new Model.RoleModel { RoleId = 1 } } }, salt ); } }
public AccountController(IServiceWrapper serviceWrapper, UserManager <User> userManager, SignInManager <User> signInManager) { _serviceWrapper = serviceWrapper; _userManager = userManager; _signInManager = signInManager; }
public WordsController(IServiceWrapper serviceWrapper) { _serviceWrapper = serviceWrapper; }
//public FactoryAuthorize(IRepositoryWrapper repositoryWrapper, // IServiceWrapper serviceWrapper) //{ // _repositoryWrapper = repositoryWrapper; // _serviceWrapper = serviceWrapper; //} public void OnAuthorization(AuthorizationFilterContext filterContext) { var services = filterContext.HttpContext.RequestServices; _repositoryWrapper = (IRepositoryWrapper)services.GetService(typeof(IRepositoryWrapper)); _serviceWrapper = (IServiceWrapper)services.GetService(typeof(IServiceWrapper)); _utilService = (IUtilService)services.GetService(typeof(IUtilService)); _context = new FactoryManagementContext(); var actionName = ""; var ctrlName = ""; Microsoft.Extensions.Primitives.StringValues authorizationToken; filterContext.HttpContext.Request.Headers.TryGetValue("Authorization", out authorizationToken); if (filterContext != null) { var _token = authorizationToken.FirstOrDefault(); if (_token != null && _token.Substring(7) != "null") { string authToken = _token; if (authToken != null) { #region Decoding Token JwtSecurityToken claims = _serviceWrapper.UserAuthInfoService.DecodeJwtToken(authorizationToken.FirstOrDefault().Substring(7)); var userId = claims.Claims.Where(x => x.Type == "UserId").FirstOrDefault().Value; var userName = claims.Claims.Where(x => x.Type == "UserName").FirstOrDefault().Value; var factoryName = claims.Claims.Where(x => x.Type == "FactoryName").FirstOrDefault().Value; var factoryId = claims.Claims.Where(x => x.Type == "FactoryId").FirstOrDefault().Value; var mvcContext = filterContext; bool hasAccessRight = false; var descriptor = mvcContext?.ActionDescriptor as ControllerActionDescriptor; if (descriptor != null) { actionName = descriptor.ActionName; ctrlName = descriptor.ControllerName; } UserRole roleVm = GetUserRole(userId); if (roleVm.Role.Name == "SUPER_ADMIN") { filterContext.HttpContext.Response.Headers.Add("authToken", authToken); filterContext.HttpContext.Response.Headers.Add("AuthStatus", "Authorized"); filterContext.HttpContext.Response.Headers.Add("storeAccessiblity", "Authorized"); return; } ApiResourceMappingVM vm = GetApiResourceMapping(ctrlName, actionName); // UserRole roleVm = GetUserRole(userId); var property = vm.Resource == "Common" ? null : roleVm.Role.GetType().GetProperty(vm.Resource); if (vm.Resource == "Common") { hasAccessRight = true; } else if (property != null) { hasAccessRight = (bool)property.GetValue(roleVm.Role); } #endregion if (IsValidToken(authToken.Substring(7)) && hasAccessRight) { filterContext.HttpContext.Response.Headers.Add("authToken", authToken); filterContext.HttpContext.Response.Headers.Add("AuthStatus", "Authorized"); filterContext.HttpContext.Response.Headers.Add("storeAccessiblity", "Authorized"); return; } else { filterContext.HttpContext.Response.Headers.Add("authToken", authToken); filterContext.HttpContext.Response.Headers.Add("AuthStatus", "NotAuthorized"); filterContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; filterContext.HttpContext.Response.HttpContext.Features.Get <IHttpResponseFeature>().ReasonPhrase = "Not Authorized"; filterContext.Result = new JsonResult("NotAuthorized") { Value = new { Status = "Error", Message = "Invalid Token" }, }; } } } else { filterContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.ExpectationFailed; filterContext.HttpContext.Response.HttpContext.Features.Get <IHttpResponseFeature>().ReasonPhrase = "Please Provide authToken"; filterContext.Result = new JsonResult("Please Provide authToken") { Value = new { Status = "Error", Message = "Please Provide authToken" }, }; } } }
public TestRabbitMQController(IServiceWrapper serviceWrapper, ILogger <TestRabbitMQController> logger) { _serviceWrapper = serviceWrapper; _logger = logger; }
public BaseController(IServiceWrapper serviceWrapper) { this.ServiceWrapper = serviceWrapper; }
public BaseController() { _logger = LogManager.GetLogger(GetType()); _wrapper = new ClassWrapper(); //_wrapper = new WebApiWrapper(); }
public BaseController(IServiceWrapper usersWrapper) { _wrapper = usersWrapper; }
public ProductController(IServiceWrapper serviceWrapper) : base(serviceWrapper) { }
private WindowsService(bool interactive, IServiceWrapper wrapper, ILogger logger, IConsoleHarness console, IAssembly assembly, ServiceAttributeReader reader, HostFactory factory) : this(interactive, wrapper, logger, new Parser(Strings.DEBUG_Cush, string.Empty, true, console, assembly), console, assembly, reader, WindowsServiceManager.GetInstance(console), factory) { }
public EstadoService(CorreiosContext correiosContext, IServiceWrapper serviceWrapper, IRepositoryWrapper repositoryWrapper) : base(correiosContext, serviceWrapper, repositoryWrapper) { }