示例#1
0
        public void SetUp()
        {
            request = Request.Get("foo/bar");

            replicas = new[]
            {
                replica1 = new Uri("http://replica-1"),
                replica2 = new Uri("http://replica-2"),
                replica3 = new Uri("http://replica-3"),
                replica4 = new Uri("http://replica-4"),
                replica5 = new Uri("http://replica-5")
            };

            modifiers = new List <IReplicaWeightModifier>
            {
                Substitute.For <IReplicaWeightModifier>(),
                Substitute.For <IReplicaWeightModifier>(),
                Substitute.For <IReplicaWeightModifier>()
            };

            storageProvider = Substitute.For <IReplicaStorageProvider>();

            weightCalculator = Substitute.For <IReplicaWeightCalculator>();
            // ReSharper disable AssignNullToNotNullAttribute
            weightCalculator.GetWeight(null, null, null, null).ReturnsForAnyArgs(1.0);
            // ReSharper restore AssignNullToNotNullAttribute

            ordering = new WeighedReplicaOrdering(modifiers, weightCalculator);
        }
        public void TestSetup()
        {
            request    = Request.Get("foo/bar");
            parameters = RequestParameters.Empty;

            replicas = new[]
            {
                replica1 = new Uri("http://replica-1"),
                replica2 = new Uri("http://replica-2"),
                replica3 = new Uri("http://replica-3"),
                replica4 = new Uri("http://replica-4"),
                replica5 = new Uri("http://replica-5")
            };

            modifiers = new List <IReplicaWeightModifier>
            {
                Substitute.For <IReplicaWeightModifier>(),
                Substitute.For <IReplicaWeightModifier>(),
                Substitute.For <IReplicaWeightModifier>()
            };

            storageProvider = Substitute.For <IReplicaStorageProvider>();

            weightCalculator = Substitute.For <IReplicaWeightCalculator>();
            weightCalculator.GetWeight(null, null, null, null, null).ReturnsForAnyArgs(1.0);

            ordering = new WeighedReplicaOrdering(modifiers, weightCalculator);
        }
示例#3
0
 private void SetupWeight(Uri replica, double weight)
 {
     weightCalculator.GetWeight(replica, Arg.Any <IList <Uri> >(), storageProvider, request).Returns(weight);
 }