Exemplo n.º 1
0
        private void SetupServiceMock()
        {
            _serviceMock = Substitute.For <ICachingTestService>();
            _serviceMock.CallService().Returns(_ =>
            {
                return(Task.FromResult(_serviceResult));
            });
            _serviceMock.CallServiceWithAttRefreshTime().Returns(_ =>
            {
                return(Task.FromResult(_serviceResult));
            });
            _serviceMock.CallServiceWithoutAttRefreshTime().Returns(_ =>
            {
                return(Task.FromResult(_serviceResult));
            });
            _serviceMock.CallRevocableService(Arg.Any <string>()).Returns(async s =>
            {
                var result = _serviceResult;
                await _revokeDelay;
                return(new Revocable <string>
                {
                    Value = result,
                    RevokeKeys = new[] { s.Args()[0].ToString() }
                });
            });

            _serviceResult = FirstResult;
            var serviceProxyMock = Substitute.For <IServiceProxyProvider <ICachingTestService> >();

            serviceProxyMock.Client.Returns(_serviceMock);
            _kernel.Rebind <IServiceProxyProvider <ICachingTestService> >().ToConstant(serviceProxyMock);
        }
Exemplo n.º 2
0
        public void Setup()
        {
            SetupServiceMock();
            SetupDateTime();

            _proxy = _kernel.Get <ICachingTestService>();
        }
Exemplo n.º 3
0
        private void SetupServiceMock()
        {
            _serviceMock = Substitute.For <ICachingTestService>();
            _serviceMock.CallService().Returns(_ => Task.FromResult(_serviceResult));
            _serviceResult = FirstResult;
            var serviceProxyMock = Substitute.For <IServiceProxyProvider <ICachingTestService> >();

            serviceProxyMock.Client.Returns(_serviceMock);
            _kernel.Rebind <IServiceProxyProvider <ICachingTestService> >().ToConstant(serviceProxyMock);
        }
Exemplo n.º 4
0
        public void Setup()
        {
            SetupServiceMock();
            SetupDateTime();
            _revokeDelay = Task.Delay(0);

            _proxy          = _kernel.Get <ICachingTestService>();
            _cacheRevoker   = _kernel.Get <ICacheRevoker>();
            _revokeListener = _kernel.Get <IRevokeListener>();
        }