예제 #1
0
 public HealthCheckTest(TestWebApplicationFactory <Startup> factory)
 {
     _fakeUnitOfWork = A.Fake <IUnitOfWork>(uow => uow.Implements <IUnitOfWork>());
     _factory        = factory;
     _factory.ClientOptions.BaseAddress = new Uri("http://localhost/v1/api/users");
     _httpClient = factory.WithWebHostBuilder(builder =>
     {
         builder.UseSetting("https_port", "5001");
         builder.UseStartup <TestStartup>();
         builder.ConfigureTestServices(services =>
         {
             services.AddSingleton(typeof(IUnitOfWork), _fakeUnitOfWork);
         });
     }).CreateClient();
 }
        public UsersControllerIntegrationTest(TestWebApplicationFactory <Startup> factory)
        {
            _fakeUnitOfWork = A.Fake <IUnitOfWork>(uow => uow.Implements <IUnitOfWork>());
            _factory        = factory;
            _factory.ClientOptions.BaseAddress = new Uri("http://localhost/v1/api/users");
            _client = _factory.WithWebHostBuilder(builder =>
            {
                builder.UseSetting("https_port", "5001");
                builder.UseStartup <TestStartup>();
                builder.ConfigureTestServices(services =>
                {
                    services.AddSingleton(typeof(IUnitOfWork), _fakeUnitOfWork);
                });
            }).CreateClient();

            _dummyRole = new Role
            {
                Id          = 1,
                Name        = "RoleKind",
                Description = "A Role of some kind"
            };

            _dummyUser1 = new User
            {
                Id     = 1,
                Name   = "Hello",
                Email  = "*****@*****.**",
                Hash   = "234dasd3rfs",
                RoleId = 1,
                Role   = _dummyRole
            };

            _dummyUser2 = new User
            {
                Id     = 2,
                Name   = "Hello",
                Email  = "*****@*****.**",
                Hash   = "234dasd3rfs",
                RoleId = 1,
                Role   = _dummyRole
            };

            A.CallTo(() => _fakeUnitOfWork.Users.GetAsync(1)).Returns(_dummyUser1);
            A.CallTo(() => _fakeUnitOfWork.Roles.GetAsync(1)).Returns(_dummyRole);
            A.CallTo(() => _fakeUnitOfWork.Users.GetAllAsync()).Returns(new List <User> {
                _dummyUser1, _dummyUser2
            });
        }