Beispiel #1
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");
        }
Beispiel #2
0
        public async Task ReturnsValuesThatExistInCache(string expectedKey, string expectedValue)
        {
            var expectedByteValue = Encoding.ASCII.GetBytes(expectedValue);

            _cache.GetAsync(expectedKey).Returns(expectedByteValue);

            var expectedToken = await _sut.GetToken(expectedKey);

            Assert.IsType <Models.Token>(expectedToken);
            Assert.Equal(expectedKey, expectedToken.Key);
            Assert.Equal(expectedValue, expectedToken.Value);
            await _cache.Received(1).GetAsync(expectedKey);

            await _tokenDb.DidNotReceiveWithAnyArgs().GetToken("");
        }