|
90 | 90 | .ShouldMap(request => request
|
91 | 91 | .WithLocation("/My/Action/1")
|
92 | 92 | .WithMethod(HttpMethod.Post)
|
| 93 | + .WithAuthenticatedUser() |
| 94 | + .WithAntiForgeryToken() |
93 | 95 | .WithJsonBody(new
|
94 | 96 | {
|
95 | 97 | Integer = 1,
|
@@ -125,6 +127,31 @@ MyMvc
|
125 | 127 | Assert.AreEqual(1, m.Id);
|
126 | 128 | Assert.AreEqual("Some property value", m.SomeProperty);
|
127 | 129 | });
|
| 130 | + |
| 131 | +// instantiates controller with the registered services |
| 132 | +// and sets options for the current test |
| 133 | +// and sets session for the current test |
| 134 | +// and sets DbContext for the current test |
| 135 | +// and tests for added cache entry by the action |
| 136 | +// and tests model from view result |
| 137 | +MyMvc |
| 138 | + .Controller<MvcController>() |
| 139 | + .WithOptions(options => options |
| 140 | + .For<AppSettings>(settings => settings.Cache = true)) |
| 141 | + .WithSession(session => session |
| 142 | + .WithEntry("Session", "SessionValue")) |
| 143 | + .WithDbContext(db => db.WithEntities(entities => entities |
| 144 | + .AddRange(SampleDataProvider.GetModels()))) |
| 145 | + .Calling(c => c.SomeAction()) |
| 146 | + .ShouldHave() |
| 147 | + .MemoryCache(cache => cache |
| 148 | + .ContainingEntry(entry => entry |
| 149 | + .WithKey("CacheEntry") |
| 150 | + .WithSlidingExpiration(TimeSpan.FromMinutes(10)))) |
| 151 | + .AndAlso() |
| 152 | + .ShouldReturn() |
| 153 | + .View() |
| 154 | + .WithModelOfType<ResponseModel>(); |
128 | 155 |
|
129 | 156 | // tests whether the action is declared with filters
|
130 | 157 | MyMvc
|
@@ -167,7 +194,7 @@ Code by Ivaylo Kenov. Copyright 2015 Ivaylo Kenov ([http://mytestedasp.net](http
|
167 | 194 |
|
168 | 195 | **Currently MyTested.AspNetCore.Mvc is in alpha version and it is not advised to use it in production environments. The testing framework is fully tested and working correctly but the fluent APIs may change in the final production-ready build.**
|
169 | 196 |
|
170 |
| -MyTested.AspNetCore.Mvc source code is available under GNU Affero General Public License/FOSS License Exception. The free version of the library allows up to 500 assertions (around 100 test cases) per test project. Additionally, full-featured licenses can be requested for free by individuals, startups and educational institutions. Commercial licensing with private support will also be available with the final release. |
| 197 | +MyTested.AspNetCore.Mvc source code is available under GNU Affero General Public License/FOSS License Exception. The free version of the library allows up to 500 assertions (around 100 test cases) per test project. Additionally, full-featured licenses can be requested for free by individuals, open-source projects, startups and educational institutions. Commercial licensing with private support will also be available with the final release. |
171 | 198 |
|
172 | 199 | See the [LICENSE](https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc/blob/master/LICENSE) for detailed information.
|
173 | 200 |
|
|
0 commit comments