public void GetApplicationAsyncTest1() { //Arrange var svc = MockRepository.GenerateMock <ApplicationService>(); svc.Stub(async x => await x.GetApplicationAsync(null)).IgnoreArguments().Return(Task.FromResult(new Application { Id = 1 })); var factory = MockRepository.GenerateMock <IServiceFactory>(); factory.Stub(x => x.CreateProxy <ApplicationService, ApplicationServiceClient>(Arg <bool> .Is.Anything, Arg <ICacheManager> .Is.Anything, Arg <string> .Is.Anything, ref Arg <ApplicationServiceClient> .Ref(Is.Anything(), null).Dummy)) .Return(svc); // Act using (var client = new AccessClient(factory)) { var task = client.ApplicationProxy.GetApplicationAsync("sv"); task.Wait(); var application = task.Result; // Assert Assert.IsNotNull(application); Assert.AreEqual(1, application.Id); } }
public void ExposeProcessRequestTest1() { //Arrange var exposeService = MockRepository.GenerateMock <ExposeService>(); exposeService.Stub(x => x.Process(null)).IgnoreArguments().Return(new ResponseList { new UpdateBasketItemResponse { Result = new Basket() } }); var factory = MockRepository.GenerateMock <IServiceFactory>(); factory.Stub(x => x.CreateProxy <ExposeService, ExposeServiceClient>(Arg <bool> .Is.Anything, Arg <ICacheManager> .Is.Anything, Arg <string> .Is.Anything, ref Arg <ExposeServiceClient> .Ref(Is.Anything(), null).Dummy)) .Return(exposeService); // Act using (var client = new AccessClient(factory)) { client.RegisterRequest("1", new UpdateBasketItemRequest()); client.ProcessRequests(); Basket result; client.TryGet("1", out result); // Assert Assert.IsNotNull(result); } }
public AccessAppService(ILogger <AccessAppService> logger, AppConfig appConfig, AccessClient accessClient) : base(logger) { this.appConfig = appConfig; this.accessClient = accessClient; }
public PermissionFilter(AccessClient accessClient, AppConfig appConfig, string resourceKey, params ActionPermission[] actions) { this.accessClient = accessClient; this.appConfig = appConfig; ResourceKey = resourceKey; Actions = actions; }
public void GetBatchTest1() { // Arrange var api = new AccessClient(); var repository = new Repository(() => api); // Act var batch = repository.GetBatch(); // Assert Assert.IsInstanceOfType(batch, typeof(AccessClient)); }
public void CreateTest2() { //Arrange // Act using (var client = new AccessClient()) { client.UseCache = false; // Assert Assert.IsInstanceOfType(client.ApplicationProxy, typeof(ApplicationService)); Assert.IsInstanceOfType(client.ApplicationProxy, typeof(ApplicationServiceClient)); } }
public void CreateTest1() { //Arrange // Act using (var client = new AccessClient()) { // Assert Assert.IsInstanceOfType(client.ApplicationProxy, typeof(ApplicationService)); Assert.AreEqual(client.ApplicationProxy.GetType(), typeof(ApplicationServiceClient)); Assert.IsNotInstanceOfType(client.ApplicationProxy, typeof(ApplicationServiceClient)); } }
/// <summary> /// 获取用户 /// </summary> public static User GetUser(string Uid) { User u = null; string AppID = System.Configuration.ConfigurationManager.AppSettings["AppID"]; AccessClient client = new AccessClient(); try { client.Open(); u = client.GetCurrentUser(Convert.ToInt32(AppID), Uid); } catch (Exception ex) { HttpContext.Current.Response.Redirect("~/Home/Msg/AccessIssue"); } finally { client.Close(); } return u; }
public void ExceptionWhenProcessingRequestsTest1() { //Arrange var exposeService = MockRepository.GenerateMock <ExposeService>(); exposeService.Stub(x => x.Process(null)).IgnoreArguments().Throw(new ApplicationException()); var factory = MockRepository.GenerateMock <IServiceFactory>(); factory.Stub(x => x.CreateProxy <ExposeService, ExposeServiceClient>(Arg <bool> .Is.Anything, Arg <ICacheManager> .Is.Anything, Arg <string> .Is.Anything, ref Arg <ExposeServiceClient> .Ref(Is.Anything(), null).Dummy)) .Return(exposeService); // Act using (var client = new AccessClient(factory)) { client.RegisterRequest("1", new UpdateBasketItemRequest()); client.ProcessRequests(); } // Assert Assert.Fail("Should not get here. ProcessRequest throws exeption."); }
private void UpdatePassword() { UserInformation.Instance.Refresh(); if (!UserInformation.Instance.UserExists) { MessageBox.Show("Couldn't fetch user information from the server." + Environment.NewLine + "Please verify that you have an existing user and that your user name and password is correct. ", "HeuristicLab Access Service", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { bool result = AccessClient.CallAccessService <bool>(x => x.ChangePassword(UserInformation.Instance.User.Id, oldPasswordTextBox.Text, newPasswordTextBox.Text)); if (result) { MessageBox.Show("Password change successfull.", "HeuristicLab Access Service", MessageBoxButtons.OK, MessageBoxIcon.Information); SaveNewUserPasswordConfig(); Close(); } else { MessageBox.Show("Password change failed. " + Environment.NewLine + "Please check the entered passwords to conform with the passwords standards.", "HeuristicLab Access Service", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public static IAccessClient GetAccessClient(this System.Web.UI.Page page) { var client = page.Items["EnfernoStormApiClient"] as IAccessClient; if (client != null) { return(client); } lock (syncRoot) { client = page.Items["EnfernoStormApiClient"] as IAccessClient; if (client != null) { return(client); } client = new AccessClient("AccessClient"); page.Unload += (o, e) => client.Dispose(); page.PreRender += (o, e) => client.ProcessRequests(page); page.Items["EnfernoStormApiClient"] = client; } return(client); }
public void GetProductTest1() { //Arrange var svc = MockRepository.GenerateMock <ProductService>(); svc.Stub(x => x.GetProduct(4711, "1,2,3", null, null, null, null, "sv-SE", "2")).IgnoreArguments().Return(new Product { Id = 4711 }); var factory = MockRepository.GenerateMock <IServiceFactory>(); factory.Stub(x => x.CreateProxy <ProductService, ProductServiceClient>(Arg <bool> .Is.Anything, Arg <ICacheManager> .Is.Anything, Arg <string> .Is.Anything, ref Arg <ProductServiceClient> .Ref(Is.Anything(), null).Dummy)) .Return(svc); // Act using (var client = new AccessClient(factory)) { var product = client.ProductProxy.GetProduct(4711, "1,2,3", null, null, null, null, "sv-SE", "2"); // Assert Assert.IsNotNull(product); Assert.AreEqual(4711, product.Id); } }
/// <summary> /// 日志 /// </summary> public static bool LogAdd(string Action, string Description) { string AppID = System.Configuration.ConfigurationManager.AppSettings["AppID"]; AccessClient client = new AccessClient(); try { client.Open(); return client.LogAdd(Convert.ToInt32(AppID), CurrentLogonUser.Uid, System.Web.HttpContext.Current.Request.Url.ToString(), Action, Description); } catch (Exception ex) { return false; } finally { client.Close(); } }
private void storeButton_Click(object sender, EventArgs e) { AccessClient.Instance.ExecuteActionAsync(new Action(delegate { AccessClient.CallAccessService(x => x.UpdateLightweightUser(UserInformation.Instance.User)); }), HeuristicLab.PluginInfrastructure.ErrorHandling.ShowErrorDialog); }
private void AddClient() { AccessClient.CallAccessService(x => x.AddClient(clientView.Content)); }
public BaseController(ILogger logger, AccessClient accessClient, AppConfig appConfig) { this.logger = logger; this.accessClient = accessClient; this.appConfig = appConfig; }