public void SetUp()
        {
            this.restConfigurations = new List <IRestConfiguration>();
            this.mockWrapperFactory = A.Fake <IWrapperFactory>();
            this.mockNetworkFactory = A.Fake <INetworkFactory>();

            this.configuration1 = A.Fake <IRestConfiguration>();
            A.CallTo(() => this.configuration1.BaseUrl).Returns("url1");
            A.CallTo(() => this.configuration1.UserName).Returns("user1");
            A.CallTo(() => this.configuration1.Password).Returns("password1");
            A.CallTo(() => this.configuration1.IsServerOn).Returns(true);
            A.CallTo(() => this.configuration1.Name).Returns("conf1");
            restConfigurations.Add(this.configuration1);


            this.configuration2 = A.Fake <IRestConfiguration>();
            A.CallTo(() => this.configuration2.BaseUrl).Returns("url2");
            A.CallTo(() => this.configuration2.UserName).Returns("user2");
            A.CallTo(() => this.configuration2.Password).Returns("password2");
            A.CallTo(() => this.configuration2.IsServerOn).Returns(true);
            A.CallTo(() => this.configuration2.Name).Returns("conf2");
            restConfigurations.Add(this.configuration2);

            this.mockHttpClientHandler = A.Fake <IHttpClient>();
            this.mockRestConsumer      = A.Fake <IRestConsumer>();

            A.CallTo(() => this.mockWrapperFactory.CreateHttpClientHandler(this.configuration1.UserName, this.configuration1.Password)).Returns(mockHttpClientHandler);
            A.CallTo(() => this.mockNetworkFactory.CreateRestConsumer(A <IUri> .Ignored, mockHttpClientHandler, mockWrapperFactory)).Returns(mockRestConsumer);

            this.testee = new RestFactory(this.restConfigurations, this.mockWrapperFactory, mockNetworkFactory);
        }
Ejemplo n.º 2
0
        public RestClientIDS(IApiConfiguration configuration, IIDSConfiguration idsConfiguration, IRestConfiguration restConfiguration)
            : base(configuration)
        {
            _idsConfiguration  = idsConfiguration;
            _restConfiguration = restConfiguration;

            SerializationSettings = new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                MissingMemberHandling = MissingMemberHandling.Ignore,
                DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
                DateFormatHandling    = DateFormatHandling.IsoDateFormat
            };

            DeserializationSettings = SerializationSettings;
        }
 private bool IsValid(IRestConfiguration configuration)
 {
     return(configuration.BaseUrl != string.Empty &&
            configuration.UserName != string.Empty &&
            configuration.Password != string.Empty);
 }
 private bool IsValid(IRestConfiguration configuration)
 {
     return configuration.BaseUrl != string.Empty
         && configuration.UserName != string.Empty
         && configuration.Password != string.Empty;
 }
        public void SetUp()
        {
            this.restConfigurations = new List<IRestConfiguration>();
            this.mockWrapperFactory = A.Fake<IWrapperFactory>();
            this.mockNetworkFactory = A.Fake<INetworkFactory>();

            this.configuration1 = A.Fake<IRestConfiguration>();
            A.CallTo(() => this.configuration1.BaseUrl).Returns("url1");
            A.CallTo(() => this.configuration1.UserName).Returns("user1");
            A.CallTo(() => this.configuration1.Password).Returns("password1");
            A.CallTo(() => this.configuration1.IsServerOn).Returns(true);
            A.CallTo(() => this.configuration1.Name).Returns("conf1");
            restConfigurations.Add(this.configuration1);

            this.configuration2 = A.Fake<IRestConfiguration>();
            A.CallTo(() => this.configuration2.BaseUrl).Returns("url2");
            A.CallTo(() => this.configuration2.UserName).Returns("user2");
            A.CallTo(() => this.configuration2.Password).Returns("password2");
            A.CallTo(() => this.configuration2.IsServerOn).Returns(true);
            A.CallTo(() => this.configuration2.Name).Returns("conf2");
            restConfigurations.Add(this.configuration2);

            this.mockHttpClientHandler = A.Fake<IHttpClient>();
            this.mockRestConsumer = A.Fake<IRestConsumer>();

            A.CallTo(() => this.mockWrapperFactory.CreateHttpClientHandler(this.configuration1.UserName, this.configuration1.Password)).Returns(mockHttpClientHandler);
            A.CallTo(() => this.mockNetworkFactory.CreateRestConsumer(A<IUri>.Ignored, mockHttpClientHandler, mockWrapperFactory)).Returns(mockRestConsumer);

            this.testee = new RestFactory(this.restConfigurations, this.mockWrapperFactory, mockNetworkFactory);
        }