Exemple #1
0
        public override void Run()
        {
            Msg("Example");

            try
            {
                var module = new Example();

                module.Str = "CODERUN_Example";
                module.Int = 99;

                var idxStr  = module.Add(module.Str);
                var idxInt  = module.Add(module.Int.ToString());
                var idxItem = module.Add("Item");
                var str     = module.Remove(idxItem);
            }
            catch
            {
            }

            Msg("HExample");

            try
            {
                var host = new HExample();
            }
            catch
            {
            }

            Msg("EExample");

            try
            {
                var empty = new EExample();
            }
            catch
            {
            }

            Msg("MExample");

            try
            {
                var mock = new MExample
                {
                    Run     = IMock.RunType.SUCCESS,
                    Arrange = IMock.RunType.SUCCESS,
                    Test    = IMock.RunType.SUCCESS,
                    Assert  = IMock.RunType.SUCCESS
                };
            }
            catch
            {
            }
        }
Exemple #2
0
    public static void Main()
    {
        // This generates a compile-time warning.
        int i = Example.Add(2, 2);

        Console.WriteLine(i);
    }
Exemple #3
0
        public void AddTest(int x, int y, int expected)
        {
            // arrange, instantiate object
            Example obj = new Example();

            // act, call the method
            int actual = obj.Add(x, y);

            // assert, verify correctness
            Assert.AreEqual(expected, actual);
        }
        public void Example()
        {
            var module = new Example();

            module.Str = "APP-Example";
            module.Int = 99;

            var idxStr = module.Add(module.Str);

            Assert.Equal(idxStr, module.Find(module.Str));

            var idxInt = module.Add(module.Int.ToString());

            Assert.Equal(idxInt, module.Find(module.Int.ToString()));

            var idxItem = module.Add("Item");

            Assert.Equal(idxItem, module.Find("Item"));

            var str = module.Remove(idxItem);

            Assert.False(idxItem == module.Find("Item"));
        }
    static void Main(string[] args)
    {
        int[]   ints = new int[] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150 };
        Example e    = new Example();

        e.AddRange(ints);
        e.Start();
        int k = 0;

        while (true)
        {
            int input = int.Parse(Console.ReadLine());
            e.Add(input);
        }
    }
Exemple #6
0
        static void Main(string[] args)
        {
            // Example

            try
            {
                var example = new Example();

                example.Str = "APP-Example";
                example.Int = 99;
                example.Add(example.Str);
                example.Add(example.Int.ToString());

                foreach (var item in example.Repository)
                {
                    Console.WriteLine(item);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            // HExample

            try
            {
                var host = new HExample();

                var s = host.Str();
                var i = host.Int();

                host.Add();
                host.Find();
                host.Remove();

                host.Try = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            // EExample

            try
            {
                var empty = new EExample();

                empty.Add("Item");
                empty.Remove(empty.Find("Item"));
            }
            catch (ExampleNotImplentedException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            // MEXample

            try
            {
                var mockOK = new MExample
                {
                    Run     = RunType.SUCCESS,
                    Arrange = true,
                    Test    = true,
                    Assert  = true
                };

                var mockERROR = new MExample
                {
                    Run = RunType.EXCEPTION,
                    ExceptionExpected = new ExampleAlreadyExistsException("Mock ERROR"),
                    Throws            = true,
                    Arrange           = true,
                    Test   = true,
                    Assert = true
                };
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadLine();
        }
Exemple #7
0
 public void Can_add(int x, int y, int expected)
 {
     Assert.That(Example.Add(x, y), Is.EqualTo(expected));
 }
Exemple #8
0
 public int Find()
 {
     Example.Add("Added");
     return(Example.Find("Added"));
 }