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

            Assert.AreEqual(hwAPI.getGreeting(), "Hello World Console");
        }
Exemplo n.º 2
0
        public void WriteMessage_NotImplemented()
        {
            HelloWorldFactory fac   = new HelloWorldFactory();
            IHelloWorld       hwAPI = fac.CreateInstance(HelloWorldTypes.Console, "test");

            Assert.ThrowsException <NotImplementedException>(() => hwAPI.writeMessage("test"));
        }
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 GetHelloWorldTest()
        {
            HelloWorldFactory factory          = new HelloWorldFactory(new MockSettings());
            IParadigm         helloWorldGetter = factory.CreateHelloWorldGetter("plaintext");

            string result = helloWorldGetter.GetHelloWorld();

            Assert.AreEqual(result, "Hello, world!");
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            HelloWorldFactory factory = new HelloWorldFactory();
            // create hellowWorld obj
            IHelloWorld helloWorldObj = factory.CreateHelloWorldObj();

            // call any of the implemented function to output "Hello World" to either console or database or other places
            helloWorldObj.PrintHelloWorldToConsole("Hello World");
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var helloWorld = HelloWorldFactory.Build(OutputType);

            helloWorld.Write(HelloWorld);

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
Exemplo n.º 7
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.º 8
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.º 9
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.º 10
0
        public void CreateFactoryThatWrapsHelloWorldMessage()
        {
            var factory = new HelloWorldFactory();
            var hw      = factory.Create();

            Assert.IsType <HelloWorld.Core.HelloWorld>(hw);

            var expected = "Hello, World";

            Assert.Equal(expected, hw.Message);
        }
Exemplo n.º 11
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();
        }
        public void ReturnsHelloWorld()
        {
            // Arrange
            var target = new HelloWorldFactory();

            // Act
            var result = target.Create();

            // Assert
            Assert.IsType <DefaultHelloWorld>(result);
        }
Exemplo n.º 13
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.º 14
0
        public ActionResult Index()
        {
            var factory = new HelloWorldFactory();
            var helloWorldPlaintextParadigm = factory.CreateHelloWorldGetter("plaintext");
            var homeViewModel = new HomeViewModel
            {
                helloWorldMessage = helloWorldPlaintextParadigm.GetHelloWorld()
            };

            return(View(homeViewModel));
        }
Exemplo n.º 15
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.º 16
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.º 17
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.º 18
0
 public void Startup()
 {
     factory = new HelloWorldFactory(new MockSettings());
 }
    public void ValidateFactoryType(string outputCases)
    {
        var helloWorld = HelloWorldFactory.Build(outputCases);

        Assert.IsInstanceOfType(helloWorld, typeof(ConsoleHelloWorld));
    }
 public void ValidateNotImplimented(string outputCases)
 {
     var helloWorld = HelloWorldFactory.Build(outputCases);
 }
Exemplo n.º 21
0
 public HelloWorldDomainTest()
 {
     factory = container.Resolve <HelloWorldFactory>();
 }
Exemplo n.º 22
0
        public void CreateMobileType()
        {
            HelloWorldFactory fac = new HelloWorldFactory();

            Assert.ThrowsException <ApplicationException>(() => fac.CreateInstance(HelloWorldTypes.Mobile, "test"));
        }
Exemplo n.º 23
0
        public void SubstituteFor_CreateHelloWorld()
        {
            HelloWorldFactory factory = Substitute.For <HelloWorldFactory>();

            Assert.IsInstanceOf(typeof(ConsoleApp.HelloWorld), factory.CreateHelloWorldObj());
        }