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)));
            });
        }
예제 #2
0
        public ICouplingsAndBiases <int, BiasValueType, CouplingValueType> GetCouplingsAndBiases(IEnumerable <InputType> input)
        {
            var inputLength = input.Count();
            var response    = new CouplingsAndBiases <int, BiasValueType, CouplingValueType>();

            for (var i = 0; i < input.Count(); i++)
            {
                var currentElement = input.ElementAt(i);
                var bias           = _biasProvider.GetBias(currentElement);
                response.AddBias(i, bias);
                for (var j = i + 1; j < input.Count(); j++)
                {
                    var nextElement = input.ElementAt(j);
                    var coupling    = _couplingsProvider.GetCoupling(currentElement, nextElement);
                    response.AddCoupling(i, j, coupling);
                }
            }
            return(response);
        }