Ejemplo n.º 1
0
        public void SetupFakeServer()
        {
            loginSettingsRepository = Resolve<LoginSettingsRepository>();

            server = new HttpServer();
            server.RequestReceived += (s, e) =>
            {
                using (var writer = new StreamWriter(e.Response.OutputStream))
                {
                    var path = e.Request.RawUrl;
                    var response = responses.First(r => r.Path == path);
                    
                    Console.WriteLine("Received request {0}", path);

                    if (response == null)
                    {
                        if (path != FaviconPath)
                            unhandledResponses.Add(path);
                    }
                    else
                    {
                        if (response.IsSatisfied(e))
                        {
                            responses.Remove(response);
                            Console.WriteLine(response.ResponseText);
                            writer.Write(response.ResponseText);
                        }                        
                    }                    
                }
            };

            //Use port zero - this way the OS will assign a free port and we can avoid collisions
            server.EndPoint = new IPEndPoint(IPAddress.Loopback, 0);
            server.Start();

            Console.WriteLine("Starting server at {0}", server.EndPoint);

            //Update login settings so that they match the server URL
            UpdateLoginSettings(server.EndPoint.ToString());
        }
Ejemplo n.º 2
0
 public LoginClient(LoginSettingsRepository repository)
 {
     this.repository = repository;
 }
 public CommandEnvelopeDownloadClient(LoginSettingsRepository loginSettingsRepository)
 {
     this.loginSettingsRepository = loginSettingsRepository;
 }
 public void Setup()
 {
     repository = new LoginSettingsRepository(Database);   
 }