/// <summary> /// Adds a new person to phone book. /// </summary> /// <param name="recordToAdd">Person informations to add</param> public void AddPerson(PhoneBookRecord recordToAdd) { if (recordToAdd == null) { throw new ArgumentNullException("recordToAdd"); } _records[recordToAdd.Name] = recordToAdd; Console.WriteLine("A new person is added: " + recordToAdd.Name + " (" + recordToAdd.Phone + ")"); }
public async Task AddPhoneBook_Should_AddNewRecord() { var newRecord = new PhoneBookRecord("new record", "with phonenumber"); _phonebookRepository.Add(newRecord); await _unitOfWork.CommitAsync(); var addedRecord = await _phonebookRepository.GetAsync(newRecord.Id); Assert.Equal("with phonenumber", addedRecord.PhoneNumber); }
static void Main() { var serverPublicKey = new X509Certificate2(@"C:\Users\node\Desktop\scs\SSLSamples\CertificateFiles\Server\publicKey.cer"); //Create a client to connecto to phone book service on local server and 10048 TCP port. //var client = ScsServiceClientBuilder.CreateClient<IPhoneBookService>(new ScsTcpEndPoint("127.0.0.1", 10048)); var client = SslScsServiceClientBuilder.CreateSslClient <IPhoneBookService>(new ScsTcpEndPoint("127.0.0.1", 10048) , serverPublicKey , "127.0.0.1" , SslScsAuthMode.ServerAuth , null, null); Console.WriteLine("Press enter to connect to phone book service..."); Console.ReadLine(); //Connect to the server client.Connect(); var person1 = new PhoneBookRecord { Name = "Halil ibrahim", Phone = "5881112233" }; var person2 = new PhoneBookRecord { Name = "John Nash", Phone = "58833322211" }; //Add some persons client.ServiceProxy.AddPerson(person1); client.ServiceProxy.AddPerson(person2); //Search for a person var person = client.ServiceProxy.FindPerson("Halil"); if (person != null) { Console.WriteLine("Person is found:"); Console.WriteLine(person); } else { Console.WriteLine("Can not find person!"); } Console.WriteLine(); Console.WriteLine("Press enter to disconnect from phone book service..."); Console.ReadLine(); //Disconnect from server client.Disconnect(); }
public async Task FindPhoneBookByTag_Should_FindRecord() { var newRecord = new PhoneBookRecord("new record", "with tag"); newRecord.UpdateTags(new List <int> { 1 }); _phonebookRepository.Add(newRecord); await _unitOfWork.CommitAsync(); var addedRecord = await _phonebookRepository.GetAsync(newRecord.Id); Assert.Equal(1, addedRecord.PhoneBookTags.Count); Assert.Equal("with tag", addedRecord.PhoneNumber); }
static void Main() { //Create a client to connecto to phone book service on local server and 10048 TCP port. var client = ScsServiceClientBuilder.CreateClient <IPhoneBookService>( new ScsTcpEndPoint("127.0.0.1", 10048)); Console.WriteLine("Press enter to connect to phone book service..."); Console.ReadLine(); //Connect to the server client.Connect(); var person1 = new PhoneBookRecord { Name = "Halil ibrahim", Phone = "5881112233" }; var person2 = new PhoneBookRecord { Name = "John Nash", Phone = "58833322211" }; //Add some persons client.ServiceProxy.AddPerson(person1); client.ServiceProxy.AddPerson(person2); //Search for a person var person = client.ServiceProxy.FindPerson("Halil"); if (person != null) { Console.WriteLine("Person is found:"); Console.WriteLine(person); } else { Console.WriteLine("Can not find person!"); } Console.WriteLine(); Console.WriteLine("Press enter to disconnect from phone book service..."); Console.ReadLine(); //Disconnect from server client.Disconnect(); }