Beispiel #1
0
        static void Main(string[] args)
        {
            var userName = Environment.GetEnvironmentVariable("FritzBoxUserName");
            var password = Environment.GetEnvironmentVariable("FritzBoxPassword");

            var fritzBox = new FritzClient()
            {
                UserName = userName,
                Password = password
            };

            // Write csv file to the application folder
            fritzBox.WritePhonebookCsv(name: "Test Phonebook", folder: AppDomain.CurrentDomain.BaseDirectory, separator: ";");
        }
Beispiel #2
0
        public void TestPhonebook()
        {
            // Create a name for the test phonebook.
            string testPhonebookName = $"Test Phonebook {Utility.GetTimestamp()}";



            // Create the test phonebook on the device.
            _fb.AddPhonebook(name: testPhonebookName);
            Assert.IsTrue(_fb.PhonebookExists(testPhonebookName));



            // Get the phonebook id.
            bool success = _fb.GetPhonebookId(name: testPhonebookName, out ushort testPhonebookId);

            Assert.IsTrue(success);
            Assert.IsTrue(testPhonebookId > 0);



            // Add an inital phonebook entry.
            string testPhonebookEntryUniqueId = _fb.AddPhonebookEntry(phonebookId: testPhonebookId,
                                                                      name: "Siciliani Salvatore",
                                                                      telephonyNumbers: new List <contactTelephonyNumber>()
            {
                new contactTelephonyNumber()
                {
                    Value = "+1 205 111 0010", type = NumberType.Home.ToString("G")
                },
                new contactTelephonyNumber()
                {
                    Value = "+1 205 111 0010", type = NumberType.Mobile.ToString("G")
                },
                new contactTelephonyNumber()
                {
                    Value = "+1 205 111 0010", type = NumberType.Work.ToString("G")
                },
                new contactTelephonyNumber()
                {
                    Value = "+1 205 111 0010", type = NumberType.Fax_Work.ToString("G")
                },
            },
                                                                      category: 0,
                                                                      email: "*****@*****.**");

            Assert.IsNotNull(testPhonebookEntryUniqueId);
            Assert.IsTrue(testPhonebookEntryUniqueId.Length > 0);



            // Add a second phonebook entry.
            testPhonebookEntryUniqueId = _fb.AddPhonebookEntry(phonebookId: testPhonebookId,
                                                               name: "Guzman Miguela",
                                                               telephonyNumbers: new List <contactTelephonyNumber>()
            {
                new contactTelephonyNumber()
                {
                    Value = "+1 205 222 0011", type = NumberType.Home.ToString("G")
                },
                new contactTelephonyNumber()
                {
                    Value = "+1 205 222 0012", type = NumberType.Mobile.ToString("G")
                },
                new contactTelephonyNumber()
                {
                    Value = "+1 205 222 0013", type = NumberType.Work.ToString("G")
                },
                new contactTelephonyNumber()
                {
                    Value = "+1 205 222 0014", type = NumberType.Fax_Work.ToString("G")
                },
            },
                                                               category: 0,
                                                               email: "*****@*****.**");
            Assert.IsNotNull(testPhonebookEntryUniqueId);
            Assert.IsTrue(testPhonebookEntryUniqueId.Length > 0);



            // Get the phonebook entry by uid.
            contact result = _fb.GetPhonebookEntryUID(phonebookId: testPhonebookId, entryUniqueId: testPhonebookEntryUniqueId);

            Assert.IsNotNull(result);

            string name = result.person.realName;

            Assert.IsTrue(name.Length > 0);

            string email = result.services.email?.Value ?? string.Empty;

            Assert.AreEqual(expected: "*****@*****.**", actual: email);



            // Update phonebook entry.
            _fb.UpdatePhonebookEntry(phonebookId: testPhonebookId,
                                     uniqueId: testPhonebookEntryUniqueId,
                                     name: "Guzman E. Miguela",
                                     telephonyNumbers: new List <contactTelephonyNumber>()
            {
                new contactTelephonyNumber()
                {
                    Value = "+1 205 222 0021", type = NumberType.Home.ToString("G")
                },
                new contactTelephonyNumber()
                {
                    Value = "+1 205 222 0022", type = NumberType.Mobile.ToString("G")
                },
                new contactTelephonyNumber()
                {
                    Value = "+1 205 222 0023", type = NumberType.Work.ToString("G")
                },
                new contactTelephonyNumber()
                {
                    Value = "+1 205 222 0024", type = NumberType.Fax_Work.ToString("G")
                },
            },
                                     category: 0,
                                     email: "*****@*****.**"
                                     );



            // Delete phonebook entry.
            _fb.DeletePhonebookEntryUID(phonebookId: testPhonebookId, uniqueId: testPhonebookEntryUniqueId);



            // Write the phonebook to console.
            var phonebook = _fb.GetPhonebook(name: testPhonebookName);

            Assert.IsNotNull(phonebook);
            Assert.IsTrue(phonebook.contact.Count() > 0);

            foreach (var contact in phonebook.contact)
            {
                email = (contact.telephony[0].services != null && contact.telephony[0].services.Count() > 0)
                    ? contact.telephony[0].services[0].Value
                    : string.Empty;

                Console.WriteLine($"{contact.uniqueid}\t{contact.person[0].realName}\t{contact.telephony[0].number[0].Value}\t{email}");
            }



            // Backup the test phonebook as csv file.
            // Note: In VS, the deployment directories created for running tests are deleted after each test run.
            // If the test fails, these directories are retained for easier analysis. You can override this behavior
            // with the DeleteDeploymentDirectoryAfterTestRunIsComplete setting.See http://msdn.microsoft.com/en-us/library/jj635153.aspx
            _fb.WritePhonebookCsv(name: testPhonebookName, folder: TestContext.TestDeploymentDir);



            // Backup the test phonebook as xml file.
            _fb.WritePhonebookXml(name: testPhonebookName, folder: TestContext.TestDeploymentDir);



            // Remove the test phonebook from the device.
            _fb.DeletePhonebook(name: testPhonebookName);
        }
Beispiel #3
0
 public void TestWritePhonebookCsv()
 {
     _fb.WritePhonebookCsv(name: "Test Phonebook", folder: TestContext.TestDeploymentDir);
 }