Пример #1
0
        public async Task CountAsync_GivenNoCharacters_ShouldReturnZero()
        {
            // Given
            var dbContext  = InMemoryDbProvider.GetDbContext();
            var repository = new CharacterRepository(dbContext);

            // When
            var result = await repository.GetCountAsync();

            // Then
            result.Should().Be(0);
        }
Пример #2
0
        public async Task CountAsync_GivenSingleCharacter_ShouldReturnOne()
        {
            // Given
            var dbContext  = InMemoryDbProvider.GetDbContext();
            var repository = new CharacterRepository(dbContext);
            var character  = new CharacterBuilder().WithName("Naruto").Build();

            await dbContext.AnimeCharacters.AddAsync(character);

            await dbContext.SaveChangesAsync();

            // When
            var result = await repository.GetCountAsync();

            // Then
            result.Should().Be(1);
        }
Пример #3
0
        public async Task CountAsync_GivenMultipleCharacters_ShouldReturnCount()
        {
            // Given
            var dbContext  = InMemoryDbProvider.GetDbContext();
            var repository = new CharacterRepository(dbContext);
            var character1 = new CharacterBuilder().WithName("Naruto").Build();
            var character2 = new CharacterBuilder().WithName("Sasuke").Build();
            var character3 = new CharacterBuilder().WithName("Sakura").Build();

            await dbContext.AnimeCharacters.AddAsync(character1);

            await dbContext.AnimeCharacters.AddAsync(character2);

            await dbContext.AnimeCharacters.AddAsync(character3);

            await dbContext.SaveChangesAsync();

            // When
            var result = await repository.GetCountAsync();

            // Then
            result.Should().Be(3);
        }