public void ExecuteQuestion() { moq::Mock <QuestionService.QuestionServiceClient> mockGrpcClient = new moq::Mock <QuestionService.QuestionServiceClient>(moq::MockBehavior.Strict); ExecuteQuestionRequest request = new ExecuteQuestionRequest { Name = "name1c9368b0", InterpretationIndex = -988014087, }; Question expectedResponse = new Question { QuestionName = QuestionName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"), Scopes = { "scopes35c99a1e", }, Query = "queryf0c71c1b", DataSourceAnnotations = { "data_source_annotationscbcadb22", }, InterpretError = new InterpretError(), Interpretations = { new Interpretation(), }, CreateTime = new wkt::Timestamp(), UserEmail = "user_emaildc7bc240", DebugFlags = new DebugFlags(), DebugInfo = new wkt::Any(), }; mockGrpcClient.Setup(x => x.ExecuteQuestion(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); QuestionServiceClient client = new QuestionServiceClientImpl(mockGrpcClient.Object, null); Question response = client.ExecuteQuestion(request.Name, request.InterpretationIndex); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary> /// Parse a QuestionName represented as a byte array. /// </summary> /// <param name="data">The byte array.</param> /// <param name="offset">The offset to start parsing from.</param> /// <returns>A parsed QuestionName object.</returns> public static QuestionName Parse(byte[] data, ref int offset) { QuestionName name = new QuestionName(); name.UncompressedName = ExtractName(data, ref offset); name.Type = (QuestionType)((data[offset++] << 8) + data[offset++]); name.Class = (QuestionClass)((data[offset++] << 8) + data[offset++]); return(name); }
private bool Valid() { if (Antwoord1 != null) { Antwoorden.Add(Antwoord1); } if (Antwoord2 != null) { Antwoorden.Add(Antwoord2); } if (Antwoord3 != null) { Antwoorden.Add(Antwoord3); } if (Antwoord4 != null) { Antwoorden.Add(Antwoord4); } if (Antwoord5 != null) { Antwoorden.Add(Antwoord5); } if (Antwoord6 != null) { Antwoorden.Add(Antwoord6); } if (Antwoord7 != null) { Antwoorden.Add(Antwoord7); } if (Antwoord8 != null) { Antwoorden.Add(Antwoord8); } ErrorMessage = null; if (QuestionName == null || QuestionName.Equals("")) { ErrorMessage = "De nieuwe vraag heeft een naam nodig"; return(false); } else if (SelectedQuestionType == null) { ErrorMessage = "Selecteer een vraagtype"; return(false); } else if (Stackpanel.Equals("Visible")) { if (Antwoorden.Count < 2) { ErrorMessage = "Vul minstens 2 antwoorden in"; Antwoorden.Clear(); return(false); } } return(true); }
/// <summary>Snippet for GetQuestion</summary> public void GetQuestionResourceNames() { // Snippet: GetQuestion(QuestionName, CallSettings) // Create client QuestionServiceClient questionServiceClient = QuestionServiceClient.Create(); // Initialize request argument(s) QuestionName name = QuestionName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"); // Make the request Question response = questionServiceClient.GetQuestion(name); // End snippet }
/// <summary>Snippet for GetQuestionAsync</summary> public async Task GetQuestionResourceNamesAsync() { // Snippet: GetQuestionAsync(QuestionName, CallSettings) // Additional: GetQuestionAsync(QuestionName, CancellationToken) // Create client QuestionServiceClient questionServiceClient = await QuestionServiceClient.CreateAsync(); // Initialize request argument(s) QuestionName name = QuestionName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"); // Make the request Question response = await questionServiceClient.GetQuestionAsync(name); // End snippet }
/// <summary>Snippet for GetQuestion</summary> public void GetQuestionRequestObject() { // Snippet: GetQuestion(GetQuestionRequest, CallSettings) // Create client QuestionServiceClient questionServiceClient = QuestionServiceClient.Create(); // Initialize request argument(s) GetQuestionRequest request = new GetQuestionRequest { QuestionName = QuestionName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"), ReadMask = new FieldMask(), }; // Make the request Question response = questionServiceClient.GetQuestion(request); // End snippet }
/// <summary>Snippet for GetQuestionAsync</summary> public async Task GetQuestionRequestObjectAsync() { // Snippet: GetQuestionAsync(GetQuestionRequest, CallSettings) // Additional: GetQuestionAsync(GetQuestionRequest, CancellationToken) // Create client QuestionServiceClient questionServiceClient = await QuestionServiceClient.CreateAsync(); // Initialize request argument(s) GetQuestionRequest request = new GetQuestionRequest { QuestionName = QuestionName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"), ReadMask = new FieldMask(), }; // Make the request Question response = await questionServiceClient.GetQuestionAsync(request); // End snippet }
public async stt::Task GetQuestionRequestObjectAsync() { moq::Mock <QuestionService.QuestionServiceClient> mockGrpcClient = new moq::Mock <QuestionService.QuestionServiceClient>(moq::MockBehavior.Strict); GetQuestionRequest request = new GetQuestionRequest { QuestionName = QuestionName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"), ReadMask = new wkt::FieldMask(), }; Question expectedResponse = new Question { QuestionName = QuestionName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"), Scopes = { "scopes35c99a1e", }, Query = "queryf0c71c1b", DataSourceAnnotations = { "data_source_annotationscbcadb22", }, InterpretError = new InterpretError(), Interpretations = { new Interpretation(), }, CreateTime = new wkt::Timestamp(), UserEmail = "user_emaildc7bc240", DebugFlags = new DebugFlags(), DebugInfo = new wkt::Any(), }; mockGrpcClient.Setup(x => x.GetQuestionAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Question>(stt::Task.FromResult(expectedResponse), null, null, null, null)); QuestionServiceClient client = new QuestionServiceClientImpl(mockGrpcClient.Object, null); Question responseCallSettings = await client.GetQuestionAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Question responseCancellationToken = await client.GetQuestionAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary> /// Parse a ResourceRecord represented as a byte array. /// </summary> /// <param name="data">The byte array.</param> /// <param name="offset">The offset to start parsing from.</param> /// <returns>A parsed ResourceRecord.</returns> public static ResourceRecord Parse(byte[] data, ref int offset) { ResourceRecord record = new ResourceRecord(); record.UncompressedName = QuestionName.ExtractName(data, ref offset); record.Type = (ResourceRecordType)((data[offset++] << 8) + data[offset++]); record.Class = (ResourceRecordClass)((data[offset++] << 8) + data[offset++]); record.TTL = (uint)((data[offset++] << 24) + (data[offset++] << 16) + (data[offset++] << 8) + data[offset++]); int length = (ushort)((data[offset++] << 8) + data[offset++]); if (length > 0) { record.Data = new byte[length]; for (int i = 0; i < length; i++) { record.Data[i] = data[offset++]; } } else { record.Data = null; } return(record); }
public override string DataValidate(string name) { switch (name) { case "QuestionName": { if (string.IsNullOrEmpty(QuestionName.Trim())) { return("题目不能为空!"); } } break; case "LvTradeInfo": { if (LvTradeInfo.Count == 0) { return("答案不能为空!"); } } break; } return(null); }
public void Update() { string strsql = "update JobPost_Question set " + "JobPostId= " + JobPostId + ", " + "Date= '" + Date.ToString("MM/dd/yyyy hh:mm:ss tt") + "', " + "QuestionName= '" + QuestionName.Replace("'", "''") + "', " + "Status= '" + Status.Replace("'", "''") + "' " + " where ID =" + Id; SqlConnection ObjConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyJobPortal"].ConnectionString); ObjConnection.Open(); SqlCommand ObjCommand = new SqlCommand(strsql, ObjConnection); ObjCommand.ExecuteNonQuery(); ObjConnection.Dispose(); ObjCommand.Dispose(); }
/// <summary> /// Parse a QuestionName represented as a byte array. /// </summary> /// <param name="data">The byte array.</param> /// <param name="offset">The offset to start parsing from.</param> /// <returns>A parsed QuestionName object.</returns> public static QuestionName Parse(byte[] data, ref int offset) { QuestionName name = new QuestionName(); name.UncompressedName = ExtractName(data, ref offset); name.Type = (QuestionType)((data[offset++] << 8) + data[offset++]); name.Class = (QuestionClass)((data[offset++] << 8) + data[offset++]); return name; }
/// <summary> /// Parses a packet from incomming data. /// </summary> /// <param name="data">Byte array containing the incomming data.</param> /// <returns>A parsed Packet.</returns> public static Packet Parse(byte[] data) { Packet packet = new Packet(); packet.Header = Header.Parse(data); int offset = packet.Header.ByteSize; if (packet.Header.QdCount > 0) { packet.QuestionEntries = new QuestionName[packet.Header.QdCount]; for (int i = 0; i < packet.Header.QdCount; i++) { packet.QuestionEntries[i] = QuestionName.Parse(data, ref offset); } } else { packet.QuestionEntries = null; } if (packet.Header.AnCount > 0) { packet.AnswerResourceRecords = new ResourceRecord[packet.Header.AnCount]; for (int i = 0; i < packet.Header.AnCount; i++) { packet.AnswerResourceRecords[i] = ResourceRecord.Parse(data, ref offset); } } else { packet.AnswerResourceRecords = null; } if (packet.Header.NsCount > 0) { packet.AuthorityResourceRecords = new ResourceRecord[packet.Header.NsCount]; for (int i = 0; i < packet.Header.NsCount; i++) { packet.AuthorityResourceRecords[i] = ResourceRecord.Parse(data, ref offset); } } else { packet.AuthorityResourceRecords = null; } if (packet.Header.ArCount > 0) { packet.AdditionalResourceRecords = new ResourceRecord[packet.Header.ArCount]; for (int i = 0; i < packet.Header.ArCount; i++) { packet.AdditionalResourceRecords[i] = ResourceRecord.Parse(data, ref offset); } } else { packet.AdditionalResourceRecords = null; } return(packet); }