public UpdateControllerTest()
        {
            _testContainerBuilder.RegisterType <UpdateController>();
            _bot    = A.Fake <IBot>();
            _logger = A.Fake <ILogger <UpdateController> >();
            _testContainerBuilder.RegisterInstance(_logger).As <ILogger <UpdateController> >();
            _adminService = A.Fake <IAdminWebService>();
            var admins = new List <AdminResponse>
            {
                new AdminResponse()
                {
                    Name = "admin"
                },
                new AdminResponse()
                {
                    Name = "toto"
                },
            };

            A.CallTo(() => _adminService.GetAllAdmins()).Returns(admins);

            _testContainerBuilder.RegisterInstance(_adminService).As <IAdminWebService>();
            _testContainerBuilder.RegisterInstance(_bot);
            _contextHub = A.Fake <ContextHub>();
            _testContainerBuilder.RegisterInstance(_contextHub).SingleInstance();
            _container = _testContainerBuilder.Build();
            _target    = _container.Resolve <UpdateController>();
        }
        public async Task UpdateAdmins()
        {
            // Arrange

            // Act
            await _target.UpdateAdmins();

            // Assert
            A.CallTo(() => _adminService.GetAllAdmins()).MustHaveHappened(Repeated.Exactly.Once);
        }
Exemple #3
0
        public async Task UpdateAdmins()
        {
            await semaphoreSlim.WaitAsync();

            try
            {
                _admins = (await _adminWebService.GetAllAdmins()).ToList();
            }
            finally
            {
                semaphoreSlim.Release();
            }
        }