Exemplo n.º 1
0
        public void WriteMessage_NotImplemented()
        {
            HelloWorldFactory fac   = new HelloWorldFactory();
            IHelloWorld       hwAPI = fac.CreateInstance(HelloWorldTypes.Console, "test");

            Assert.ThrowsException <NotImplementedException>(() => hwAPI.writeMessage("test"));
        }
Exemplo n.º 2
0
        public void CreateConsoleType()
        {
            HelloWorldFactory fac   = new HelloWorldFactory();
            IHelloWorld       hwAPI = fac.CreateInstance(HelloWorldTypes.Console, "test");

            Assert.AreEqual(hwAPI.getGreeting(), "Hello World Console");
        }
Exemplo n.º 3
0
        public void test_client_not_implemented()
        {
            var client           = HelloWorldClient.NEW_CLIENT;
            var connectionString = "DB Connection string";

            HelloWorldFactory.Init(connectionString);
            HelloWorldFactory.CreateInstance(client, connectionString);
        }
Exemplo n.º 4
0
        public void TestConsole()
        {
            var fac = new HelloWorldFactory();

            var hello    = fac.CreateInstance(HelloWorldConstants.HelloWorldTypes.Console, "database");
            var response = hello.getMessage();

            Assert.IsNotNull(response, "API returned null from API");
            Assert.IsTrue(response == HelloWorldConstants.ConsoleResponse, "Helloworld API did not return valid response for console");
        }
Exemplo n.º 5
0
        public void test_write_on_implemented_client()
        {
            var client           = HelloWorldClient.MOBILE;
            var connectionString = "DB Connection string";

            HelloWorldFactory.Init(connectionString);
            var hwInstance = HelloWorldFactory.CreateInstance(client, connectionString);

            hwInstance.setGreeting("Test");
        }
Exemplo n.º 6
0
        public void test_create_mobile_type()
        {
            var client           = HelloWorldClient.MOBILE;
            var connectionString = "DB Connection string";

            HelloWorldFactory.Init(connectionString);
            var hwInstance = HelloWorldFactory.CreateInstance(client, connectionString);

            Assert.AreEqual(hwInstance.getGreeting(), "Hello " + client.ToString());
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            var logDir = ConfigurationManager.AppSettings["LogTo"].ToString();

            HelloWorldFactory hwFac = new HelloWorldFactory();
            IHelloWorld       hwAPI = hwFac.CreateInstance(HelloWorldTypes.Console, logDir);

            Console.Write(hwAPI.getMessage());

            Console.ReadKey();
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            var writeLocation = ConfigurationManager.AppSettings["WriteToLocation"];

            HelloWorldFactory fac   = new HelloWorldFactory();
            IHelloWorld       hwAPI = fac.CreateInstance(HelloWorldTypes.Console, writeLocation);

            Console.Write(hwAPI.getGreeting());

            Console.ReadKey();
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            var connectionString = ConfigurationManager.AppSettings["connectionString"];

            HelloWorldFactory.Init(connectionString);
            var hwInstance = HelloWorldFactory.CreateInstance(HelloWorldClient.CONSOLE, connectionString);

            hwInstance.getGreeting();
            Console.WriteLine(string.Format("Greetings from console : {0}", hwInstance.getGreeting()));
            Console.WriteLine("Press Enter to exit...");
            Console.ReadLine();
        }
Exemplo n.º 10
0
        public void WriteMessage_NotImplemented()
        {
            HelloWorldFactory fac   = new HelloWorldFactory();
            IHelloWorld       hwAPI = fac.CreateInstance(HelloWorldTypes.Console, "test");

            try {
                hwAPI.writeMessage("test");
            }
            catch (NotImplementedException e)
            {
                Assert.IsTrue(e.Message == "The method or operation is not implemented.");
            }
        }
Exemplo n.º 11
0
        public void TestWebService()
        {
            var fac = new HelloWorldFactory();

            try
            {
                var hello = fac.CreateInstance(HelloWorldTypes.WebService, "database");
                Assert.Fail("WebService exception not thrown");
            }
            catch (Exception e)
            {
                Assert.IsTrue(e.Message == "Client 'WebService' cannot be created");
            }
        }
Exemplo n.º 12
0
        public void CreateMobileType()
        {
            HelloWorldFactory fac = new HelloWorldFactory();

            Assert.ThrowsException <ApplicationException>(() => fac.CreateInstance(HelloWorldTypes.Mobile, "test"));
        }