Exemple #1
0
        public async Task GetAvatarAsync_should_generate_avatar_if_none_found()
        {
            var fileSystem = new MockFileSystem();

            _cache = new AvatarPersistentCache(_inner, _avatarGenerator, fileSystem);
            fileSystem.Directory.Exists(_folderPath).Should().BeFalse();

            Assert.AreSame(_imgGenerated, await _cache.GetAvatarAsync(_emailMissing, _nameMissing, _size));
        }
Exemple #2
0
        public async Task GetAvatarAsync_should_create_if_folder_absent()
        {
            var fileSystem = new MockFileSystem();

            _cache = new AvatarPersistentCache(_inner, Substitute.For <IAvatarGenerator>(), fileSystem);
            fileSystem.Directory.Exists(_folderPath).Should().BeFalse();

            Assert.AreSame(_img1, await _cache.GetAvatarAsync(_email1, _name1, _size));

            fileSystem.Directory.Exists(_folderPath).Should().BeTrue();
        }
Exemple #3
0
        public async Task GetAvatarAsync_should_create_image_from_stream()
        {
            var fileSystem = new MockFileSystem();

            _cache = new AvatarPersistentCache(_inner, Substitute.For <IAvatarGenerator>(), fileSystem);
            fileSystem.Directory.Exists(_folderPath).Should().BeFalse();

            Assert.AreSame(_img1, await _cache.GetAvatarAsync(_email1, _name1, _size));

            fileSystem.Directory.Exists(_folderPath).Should().BeTrue();
            fileSystem.File.Exists(Path.Combine(_folderPath, $"{_email1}.{_size}px.png")).Should().BeTrue();
        }