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); }
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>(); } }
public CalculatorController(ICalculatorLogic logic, ICalculatorValidator validator) { _logic = logic; _validator = validator; }
public CalculatorUI(ICalculatorLogic calculator) { InitializeComponent(); _calculator = calculator; }
public AdvanceCalculatorLogic(ICalculatorLogic calculatorLogic) { _calculatorLogic = calculatorLogic; }
public ConfigForTests() { calculator = new CalculatorLogic(); }