Exemplo n.º 1
0
        public async Task ReturnsNullForNonExistingKeyInBothStorages()
        {
            _cache.GetAsync("foo").Returns <byte[]>(x => null);
            _tokenDb.GetToken("foo").Returns <Models.Token>(x => null);

            var expectedToken = await _sut.GetToken("foo");

            Assert.Null(expectedToken);
            await _cache.Received(1).GetAsync("foo");

            await _tokenDb.Received(1).GetToken("foo");

            await _cache.DidNotReceiveWithAnyArgs().SetAsync("", new byte[1]);
        }
Exemplo n.º 2
0
        public async Task InvalidInputsAreHandledCorrectly(string expectedKey, string expectedValue)
        {
            var expectedException = await Assert.ThrowsAsync <ArgumentException>(async() => await _sut.InsertToken(expectedKey, expectedValue));

            Assert.Contains("null or empty", expectedException.Message);

            await _cache.DidNotReceiveWithAnyArgs().RemoveAsync("foo");

            await _tokenDb.DidNotReceiveWithAnyArgs().DeleteToken("foo");
        }