ibrahimbensalah / xania.aspnet Goto Github PK
View Code? Open in Web Editor NEWAspNet Mvc Simulator
License: MIT License
AspNet Mvc Simulator
License: MIT License
I tried to use Xania.AspNet.Simulator for Authorize attribute testing. I added this library to my existing unit test project and wrote such test:
[TestMethod]
public void HomeControllerAuthorizeTest()
{
var ctrl = new HomeController();
var action = ctrl.Action("Index");
action.Authenticate("user", new[] { "User" });
var result = action.GetAuthorizationResult();
Assert.IsNull(result);
}
And ArgumentNullException occured on action.GetAuthorizationResult(). I was amazed, this test is almost the same as examples in repo, but it didn't work! Then, I found a difference: a test class with this test method (as all controller test classes in my project) sets mock DependencyResolver on initialize:
[TestInitialize]
public void Setup()
{
var mockResolver = MockRepository.GenerateMock<IDependencyResolver>();
...
DependencyResolver.SetResolver(_mockResolver);
}
I tried to comment SetResolver line, and a test began to work.
If it is a bug, please fix it. Or, if I do something wrong, give an example with GetAuthorizationResult and mock DependencyResolver both.
Should look like:
action.RenderView(viewResult, output)
Hi @ibrahimbensalah. Really interested in this project. Could you provide an example of how I can execute a controller action that has filters on it? For example, I have a LoggingFilter that has been added to GlobalFilters. I'm interested in executing the whole pipeline, with filters, binders, etc.
Thanks
Hi
When I run my NUnit tests with the ReSharper test runner, Simulator is throwing an exception in the Assemblies property of MvcApplication, line 145:
System.ArgumentException : An item with the same key has already been added.
The Linq query on AppDomain.CurrentDomain.GetAssemblies() is returning duplicates, hence the error with duplicate key names being added to the collection. In my test project, this is the particular assembly that has been returned multiple times - JetBrains.ReSharper.UnitTestRunner.nUnit30.dll. Maybe a Distinct() call at the end of the query would resolve it?
When I run the tests with TestDriven.Net the error does not occur, presumably because the ReSharper DLLs are not loaded into the AppDomain.
Hi :)
I'm really keen to explore the features of this library, but it's a little tricky to get started without some documentation. I've had a look at some of the tests, but I'm struggling a bit to understand how view rendering works.
As an example: I'm getting some Razor compilation errors since it can't seem to find some of the dlls even though they are loaded into my app and I'm not sure what method this library uses for finding and loading assemblies.
Thanks
We are using xunit VS test adapter. And errors found here:
Created new MVC project from VS wizard (index page with About, Contact etc.) and test project alongside. Included Xania.AspNet nuget and wrote this:
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var controller = new HomeController();
var action = controller.Action(c => c.About());
var result = action.Execute();
Console.WriteLine(result.ToString());
}
}
it falls on action.Execute
with System.Web.HttpException: View 'About' not found.
Is that normal and what I must to do?
.NET 4.7.2, MVC5
Hi, could it be possible to include the extension?
.Action(controller => controller.Method())
support for WebApi also?
I see it works for MVC (System.Web.Mvc) - Controller
but not for WebApi (System.Web.Http) - ApiController
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.