public override IEnumerable <object[]> GetData(MethodInfo testMethod)
        {
            var testExecutionData = MockRoles.GetAllRoles().Select(role =>
            {
                return(new object[] { role, role == _roleName ? true : false });
            });

            return(testExecutionData);
        }
示例#2
0
 private HttpClient Arrange(string role)
 {
     if (role != null)
     {
         _testServerFixture.MockRoles.Roles = new List <string> {
             role
         };
     }
     else
     {
         _testServerFixture.MockRoles.Roles = MockRoles.GetAllRoles();
     }
     return(_testServerFixture.CreateDefaultClient());
 }
示例#3
0
            public TestContext()
            {
                MockDbContext   = CreateMockDbContext();
                MockUserManager = CreateMockUserManager(this);

                var mockLogger = new Mock <ILogger>();

                MockLoggerFactory = new Mock <ILoggerFactory>();
                MockLoggerFactory.Setup(lf => lf.CreateLogger(It.IsAny <string>()))
                .Returns(mockLogger.Object);

                MockRoleManager = CreateMockRoleManager();
                MockRoleManager.Setup(m => m.Roles).Returns(MockRoles.AsQueryable());
                ;
            }
        private HttpClient Arrange(List <string> roles = null)
        {
            var testServer = new TestServer(WebHost.CreateDefaultBuilder()
                                            .UseStartup <StartupUnderTest>()
                                            .ConfigureServices(services =>
            {
                var mockRoles = new MockRoles();
                if (roles != null)
                {
                    mockRoles.AddRange(roles);
                }
                services.TryAddSingleton(mockRoles);
            })
                                            );

            return(testServer.CreateClient());
        }
 public TestStartup(IConfiguration config) : base(config)
 {
     MockRoles = new MockRoles();
 }