Пример #1
0
            public void SetUp()
            {
                _webServiceDeserializer = new Mock <INestWebServiceDeserializer>();
                _webRequest             = new Mock <IWebRequest>();
                _webResponse            = new Mock <IWebResponse>();
                _requestProvider        = new Mock <IWebRequestProvider>();
                _analytics           = new Mock <IAnalyticsService>();
                _sessionProvider     = new Mock <ISessionProvider>();
                _webHeaderCollection = new Mock <IWebHeaderCollection>();
                _timestampProvider   = new Mock <ITimestampProvider>();

                _sessionProvider.SetupGet(s => s.TransportUrl).Returns(BaseUrl);
                _requestProvider.Setup(r => r.CreateRequest(It.IsAny <Uri>())).Returns(_webRequest.Object);
                _webRequest.Setup(w => w.SetRequestStringAsync(It.IsAny <string>())).Returns(Task.Delay(0));
                _webRequest.SetupGet(w => w.Headers).Returns(_webHeaderCollection.Object);
                _webHeaderCollection.SetupSet(w => w[It.IsAny <string>()] = It.IsAny <string>());
                _webRequest.Setup(w => w.GetResponseAsync()).Returns(Task.FromResult(_webResponse.Object));
                _webResponse.Setup(w => w.GetResponseStream()).Returns(new MemoryStream());
                _webResponse.Setup(w => w.GetResponseStringAsync()).Returns(Task.FromResult(""));
                _webServiceDeserializer.Setup(d => d.ParseStructureFromGetStructureStatusResult(It.IsAny <string>(), It.IsAny <string>())).Returns(new Structure(""));
                _webServiceDeserializer.Setup(d => d.ParseWebServiceErrorAsync(It.IsAny <Exception>())).Returns(Task.FromResult(WebServiceError.Unknown));
                _timestampProvider.Setup(t => t.GetTimestamp()).Returns(1234567890d);

                ServiceContainer.RegisterService <INestWebServiceDeserializer>(_webServiceDeserializer.Object);
                ServiceContainer.RegisterService <IWebRequestProvider>(_requestProvider.Object);
                ServiceContainer.RegisterService <IAnalyticsService>(_analytics.Object);
                ServiceContainer.RegisterService <ISessionProvider>(_sessionProvider.Object);
                ServiceContainer.RegisterService <ITimestampProvider>(_timestampProvider.Object);

                _webService = new NestWebService();
            }
Пример #2
0
        public void SetUp()
        {
            ServiceContainer.Clear();
            ServiceContainer.RegisterService <ISettingsProvider>(new SettingsProvider());
            ServiceContainer.RegisterService <IWebRequestProvider>(new WebRequestProvider());
            ServiceContainer.RegisterService <IAnalyticsService>(new AnalyticsService());
            ServiceContainer.RegisterService <ISessionProvider>(new SessionProvider());

            _webService = new NestWebService();
        }
Пример #3
0
 public void TearDown()
 {
     ServiceContainer.Clear();
     _webService = null;
 }