public void Build(TypeBuilder typeBuilder, FieldBuilder injectionSetField, Type injectionType) { var parameterTypes = new[] { typeof(string) }; var methods = new Methods(typeBuilder, _methodName, parameterTypes); var injectionMethod = injectionType.GetMethod(_methodName, new[] { typeof(BaseType), typeof(string) }); var il = methods.GetILGenerator(injectionType); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Call, methods.BaseMethod); il.EmitGetInjections(injectionSetField, injectionType); il.EmitInjectionLoop(x => { x.Emit(OpCodes.Ldarg_0); x.Emit(OpCodes.Ldarg_1); x.Emit(OpCodes.Callvirt, injectionMethod); }); il.Emit(OpCodes.Ret); }
private static BaseResponse GetResponse(Methods methodCalled, returntype sfgReturn) { string className = "SFGWrapper.HeartbeatTranslators"; BaseResponse baseResponse = new BaseResponse(); foreach (var item in sfgReturn.error) { Message ahError = new Message(item.errno, MessageSources.Heartbeat); foreach (string message in item.errmsg) { ahError.SfgMessages.Add(message); } baseResponse.Messages.Add(ahError); } switch (methodCalled) { case Methods.PING: PingResponse heartbeatServiceResponse = new PingResponse(); heartbeatServiceResponse.Success = sfgReturn.success; baseResponse.TypedResponse = heartbeatServiceResponse; break; } baseResponse.TypedResponse.Success = sfgReturn.success; baseResponse.TypedResponse.Info = Utilities.GetInfo(sfgReturn.response.INFO); baseResponse.TypedResponse.MemoryUsed = sfgReturn.response.MEMORY_USED; baseResponse.TypedResponse.Protocol = sfgReturn.response.PROTOCOL; baseResponse.TypedResponse.RoundtripTime = sfgReturn.response.ROUNDTRIP_TIME; baseResponse.TypedResponse.Server = sfgReturn.response.SERVER; baseResponse.TypedResponse.TimeElapsed = sfgReturn.response.TIME_ELAPSED; baseResponse.TypedResponse.Version = sfgReturn.response.VERSION; return baseResponse; }
internal virtual Methods DescribeMethods() { Methods methods = new Methods(); methods.Add(new Method("GetWorklistItems", MethodType.List, new MetaData("Get Worklist Items", "Returns a collection of worklist items."), GetRequiredProperties("GetWorklistItems"), GetMethodParameters("GetWorklistItems"), GetInputProperties("GetWorklistItems"), GetReturnProperties("GetWorklistItems"))); methods.Add(new Method("LoadWorklistItem", MethodType.Read, new MetaData("Load Worklist Item", "Returns the specified worklist item."), GetRequiredProperties("LoadWorklistItem"), GetMethodParameters("LoadWorklistItem"), GetInputProperties("LoadWorklistItem"), GetReturnProperties("LoadWorklistItem"))); return methods; }
public void SelectNonMethodCallExpressionWithoutReturnThrows() { var sut = new Methods<ClassWithMethods>(); Expression<Action<ClassWithMethods>> nonMethodCallExpression = _ => new object(); Assert.Throws<ArgumentException>( () => sut.Select(nonMethodCallExpression)); }
public void Sut_ProcessCommand_VerifyGuardClauses( GuardClauseAssertion assertion, IAsyncCommand command) { var method = new Methods<ConcurrencyExecutionAsyncCommandBus>() .Select(sut => sut.ProcessCommand(command)); assertion.Verify(method); }
/// <summary> /// Aborts the specified method detour. /// </summary> /// <param name="method">The method.</param> public static void Abort(Methods method) { MethodDetoursBase detours; if (TryGetMethodDetours(method, out detours)) { detours.Abort(); } }
public void VerifyMethodMemberCallsVerifyMethod() { var sut = new Mock<IdiomaticAssertion> { CallBase = true }.Object; var method = new Methods<ClassWithMembers>().Select(x => x.PublicMethod()); sut.Verify((MemberInfo)method); sut.ToMock().Verify(x => x.Verify(method)); }
private void LoadBindings() { this.treeView1.Nodes.Clear(); this.treeView1.DrawMode = TreeViewDrawMode.OwnerDrawText; this.treeView1.DrawNode += new DrawTreeNodeEventHandler(DrawNode); Methods _methods = new Methods(); TemplateCustomXML tXML = _methods.ReadXML<TemplateCustomXML>(Globals.ThisAddIn.Application.ActiveDocument); Tools.Models.Template _temp = null; if (tXML != null) { _temp = _temp = ThisAddIn._document<Tools.Models.Template>(tXML.TemplateID);// _temp.AutoDocuments.ForEach(au => { au = _unitOfWork.AutoDocumentRepository.FindBy(id => id.AutoDocumentID == au.AutoDocumentID, "BookMarkDatas"); TreeNode document = new TreeNode(au.Name); document.Name = au.AutoDocumentID; _temp.BookMarks.ForEach(bkmk => { var bkd = au.BookMarkDatas.Where(aubd => aubd.BookMarkID == bkmk.BookMarkID).FirstOrDefault(); if (bkd == null) { var node = new TreeNode(bkmk.BookmarkName); node.Tag = bkmk.BookmarkName; node.Name = bkmk.BookMarkID; node.ForeColor = System.Drawing.Color.Red; document.Nodes.Add(node); // document.ForeColor = System.Drawing.Color.Black; document.ForeColor = System.Drawing.Color.Red; } else { var node = new TreeNode((bkmk.BookmarkName + " = " + bkd.BookMarkValue)); node.Tag = bkmk.BookmarkName; node.Name = bkmk.BookMarkID; document.Nodes.Add(node); } }); document.Checked = document.Nodes.Descendants().Where(n => n.ForeColor == System.Drawing.Color.Red).Any() ? false : true; this.treeView1.Nodes.Add(document); this.treeView1.CheckBoxes = true; }); } }
public void NestedSummary() { serializer = new XmlSerializer(typeof (Methods)); var methods =new Methods(null); serializer.Serialize(writer, methods); string result = textWriter.ToString(); Assert.AreEqual(null, result); }
public void QueryParameterLessMethodWithReturnValueUsingLinqSyntax() { var sut = new Methods<ClassWithMethods>(); var actual = from x in sut select x.OmitParametersWithReturnValue(); var expected = typeof(ClassWithMethods).GetMethod("OmitParametersWithReturnValue"); Assert.Equal(expected, actual); }
public void CreateReturnsEmptyCommandIfTestMethodIsParameterized() { var sut = new FactCommandFactory(); var method = new Methods<FactCommandFactoryTest>().Select(x => x.ParameterizedMethod(null, 0)); var actual = sut.Create(Reflector.Wrap(method), null); Assert.Empty(actual); }
/// <summary> /// Create a client that connects to the SendGrid Web API /// </summary> /// <param name="method">HTTP verb, case-insensitive</param> /// <param name="endpoint">Resource endpoint, do not prepend slash</param> /// <param name="data">An JObject representing the resource's data</param> /// <returns>An asyncronous task</returns> private async Task<HttpResponseMessage> RequestAsync(Methods method, string endpoint, JObject data) { using (var client = new HttpClient()) { try { client.BaseAddress = _baseUri; client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaType)); if (!string.IsNullOrWhiteSpace(_userName) && !string.IsNullOrWhiteSpace(_password)) { var byteArray = Encoding.ASCII.GetBytes(string.Format("{0}:{1}", _userName, _password)); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray)); } else { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _apiKey); } client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "sendgrid/" + Version + ";csharp"); switch (method) { case Methods.GET: return await client.GetAsync(endpoint); case Methods.POST: return await client.PostAsJsonAsync(endpoint, data); case Methods.PATCH: endpoint = _baseUri + endpoint; StringContent content = new StringContent(data.ToString(), Encoding.UTF8, MediaType); HttpRequestMessage request = new HttpRequestMessage { Method = new HttpMethod("PATCH"), RequestUri = new Uri(endpoint), Content = content }; return await client.SendAsync(request); case Methods.DELETE: return await client.DeleteAsync(endpoint); default: HttpResponseMessage response = new HttpResponseMessage(); response.StatusCode = HttpStatusCode.MethodNotAllowed; var message = "{\"errors\":[{\"message\":\"Bad method call, supported methods are GET, POST, PATCH and DELETE\"}]}"; response.Content = new StringContent(message); return response; } } catch (Exception ex) { HttpResponseMessage response = new HttpResponseMessage(); string message; message = (ex is HttpRequestException) ? ".NET HttpRequestException" : ".NET Exception"; message = message + ", raw message: \n\n"; response.Content = new StringContent(message + ex.Message); return response; } } }
public void SelectParameterLessReturnsCorrectMethod() { var sut = new Methods<ClassWithMethods>(); MethodInfo actual = sut.Select(x => x.OmitParameters()); var expected = typeof(ClassWithMethods).GetMethod("OmitParameters"); Assert.Equal(expected, actual); }
public void CreateDoesNotCreateTestFixtureForNonParameterizedMethod() { var sut = new TestCaseCommandFactory(); var method = new Methods<TestClass>().Select(x => x.TestMethod()); var factory = Mocked.Of<ISpecimenBuilderFactory>(); sut.Create(Reflector.Wrap(method), factory); factory.ToMock().Verify(x => x.Create(It.IsAny<ITestMethodContext>()), Times.Never()); }
public Server(int port) { Version = 1; Methods = new Methods(); Subscriptions = new Subscriptions(); Publications = new Publications(); new PublicationMethods(this).AttachMethods(); var messageMethods = new MessageMethods(this).GetMethods(); var messageProcessor = new MessageProcessor(messageMethods); _messageQueue = new ResultQueue<KeyValuePair<IWebSocketConnection, string>>(messageProcessor); _connector = new Connector(this, "127.0.0.1", port); }
public Api(Methods method, string url) { this.Method = method; try { this.Url = new Uri(url); } catch { throw new ApplicationException("APIの初期化に失敗しました。URLが正しくありません。"); } }
public void VisitLocalVariableInfoElementsReturnsItself() { var sut = new Mock<MemberReferenceCollector> { CallBase = true }.Object; sut.ToMock().Setup(x => x.Visit(It.IsAny<LocalVariableInfoElement>())).Throws<InvalidOperationException>(); var localVariableInfoElement = new Methods<ClassForCollectingReference>() .Select(x => x.ReturnMethod()).GetMethodBody() .LocalVariables.First().ToElement(); var actual = sut.Visit(new[] { localVariableInfoElement }); Assert.Same(sut, actual); }
public void CustomizeCorrectlyCustomizesFixture() { var parameters = new Methods<ParameterCustomizationTest>() .Select(x => x.TestMethod(null, null)) .GetParameters(); var sut = new ParameterCustomization(parameters); var fixture = new Fixture(); sut.Customize(fixture); Assert.Equal(fixture.Create<object>(), fixture.Create<object>()); Assert.NotNull(fixture.Create<Person>().Name); }
/// <summary> /// Twitterへのリクエストを作成します。 /// </summary> /// <param name="twitterContext">リクエストを行うTwitterContext。</param> /// <param name="method">APIのリクエストに使用するHTTPメソッド。</param> /// <param name="url">APIのURL。</param> /// <param name="query">リクエストのパラメータ。</param> public TwitterRequest( TwitterContext twitterContext = null, Methods method = Methods.POST, Uri url = null, StringDictionary query = null, string proxy = null, string userAgent = null) { this.TwitterContext = twitterContext; this.Method = method; this.Url = url; this.Parameter = query; this.Proxy = proxy; this.UserAgent = userAgent; }
private void tbCod_method_InvalidValue(object sender, DevExpress.XtraEditors.Controls.InvalidValueExceptionEventArgs e) { try { List<CTemplate_method> lstTemplateMethod = new Methods().GetAllLastVersionMethods(); CTemplate_method oTemplate_method = lstTemplateMethod.Single(c => c.Cod_template_method == tbCod_method.Text); if (oTemplate_method == null) e.ErrorText = "el código de método ya se encuentra asignado"; else e.ErrorText = "el código de método ya se encuentra asignado al método " + oTemplate_method.Abbreviation; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ASLScript(Methods methods, Dictionary<string, List<ASLState>> states) { _methods = methods; _states = states; _settings = new ASLSettings(); _vars = new ExpandoObject(); if (!_methods.start.IsEmpty) _settings.AddBasicSetting("start"); if (!_methods.split.IsEmpty) _settings.AddBasicSetting("split"); if (!_methods.reset.IsEmpty) _settings.AddBasicSetting("reset"); _uses_game_time = !_methods.isLoading.IsEmpty || !_methods.gameTime.IsEmpty; }
public SyncFolder(string pFolderPath) { FolderPath = pFolderPath; LastSync = new DateTime(2000, 1, 1); SetId = ""; SetTitle = ""; SetDescription = ""; SyncMethod = StringToMethod(Properties.Settings.Default.Method); FilterType = FilterTypes.FilterNone; FilterTags = ""; FilterStarRating = 0; Permission = FlickrSync.Permissions.PermDefault; NoDelete = Properties.Settings.Default.NoDelete; NoDeleteTags = Properties.Settings.Default.NoDeleteTags; OrderType = OrderTypes.OrderDefault; NoInitialReplace = false; }
private static Methods GetMethods(NSObject obj, string selector) { Dictionary<IntPtr, Methods> dictionary; if (!_callbacks.TryGetValue(obj.Handle, out dictionary)) { _callbacks[obj.Handle] = dictionary = new Dictionary<IntPtr, Methods>(); } IntPtr selectorHandle = ObjC.GetSelector(selector); Methods methods; if (!dictionary.TryGetValue(selectorHandle, out methods)) { dictionary[selectorHandle] = methods = new Methods(obj); } return methods; }
public void AutoDocSaveFolder(Office.IRibbonControl control) { //System.Windows.Forms.SaveFileDialog save = new System.Windows.Forms.SaveFileDialog(); //save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); //save.RestoreDirectory = true; System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //System.Windows.Forms.MessageBox.Show(fbd.SelectedPath); Methods _methods = new Methods(); TemplateCustomXML tXML = _methods.ReadXML<TemplateCustomXML>(Globals.ThisAddIn.Application.ActiveDocument); Tools.Models.Template _temp = null; if (tXML != null) _temp = _temp = ThisAddIn._document<Tools.Models.Template>(tXML.TemplateID);// _temp.AutoDocumentsPath = fbd.SelectedPath; ThisAddIn._unitOfWork.Save(); } }
public void SetDefaultValue() { Final = false; Error = false; state = State0; boolExPosition = int.MinValue; BaseAction = BaseActions.None; Method = Methods.None; AccountAction = AccountActions.None; DomainName.SetDefaultValue(); Signature.SetDefaultValue(); Authname.SetDefaultValue(); UsersId.SetDefaultValue(); Username.SetDefaultValue(); Timestamp = long.MinValue; Count = int.MinValue; StartIndex = int.MinValue; OnSetDefaultValue(); }
private static BaseResponse GetResponse(Methods methodCalled, PingRequest ahRequest) { string className = "SFGWrapper.Heartbeat"; BaseResponse baseResponse = new BaseResponse(); try { using (HeartbeatService svc = new HeartbeatService()) { svc.Timeout = 20000; svc.Credentials = new System.Net.NetworkCredential(ahRequest.ServiceUsername, ahRequest.ServicePassword); argtype sfgRequest = HeartbeatTranslators.TranslateToSfgRequest(ahRequest); switch (methodCalled) { case Methods.PING: baseResponse = HeartbeatTranslators.Ping(svc.process_wsdl(sfgRequest)); break; } } if (baseResponse == null) { baseResponse = new BaseResponse(); FatalErrorResponse fatalError = new FatalErrorResponse(); baseResponse.TypedResponse = fatalError; baseResponse.Messages.Add(new Message("SFGFatalError")); } } catch (Exception ex) { baseResponse = new BaseResponse(); FatalErrorResponse fatalError = new FatalErrorResponse(); baseResponse.TypedResponse = fatalError; Message error = new Message("UnknownException"); baseResponse.DebugStringLog.Add(ex.TargetSite.Name); baseResponse.DebugStringLog.Add(ex.Message); baseResponse.DebugStringLog.Add(ex.StackTrace); baseResponse.Messages.Add(error); EventLogger.LogError(string.Format("{0}.{1}()", new object[] { className, methodCalled.ToString() }), string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace)); } return baseResponse; }
public void CreatePassesCorrectMethodContextForParameterizedMethod() { var sut = new TestCaseCommandFactory(); var method = new Methods<TestClass>().Select(x => x.TestMethod(null, 0, null)); var factory = Mocked.Of<ISpecimenBuilderFactory>(); factory.ToMock() .Setup(x => x.Create(It.IsAny<ITestMethodContext>())) .Returns(new Fixture()) .Callback<ITestMethodContext>(c => { Assert.Equal(method, c.TestMethod); Assert.Equal(method, c.ActualMethod); Assert.IsAssignableFrom<TestClass>(c.TestObject); Assert.IsAssignableFrom<TestClass>(c.ActualObject); }); sut.Create(Reflector.Wrap(method), factory).ToArray(); factory.ToMock().VerifyAll(); }
public void LogEnd(Methods Method, string parameter, string processingTime, string Count, string UserHost) { switch (Method) { case Methods.GetVariables: case Methods.GetVariablesObject: LogQueryFormatted( Method.ToString(), null, parameter, null, null, processingTime, Count, UserHost); break; case Methods.GetSites: case Methods.GetSitesObject: case Methods.GetSiteInfo: case Methods.GetSiteInfoObject: LogQueryFormatted( Method.ToString(), parameter, null, null, null, processingTime, Count, UserHost); break; default: LogQueryUnformatted( Method.ToString(), parameter ); break; } }
private void txtAmount_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { Methods clsMethods = new Methods(); e.Handled = clsMethods.AllNumWithDecimal(Convert.ToInt32(e.KeyChar)); }
void GenerateInterfaceStubs(Type interfaceType) { WriteLine(); /* WriteLine("public partial class {0}_", interfaceType.SimpleName); WriteLine("{"); myIndent++; WriteLine("public static global::java.lang.Class _class"); WriteLine("{"); myIndent++; WriteLine("get {{ return __{0}.staticClass; }}", interfaceType.SimpleName); myIndent--; WriteLine("}"); myIndent--; WriteLine("}"); WriteLine(); */ Type wrapperType = new Type(); wrapperType.WrappedInterface = interfaceType.Name; wrapperType.WrappedInterfaceType = interfaceType; //wrapperType.Name = interfaceType.Name.Insert(interfaceType.Name.LastIndexOf('.') + 1, "_"); wrapperType.Name = interfaceType.Name + "_"; wrapperType.Scope = interfaceType.Scope; wrapperType.IsSealed = true; if (interfaceType.IsInterface) { wrapperType.Parent = "java.lang.Object"; wrapperType.ParentType = myModel.FindType("java.lang.Object"); wrapperType.Interfaces.Add(interfaceType.Name); wrapperType.InterfaceTypes.Add(interfaceType); var h = new HashSet<Type>(); AddAllInterfaces(interfaceType, h); foreach (var i in h) { foreach (var m in i.Methods) { var mc = new Method(); mc.Type = wrapperType; mc.Name = i.Name + "." + m.Name; //mc.Scope = "public"; mc.Parameters.AddRange(m.Parameters); mc.ParameterTypes.AddRange(m.ParameterTypes); mc.Return = m.Return; mc.ReturnType = m.ReturnType; if (!wrapperType.Methods.Contains(mc)) wrapperType.Methods.Add(mc); } } } else { wrapperType.Parent = interfaceType.Name; wrapperType.ParentType = interfaceType; var curType = interfaceType; var allImplementedMethods = new Methods(); while (curType != null) { foreach (var m in curType.Methods) { if (!m.Abstract) { if (!allImplementedMethods.Contains(m)) allImplementedMethods.Add(m); continue; } if (allImplementedMethods.Contains(m)) continue; var mc = new Method(); mc.Type = wrapperType; mc.Name = m.Name; mc.Scope = m.Scope; mc.IsOverride = true; mc.Parameters.AddRange(m.Parameters); mc.ParameterTypes.AddRange(m.ParameterTypes); mc.Return = m.Return; mc.ReturnType = m.ReturnType; if (!wrapperType.Methods.Contains(mc)) wrapperType.Methods.Add(mc); } curType = curType.ParentType; } } myTypesOfInterest.Add(wrapperType); myIndent--; GenerateType(wrapperType); myIndent++; }