-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMockWebContext.cs
50 lines (43 loc) · 1.61 KB
/
MockWebContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Security.Principal;
using Inversion.Data;
using Inversion.Process;
namespace Inversion.Web {
/// <summary>
/// Implements a mock web context suitable for testing purposes.
/// Ensures no exposure to http context, and provides mocks
/// of IWebRequest and IWebResponse.
/// </summary>
public class MockWebContext: ProcessContext, IWebContext {
/// <summary>
/// Instantiates a new process contrext for inversion.
/// </summary>
/// <remarks>You can think of this type here as "being Inversion". This is the thing.</remarks>
/// <param name="services">The service container the context will use.</param>
/// <param name="resources">The resources available to the context.</param>
public MockWebContext(IServiceContainer services, IResourceAdapter resources) : base(services, resources) {
this.Request = new MockWebRequest(String.Empty);
this.Response = new MockWebResponse();
}
/// <summary>
/// Provides access to the running web application
/// to which this context belongs.
/// </summary>
public IWebApplication Application {
get { throw new NotImplementedException("The web application has not been mocked."); }
}
/// <summary>
/// Gives access to the web response of this context.
/// </summary>
public IWebResponse Response { get; set; }
/// <summary>
/// Gives access to the web request for this context.
/// </summary>
public IWebRequest Request { get; set; }
/// <summary>
/// Gives access to the `IPrinciple` user object that represents
/// the current user for this context.
/// </summary>
public IPrincipal User { get; set; }
}
}