Exemplo n.º 1
0
        public async Task ShouldGetTryCount()
        {
            //Arrange
            var service = SetupService();

            //Act
            await service.ShouldRequeueAsync("123", 0, -1, 1);

            //Assert
            Assert.Equal(1, _repository.ReceivedCalls().Count(c => c.GetMethodInfo().Name == "GetAsync"));
        }
Exemplo n.º 2
0
        public async Task ShouldDeleteTryCountForEveryGivenId()
        {
            //Arrange
            var service   = SetupService();
            var sampleIds = new[] { "1", "2", "3" };

            //Act
            await service.ClearTryCountAsync(sampleIds, CancellationToken.None);

            //Assert
            Assert.Equal(3, _repository.ReceivedCalls().Count(c => c.GetMethodInfo().Name == "DeleteAsync"));
            Assert.True(_repository.ReceivedCalls().Where(c => c.GetMethodInfo().Name == "DeleteAsync")
                        .All(c => sampleIds.Any(i => ((string)c.GetArguments()[0]).EndsWith($":{i}"))));
            Assert.Equal(3,
                         _repository.ReceivedCalls().Where(c => c.GetMethodInfo().Name == "DeleteAsync")
                         .Select(c => (string)c.GetArguments()[0]).Distinct().Count());
        }