如何使用Xunit测试Azure AD后面的控制器的示例 [英] An example of how to use Xunit to test a controller behind Azure AD
本文介绍了如何使用Xunit测试Azure AD后面的控制器的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有示例显示如何测试由Azure AD验证的用户正在查看的Controller?
Is there an example anywhere showing how to test a Controller that is being viewed by a user authenticated to Azure AD?
我在GitHub上找到了Azure示例。 它没有任何相关的单元测试。 我正在使用XUnit进行测试。
I have found the Azure Sample on GitHub. It does not have any related Unit Test. I am using XUnit for testing.
这没什么大不了的。 只是想验证一个控制器工作。
This is nothing elaborate. Just looking to verify a controller worked.
////Arrange
var homeController = new HomeController();
//Act
var contentResult = homeController.Index() as ContentResult;
//Assert
Assert.NotNull(contentResult);
Assert.Equal("It Worked", contentResult.Content);
推荐答案
有一个MSDN UT论坛,还有一个MSDN Azure论坛。您可以使用Bing或Google查找它们。
There is a MSDN UT forum and there is also a MSDN Azure forum. You can use Bing or Google to find them.
这篇关于如何使用Xunit测试Azure AD后面的控制器的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文