public void SetUp()
 {
     // This method is called for every [Test] in this class.
     // So let's recreate our CalculatorLogic here so that each
     // test has a fresh instance.
     calculatorLogic = new CalculatorLogic();
 }
    public void SetUp()
    {
        // Create the logger mock!
        loggerMock = new Mock <ILogger>();

        // Inject the logger into our CalculatorLogic!
        calculatorLogic = new CalculatorLogic(loggerMock.Object);
    }
예제 #3
0
        private void Compose()
        {
            var executableLocation = Assembly.GetEntryAssembly().Location;
            var path       = Path.Combine(Path.GetDirectoryName(executableLocation), "Plugins");
            var assemblies = Directory
                             .GetFiles(path, "*.dll", SearchOption.AllDirectories)
                             .Select(AssemblyLoadContext.Default.LoadFromAssemblyPath)
                             .ToList();
            var configuration = new ContainerConfiguration().WithAssemblies(assemblies);

            using (var container = configuration.CreateContainer())
            {
                //_calculatorLogic = container.GetExports<ICalculatorLogic>(); // 可以輸出為 IEnumerable<T>
                _calculatorLogic = container.GetExport <ICalculatorLogic>();
            }
        }
예제 #4
0
 public CalculatorController(ICalculatorLogic logic, ICalculatorValidator validator)
 {
     _logic     = logic;
     _validator = validator;
 }
예제 #5
0
 public CalculatorUI(ICalculatorLogic calculator)
 {
     InitializeComponent();
     _calculator = calculator;
 }
예제 #6
0
 public AdvanceCalculatorLogic(ICalculatorLogic calculatorLogic)
 {
     _calculatorLogic = calculatorLogic;
 }
예제 #7
0
 public ConfigForTests()
 {
     calculator = new CalculatorLogic();
 }