public void L2CapGetChannelByte_0xF0F9() { ServiceRecord rcd = ServiceRecord.CreateServiceRecordFromBytes(Data_CompleteThirdPartyRecords.SemcHla); int value = ServiceRecordHelper.GetL2CapChannelNumber(rcd); Assert.AreEqual(0xF0F9, value); }
private static ServiceRecord CreateServiceRecord() { ServiceElement englishUtf8PrimaryLanguage = CreateEnglishUtf8PrimaryLanguageServiceElement(); ServiceRecord record = new ServiceRecord( new ServiceAttribute(InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.ServiceClassIdList, new ServiceElement(ElementType.ElementSequence, new ServiceElement(ElementType.Uuid16, (UInt16)0x1105))), new ServiceAttribute(InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.ProtocolDescriptorList, ServiceRecordHelper.CreateGoepProtocolDescriptorList()), #if ADD_SERVICE_NAME_TO_SDP_RECORD // Could add ServiceName, ProviderName etc here. new ServiceAttribute(InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.LanguageBaseAttributeIdList, englishUtf8PrimaryLanguage), new ServiceAttribute(ServiceRecord.CreateLanguageBasedAttributeId( InTheHand.Net.Bluetooth.AttributeIds.UniversalAttributeId.ProviderName, LanguageBaseItem.PrimaryLanguageBaseAttributeId), new ServiceElement(ElementType.TextString, "32feet.NET")), #endif // new ServiceAttribute(InTheHand.Net.Bluetooth.AttributeIds.ObexAttributeId.SupportedFormatsList, new ServiceElement(ElementType.ElementSequence, new ServiceElement(ElementType.UInt8, (byte)0xFF))) ); return(record); }
internal ServiceRecord BuildRecord(Structs.sdp_record_t rcdData) { var attrList = new List <ServiceAttribute>(); int count = 0; IntPtr pCurAttr = rcdData.attrlist; for (int HACK = 0; HACK < RestrictRunawayCount; ++HACK) { ++count; var item = (Structs.sdp_list_t)Marshal.PtrToStructure( pCurAttr, typeof(Structs.sdp_list_t)); //Console.WriteLine(" item next: 0x{0:X8}, data 0x{1:X8}", item.next, item.data); var attrData = (Structs.sdp_data_struct__Bytes)Marshal.PtrToStructure( item.data, typeof(Structs.sdp_data_struct__Bytes)); //Console.WriteLine(" attrId: 0x{0:X}", attrData.attrId); var attr = BuildAttribute(item.data); attrList.Add(attr); // Next pCurAttr = item.next; if (pCurAttr == IntPtr.Zero) { break; } }//while Console.WriteLine("attr count: {0}", count); var r = new ServiceRecord(attrList); return(r); }
public BluetoothListener(Guid service, ServiceRecord sdpRecord) { InitServiceRecord(sdpRecord); serverEP = new BluetoothEndPoint(BluetoothAddress.None, service); serverSocket = new BluetoothSocket(); option = new SocketOption(serverSocket); }
public virtual void TestPurgeEntryCuratorCallback() { string path = "/users/example/hbase/hbase1/"; ServiceRecord written = BuildExampleServiceEntry(PersistencePolicies.ApplicationAttempt ); written.Set(YarnRegistryAttributes.YarnId, "testAsyncPurgeEntry_attempt_001"); operations.Mknode(RegistryPathUtils.ParentOf(path), true); operations.Bind(path, written, 0); ZKPathDumper dump = registry.DumpPath(false); CuratorEventCatcher events = new CuratorEventCatcher(); Log.Info("Initial state {}", dump); // container query string id = written.Get(YarnRegistryAttributes.YarnId, string.Empty); int opcount = Purge("/", id, PersistencePolicies.Container, RegistryAdminService.PurgePolicy .PurgeAll, events); AssertPathExists(path); NUnit.Framework.Assert.AreEqual(0, opcount); NUnit.Framework.Assert.AreEqual("Event counter", 0, events.GetCount()); // now the application attempt opcount = Purge("/", id, PersistencePolicies.ApplicationAttempt, RegistryAdminService.PurgePolicy .PurgeAll, events); Log.Info("Final state {}", dump); AssertPathNotFound(path); NUnit.Framework.Assert.AreEqual("wrong no of delete operations in " + dump, 1, opcount ); // and validate the callback event NUnit.Framework.Assert.AreEqual("Event counter", 1, events.GetCount()); }
public void GetAllServiceRecordForMember() { var memberlist = new MemberList(); var member = new Member(); member.Name = "Zhao"; member.StreetAddress = "123 77th Ave S"; member.State = "MN"; member.City = "Saint Cloud"; member.ZipCode = "12345"; var newMemberId = memberlist.InsertMember(member); Assert.IsTrue(null != newMemberId, "Adding member Fail!"); var list = new ServiceRecordList(); var serviceRecord = new ServiceRecord(1231, DateTime.Now, DateTime.Today, 100, newMemberId.Value, "Hello, This is a Test!"); var serviceRecord2 = new ServiceRecord(1231, DateTime.Now, DateTime.Today, 100, newMemberId.Value, "Hello, This is a Test!"); var result1 = list.InsertServiceRecord(serviceRecord); var result2 = list.InsertServiceRecord(serviceRecord2); Assert.IsTrue(null != result1, "Adding Fail!"); Assert.IsTrue(null != result2, "Adding Fail!"); var result = list.GetAllServiceRecordForMember(newMemberId.Value); Assert.IsTrue(null != result, "Get list Fail!"); }
void DoTest_HackOneSeqDeep(StackConsts.SDP_Data_Element_Type expectedET, byte[] expectedDataValue, ServiceRecord r) { var stuff = BluetopiaTesting.InitMockery_SdpCreator(); // const UInt16 attrId = 0xF234; var expectedElement = new Structs.SDP_Data_Element__Class_ElementArray( StackConsts.SDP_Data_Element_Type.Sequence, 1, new Structs.SDP_Data_Element__Class[] { new Structs.SDP_Data_Element__Class_InlineByteArray( expectedET, expectedDataValue.Length, expectedDataValue) }); Expect.Once.On(stuff.MockApi2).Method("SDP_Add_Attribute") .With( stuff.StackId, stuff.SrHandle, attrId, expectedElement ) .Will(Return.Value(BluetopiaError.OK)); // stuff.DutSdpCreator.CreateServiceRecord(r); stuff.Mockery_VerifyAllExpectationsHaveBeenMet(); VerifyDispose(stuff); }
public async Task <bool> CreateService(string serviceName, string serviceType, string version, IEnumerable <string> files) { bool ret = false; string url = null; if (string.IsNullOrEmpty(serviceName) || string.IsNullOrEmpty(serviceType) || string.IsNullOrEmpty(version) || files == null || files.Count() == 0) { return(ret); } bool isExisted = await ExistedService(serviceName, serviceType, version); if (isExisted) { return(ret); } string href = JsonSettings.DefaultSettings.GetValue <string>("href"); string capabilitiesPath = null; IOgcService ogcService = OgcServiceHelper.GetOgcService(serviceType, version); Dictionary <string, string> layerNameAndPathes = new Dictionary <string, string>(); if (ogcService is IWmtsService wmts1Service) { href = $"{href}/SharpMapServer/Services/{serviceName}/MapServer/Wmts"; Capabilities capabilities = wmts1Service.CreateCapabilities(href); string directory = null; foreach (var file in files) { if (directory == null) { directory = Path.GetDirectoryName(file); } LayerType layerType = wmts1Service.AddContent(capabilities, file); string name = Path.GetFileNameWithoutExtension(file); layerNameAndPathes[name] = file; } capabilitiesPath = Path.Combine(directory, "WMTSCapabilities.xml"); using (StreamWriter sw = new StreamWriter(capabilitiesPath)) { wmts1Service.XmlSerialize(sw, capabilities); } url = $"{href}/1.0.0/WMTSCapabilities.xml"; } else { return(ret); } ret = await AddServiceRecord(serviceName, serviceType, version, capabilitiesPath); ServiceRecord serviceRecord = await GetServiceRecord(serviceName, serviceType, version); foreach (var item in layerNameAndPathes) { bool result = await AddLayerRecord(serviceRecord, item.Key, item.Value); } if (!ret) { File.Delete(capabilitiesPath); } return(ret); }
public CsrDetailViewModel(ServiceRecord serviceRecord, PlaylistOrientationEntity playlistOrientation, CommonModels.CurrentSkillRank currentSkillRank, MetadataModels.Playlist playlist) : base(serviceRecord) { Playlist = playlist; PlaylistOrientation = playlistOrientation; CurrentSkillRank = currentSkillRank; }
public void GetChannelByte_SdpNone() { ServiceRecord rcd = ServiceRecord.CreateServiceRecordFromBytes(Data_CompleteThirdPartyRecords.XpB_0of2Sdp); int value = ServiceRecordHelper.GetRfcommChannelNumber(rcd); Assert.AreEqual(-1, value); }
public void GetChannelByte_PdlHasUuid128s() { ServiceRecord rcd = ServiceRecord.CreateServiceRecordFromBytes(Data_CompleteThirdPartyRecords.KingSt_d2r1_withPdlUuid128s); int value = ServiceRecordHelper.GetRfcommChannelNumber(rcd); Assert.AreEqual(2, value); }
public void GetChannelElement_SdpNone() { ServiceRecord rcd = ServiceRecord.CreateServiceRecordFromBytes(Data_CompleteThirdPartyRecords.XpB_0of2Sdp); ServiceElement element = ServiceRecordHelper.GetRfcommChannelElement(rcd); Assert.IsNull(element); }
public void GetPrimarySvcClassId_Opp() { ServiceRecord rcd = ServiceRecord.CreateServiceRecordFromBytes(Data_CompleteThirdPartyRecords.PalmOsOpp); Guid id = ServiceRecordHelper._GetPrimaryServiceClassId(rcd); Assert.AreEqual(BluetoothService.ObexObjectPush, id); }
public void GetChannelByte_AttrNotExists() { ServiceRecord rcd = new ServiceRecord(); int value = ServiceRecordHelper.GetRfcommChannelNumber(rcd); Assert.AreEqual(-1, value); }
public void ZeroAttributes() { var listAllocs = new List <IntPtr>(); IntPtr pCur; // var attrRsp = new Structs.SDP_Service_Attribute_Response_Data(0, IntPtr.Zero); pCur = CopyToNative(listAllocs, ref attrRsp); // var svcSrchAttrRsp = new Structs.SDP_Response_Data__SDP_Service_Search_Attribute_Response_Data( StackConsts.SDP_Response_Data_Type.ServiceSearchAttributeResponse, 1, pCur); pCur = CopyToNative(listAllocs, ref svcSrchAttrRsp); // var stuff = Create_BluetopiaSdpQuery(); List <ServiceRecord> rList = stuff.DutSdpQuery.BuildRecordList(pCur); Assert.AreEqual(1, rList.Count); ServiceRecord r = rList[0]; // Assert.AreEqual(0, r.Count, "Count"); // Free(listAllocs); }
/// <exception cref="System.Exception"/> public virtual void TestRecordValidationWrongType() { ServiceRecord record = new ServiceRecord(); record.type = "NotAServiceRecordType"; RegistryTypeUtils.ValidateServiceRecord("validating", record); }
public Base(ServiceRecord serviceRecord) { ServiceRecord = serviceRecord; RecentWarGamesHistory = GlobalStorage.H4Manager.GetPlayerGameHistory <GameHistoryModel.WarGames>(serviceRecord.Gamertag, 0, 20); PublicGamertag = ServiceRecord.Gamertag; }
/// <exception cref="System.Exception"/> public virtual void TestUnmarshallWrongType() { byte[] bytes = Sharpen.Runtime.GetBytesForString("{'type':''}"); ServiceRecord serviceRecord = marshal.FromBytes("marshalling", bytes); RegistryTypeUtils.ValidateServiceRecord("validating", serviceRecord); }
public void GetAllServiceRecordForProvider() { var providerList = new ProviderList(); var provider = new Provider(); provider.Name = "Zhao"; provider.StreetAddress = "123 77th Ave S"; provider.State = "MN"; provider.City = "Saint Cloud"; provider.ZipCode = "12345"; var newId = providerList.AddProvider(provider); Assert.IsTrue(null != newId, "Adding member Fail!"); var list = new ServiceRecordList(); var serviceRecord = new ServiceRecord(1231, DateTime.Now, DateTime.Today, newId.Value, 1001, "Hello, This is a Test!"); var serviceRecord2 = new ServiceRecord(1231, DateTime.Now, DateTime.Today, newId.Value, 1001, "Hello, This is a Test!"); Assert.IsTrue(null != serviceRecord, "Adding Fail!"); Assert.IsTrue(null != serviceRecord2, "Adding Fail!"); var result = list.GetAllServiceRecordForProvider(newId.Value); Assert.IsTrue(null != result, "Get list Fail!"); }
/// <summary> /// General code to validate bits of a component/service entry built iwth /// <see cref="AddSampleEndpoints(Org.Apache.Hadoop.Registry.Client.Types.ServiceRecord, string) /// "/> /// </summary> /// <param name="record">instance to check</param> public static void ValidateEntry(ServiceRecord record) { NUnit.Framework.Assert.IsNotNull("null service record", record); IList <Endpoint> endpoints = record.external; NUnit.Framework.Assert.AreEqual(2, endpoints.Count); Endpoint webhdfs = FindEndpoint(record, ApiWebhdfs, true, 1, 1); NUnit.Framework.Assert.AreEqual(ApiWebhdfs, webhdfs.api); NUnit.Framework.Assert.AreEqual(AddressTypes.AddressUri, webhdfs.addressType); NUnit.Framework.Assert.AreEqual(ProtocolTypes.ProtocolRest, webhdfs.protocolType); IList <IDictionary <string, string> > addressList = webhdfs.addresses; IDictionary <string, string> url = addressList[0]; string addr = url["uri"]; NUnit.Framework.Assert.IsTrue(addr.Contains("http")); NUnit.Framework.Assert.IsTrue(addr.Contains(":8020")); Endpoint nnipc = FindEndpoint(record, Nnipc, false, 1, 2); NUnit.Framework.Assert.AreEqual("wrong protocol in " + nnipc, ProtocolTypes.ProtocolThrift , nnipc.protocolType); Endpoint ipc2 = FindEndpoint(record, Ipc2, false, 1, 2); NUnit.Framework.Assert.IsNotNull(ipc2); Endpoint web = FindEndpoint(record, HttpApi, true, 1, 1); NUnit.Framework.Assert.AreEqual(1, web.addresses.Count); NUnit.Framework.Assert.AreEqual(1, web.addresses[0].Count); }
private void btnSave_Click(object sender, EventArgs e) { if (AllValidInputs()) { ServiceRecord serviceRecord = new ServiceRecord(); serviceRecord.vehicleID = int.Parse(cmbSelect.SelectedValue.ToString()); serviceRecord.dateOfService = dtServiceDate.Value; serviceRecord.mileage = Convert.ToInt32(txtMilage.Text); int serviceRecordID = serviceController.AddServiceRecord(serviceRecord); if (serviceRecordID != 0) { foreach (var item in chlistType.CheckedItems.OfType <ServiceCategory>()) { int categoryID = item.serviceCategoryID; ServiceRecordType serviceType = new Model.ServiceRecordType(); serviceType.serviceRecordID = serviceRecordID; serviceType.serviceCategoryID = categoryID; serviceTypeControl.AddServiceRecordType(serviceType); } MessageBox.Show("You have succesfully created a service record"); this.Close(); } else { MessageBox.Show("There was an error while saving, please try again."); } } }
/// <summary>Find an endpoint in a record or fail,</summary> /// <param name="record">record</param> /// <param name="api">API</param> /// <param name="external">external?</param> /// <param name="addressElements">expected # of address elements?</param> /// <param name="addressTupleSize">expected size of a type</param> /// <returns>the endpoint.</returns> public static Endpoint FindEndpoint(ServiceRecord record, string api, bool external , int addressElements, int addressTupleSize) { Endpoint epr = external ? record.GetExternalEndpoint(api) : record.GetInternalEndpoint (api); if (epr != null) { NUnit.Framework.Assert.AreEqual("wrong # of addresses", addressElements, epr.addresses .Count); NUnit.Framework.Assert.AreEqual("wrong # of elements in an address tuple", addressTupleSize , epr.addresses[0].Count); return(epr); } IList <Endpoint> endpoints = external ? record.external : record.@internal; StringBuilder builder = new StringBuilder(); foreach (Endpoint endpoint in endpoints) { builder.Append("\"").Append(endpoint).Append("\" "); } NUnit.Framework.Assert.Fail("Did not find " + api + " in endpoints " + builder); // never reached; here to keep the compiler happy return(null); }
public virtual void TestAsyncPurgeEntry() { string path = "/users/example/hbase/hbase1/"; ServiceRecord written = BuildExampleServiceEntry(PersistencePolicies.ApplicationAttempt ); written.Set(YarnRegistryAttributes.YarnId, "testAsyncPurgeEntry_attempt_001"); operations.Mknode(RegistryPathUtils.ParentOf(path), true); operations.Bind(path, written, 0); ZKPathDumper dump = registry.DumpPath(false); Log.Info("Initial state {}", dump); DeleteCompletionCallback deletions = new DeleteCompletionCallback(); int opcount = Purge("/", written.Get(YarnRegistryAttributes.YarnId, string.Empty) , PersistencePolicies.Container, RegistryAdminService.PurgePolicy.PurgeAll, deletions ); AssertPathExists(path); dump = registry.DumpPath(false); NUnit.Framework.Assert.AreEqual("wrong no of delete operations in " + dump, 0, deletions .GetEventCount()); NUnit.Framework.Assert.AreEqual("wrong no of delete operations in " + dump, 0, opcount ); // now app attempt deletions = new DeleteCompletionCallback(); opcount = Purge("/", written.Get(YarnRegistryAttributes.YarnId, string.Empty), PersistencePolicies .ApplicationAttempt, RegistryAdminService.PurgePolicy.PurgeAll, deletions); dump = registry.DumpPath(false); Log.Info("Final state {}", dump); AssertPathNotFound(path); NUnit.Framework.Assert.AreEqual("wrong no of delete operations in " + dump, 1, deletions .GetEventCount()); NUnit.Framework.Assert.AreEqual("wrong no of delete operations in " + dump, 1, opcount ); }
public async Task <IActionResult> Edit(int id, [Bind("Type,Version,Path,Name,Id")] ServiceRecord serviceRecord) { if (id != serviceRecord.Id) { return(NotFound()); } if (ModelState.IsValid) { try { ConfigContext.Update(serviceRecord); await ConfigContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ServiceRecordExists(serviceRecord.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(serviceRecord)); }
public HistoryViewModel(ServiceRecord serviceRecord, GameHistory <T> gameHistory, GameMode gameMode, int page) : base(serviceRecord) { GameHistory = gameHistory; GameMode = gameMode; Page = page; }
public ActionResult Details(string gamertag, ServiceRecord serviceRecord, int?id, string slug) { if (id == null) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "Csr"), FlashMessage.FlashMessageType.Failure, "Playlist Error", "There was no specified playlist id, the url must have been malformed.")); } var skillRank = serviceRecord.SkillRanks.FirstOrDefault(r => r.PlaylistId == id); if (skillRank == null) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "Csr"), FlashMessage.FlashMessageType.Failure, "Playlist Error", "The specified playlist doesn't exist. It either was purged by 343, or never existed.")); } var playlist = MetadataHelpers.GetPlaylist(skillRank.PlaylistId); if (playlist == null) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Index", "Csr"), FlashMessage.FlashMessageType.Failure, "Playlist Error", "The specified playlist doesn't exist. It either was purged by 343, or never existed. Try waiting for 343 to update their systems and try again in 30 minutes.")); } if (skillRank.PlaylistName.ToSlug() != slug) { return(FlashMessage.RedirectAndFlash(Response, RedirectToAction("Details", "Csr", new { id, slug = skillRank.PlaylistName.ToSlug() }), FlashMessage.FlashMessageType.Warning, "Haha!", "Nice try changing the slug m8.")); } return (View(new CsrDetailViewModel(serviceRecord, GlobalStorage.H4Manager.GetPlaylistOrientation(skillRank.PlaylistId), serviceRecord.SkillRanks.FirstOrDefault(r => r.PlaylistId == id), MetadataHelpers.GetPlaylist(skillRank.PlaylistId)))); }
public int?AddServiceRecord([FromBody] ServiceRecord newServiceRecord) { var serviceRecordId = new int?(); try { serviceRecordId = serviceRecordList.InsertServiceRecord(newServiceRecord); if (serviceRecordId == null) { throw new Exception("Enable add service record!"); } } catch (Exception e) { serviceRecordId = null; var error = e.Message; if (e.GetType() != typeof(HttpResponseException)) { throw new HttpResponseException( Request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message)); } else { throw e; } } return(serviceRecordId); }
public void UInt64() { var listAllocs = new List <IntPtr>(); // var elemData = new Structs.SDP_Data_Element( StackConsts.SDP_Data_Element_Type.UnsignedInteger8Bytes, 8); elemData.FakeAtUnionPosition7 = 0xF5; elemData.FakeAtUnionPosition6 = 0x23; elemData.FakeAtUnionPosition5 = 0x45; elemData.FakeAtUnionPosition4 = 0x67; elemData.FakeAtUnionPosition3 = 0x4a; elemData.FakeAtUnionPosition2 = 0x5b; elemData.FakeAtUnionPosition1 = 0x6c; elemData.FakeAtUnionPosition = 0x7d; ServiceRecord r = DoTestParseOneAttribute(listAllocs, elemData, 0x1234); // var attr = r[0]; Assert.AreEqual(unchecked ((ServiceAttributeId)0x1234), attr.Id, "AttrId"); Assert.AreEqual(0x1234, attr.IdAsOrdinalNumber, "IdAsOrdinalNumber"); Assert.AreEqual(ElementType.UInt64, attr.Value.ElementType, "ET"); Assert.AreEqual(ElementTypeDescriptor.UnsignedInteger, attr.Value.ElementTypeDescriptor, "ETD"); Assert.AreEqual(0xF52345674a5b6c7d, attr.Value.Value, "v"); // Free(listAllocs); }
public HistoryViewModel(ServiceRecord serviceRecord, VariantClass variantClass, uint page, GameHistory gameHistory) : base(serviceRecord) { VariantClass = variantClass; Page = page; GameHistory = gameHistory; }
public void L2CapGetChannelByte_0x000F() { ServiceRecord rcd = ServiceRecord.CreateServiceRecordFromBytes(Data_CompleteThirdPartyRecords.XpB_1of2_1115); int value = ServiceRecordHelper.GetL2CapChannelNumber(rcd); Assert.AreEqual(0x0F, value); }