Esempio n. 1
0
        public void TestSimpleSmsCapability()
        {
            ISmsc smsc;
            ISmsProvider provider;
            Dictionary<string, string> settings;
            ObjectState mockProvider;
            ObjectState mockSettings;

            // This call, other than instantiating a Smsc object,
            // loads all registered Sms Providers
            smsc = SmsFactory.GetSmsc();

            // Lookup the Aspsms provider
            provider = smsc.SmsProviders.Lookup("Aspsms");

            // Verify the Aspsms provider is correctly loaded
            Assert.IsNotNull(provider, "Aspsms provider not found");
            Assert.AreEqual("aspsms", provider.Name.ToLower(), "Invalid sms provider name");
            Assert.IsTrue(provider.Capabilities.SimpleSms, "Aspsms provider not enabled to send simple SMS");
            Assert.IsTrue(provider.Capabilities.TestMode, "Aspsms provider not implementing a test mode");

            // Read the internal provider state in order to get access
            // to private members and display some information
            mockProvider = new ObjectState(provider);
            mockSettings = new ObjectState(provider.Configuration);

            settings = (Dictionary<string, string>) mockSettings.GetField("_settings");

            Console.Out.WriteLine("Name:     " + provider.Name);
            Console.Out.WriteLine("Assembly: " + mockProvider.GetField("_assemblyName"));
            Console.Out.WriteLine("Class:    " + mockProvider.GetField("_className"));
            Console.Out.WriteLine("UserKey:  " + settings["userKey"]);
            Console.Out.WriteLine("Password: "******"password"]);
        }