Example #1
0
        public void TestNinject()
        {
            // Arrange
            List <string>  mylist = new List <string>(new string[] { "121556550", "15589455452", "2254564555565552", "5554525455454554565" });
            StandardKernel kernel = new StandardKernel();

            // Load Modules
            // Assemblies of the current project (Assemblies in Unit Test).
            //kernel.Load(Assembly.GetExecutingAssembly());

            // Assemblies of the solution (Assemblies in all projects).
            kernel.Load(AppDomain.CurrentDomain.GetAssemblies());

            CalculatorContext calculatorContext = null;

            try
            {
                // Gets a instance of the specified service.
                SumStrategy      objCalculate  = kernel.Get <SumStrategy>();      //("Sum");
                MultipleStrategy objCalculate2 = kernel.Get <MultipleStrategy>(); // ("Multiple");


                // Act: Inject
                calculatorContext = new CalculatorContext(objCalculate, objCalculate2);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }


            // Assert
            Assert.AreEqual(calculatorContext.Sum(mylist), "5556780035721132119");
        }