public void When_Requesting_SimpleAPI_ToResolve_AllAppropriateActors_AreInvoked() { var facade = FakeContainer.GetFacade <int, int, int, int>(); var converter = FakeContainer.GetQubitsToGroupsConverter <int>(); var resolver = FakeContainer.GetResolvver <int, int, int, int>(); var api = new QubitsCalculationAPI <int, int, int, int>(facade, resolver, converter); var input = new[] { 1, 2, 3, 4 }; var couplingsAndBiases = new CouplingsAndBiases <int, int, int>(); couplingsAndBiases.AddBias(0, 0); couplingsAndBiases.AddCoupling(0, 0, 0); facade.GetCouplingsAndBiases(input).Returns(couplingsAndBiases); var resolveResponse = new List <IQubitsResolvingResponse>(); var sortedQubitsList = new List <short>(); resolveResponse.Add(new IsakovScriptResponse(1, sortedQubitsList, 1)); resolver.Resolve(input, couplingsAndBiases.Biases, couplingsAndBiases.Couplings).Returns(resolveResponse); api.Resolve(input); Received.InOrder(() => { facade.GetCouplingsAndBiases(input); resolver.Resolve(input, couplingsAndBiases.Biases, couplingsAndBiases.Couplings); converter.DivideInputIntoGroupsByQubits(input, Arg.Is <IEnumerable <IEnumerable <short> > >(arg => arg.Count() == 1 && arg.First().Equals(sortedQubitsList))); }); }
/// <summary> /// Imagine we have a Container (Castle, Zenject, whatever) that holds all of our instances based on their interface. /// For example and testing purposes, I simply create new objects here, but ALL the classes and APIs expect their dependencies to be injected as interfaces. /// </summary> /// <param name="root">Root user's object</param> /// <param name="configuration">Configuration reader</param> /// <returns>The Graph division API</returns> private IQubitsCalculationAPI <INode <decimal> > CreateGraphDivisionAPI(INode <decimal> root, IConfigurationProvider configuration) { var isakovProcessPath = configuration.GetValueByCurrentPlatform(ConfigurationKeys.ISAKOV_RESOLVER_PROCESS_CONFIG_KEY); var isakovWorkingDir = configuration.GetValue(ConfigurationKeys.ISAKOV_RESOLVER_WORKING_DIRECTORY_CONFIG_KEY); var processArgs = configuration.GetValue(ConfigurationKeys.ISAKOV_RESOLVER_PROCESS_ARGS_CONFIG_KEY); var api = new QubitsCalculationAPI <INode <decimal>, int, decimal, decimal>( new QuantumDataExtractionFacade <INode <decimal>, decimal, decimal>(new GraphTraversalCouplingProvider(new RecursiveNodeTraverser <decimal>(root)), new DefaultValueBiasProvider <INode <decimal>, decimal>()), new IsakovScriptQubitsResolver <INode <decimal> >(new ProcessService(), isakovWorkingDir, isakovProcessPath, processArgs, configuration.GetValue(ConfigurationKeys.ISAKOV_INPUT_FILE_NAME), new SimpleFileService()), new QubitsToGroupsConverter <INode <decimal> >()); return(api); }