public async Task GetConfiguration_ShouldReturnConfiguration_WhenItIsAvailable() { // arrange var key = _fixture.Create <string>(); var version = _fixture.Create <Version>(); var dataType = _fixture.Create <ValueType>(); var valueId = _fixture.Create <Guid>(); var data = _fixture.Create <string>(); var sequence = _fixture.Create <int>(); var tags = _fixture.CreateMany <string>().ToList(); _sut = new InMemoryConfigurationRepository(new Dictionary <string, Tuple <string, IDictionary <Version, IList <Tuple <Guid, int, string, IEnumerable <string> > > > > > { { key, new Tuple <string, IDictionary <Version, IList <Tuple <Guid, int, string, IEnumerable <string> > > > >( dataType.ToString(), new Dictionary <Version, IList <Tuple <Guid, int, string, IEnumerable <string> > > > { { version, new List <Tuple <Guid, int, string, IEnumerable <string> > > { new Tuple <Guid, int, string, IEnumerable <string> >( valueId, sequence, data, tags) } } }) } }); var expectedConfig = new StoredConfig { Type = dataType.ToString(), Values = new List <StoredConfigValues> { new StoredConfigValues { Id = valueId, EnvironmentTags = tags, Data = data, Sequence = sequence } } }; // act var config = await _sut .GetConfiguration(key, version) .ConfigureAwait(false); // assert config.ShouldBeEquivalentTo( expectedConfig, options => options .Excluding((ISubjectInfo si) => si.SelectedMemberInfo.Name == "CreatedAt")); }
public async Task AddNewConfiguration_ShouldAddTheConfiguration_WhenItDoesNotExist() { // arrange var key = _fixture.Create <string>(); var version = _fixture.Create <Version>(); var dataType = _fixture.Create <ValueType>().ToString(); _sut = new InMemoryConfigurationRepository(); var createdAt = DateTime.UtcNow; var expected = new StoredConfig { Type = dataType, Values = new List <StoredConfigValues>() }; // act await _sut .AddNewConfiguration(key, dataType, createdAt) .ConfigureAwait(false); // assert (await _sut .GetConfiguration(key) .ConfigureAwait(false)) .ShouldBeEquivalentTo( expected, options => options .Excluding((ISubjectInfo si) => si.SelectedMemberInfo.Name == "CreatedAt")); }
public async Task AddNewValueToConfiguration_ShouldAddTheNewValue_WhenConfigurationExists() { // arrange var key = _fixture.Create <string>(); var version = _fixture.Create <Version>(); var dataType = _fixture.Create <ValueType>().ToString(); var valueId = _fixture.Create <Guid>(); var data = _fixture.Create <string>(); var sequence = _fixture.Create <int>(); var tags = _fixture.CreateMany <string>().ToList(); _sut = new InMemoryConfigurationRepository(new Dictionary <string, Tuple <string, IDictionary <Version, IList <Tuple <Guid, int, string, IEnumerable <string> > > > > > { { key, new Tuple <string, IDictionary <Version, IList <Tuple <Guid, int, string, IEnumerable <string> > > > >( dataType, new Dictionary <Version, IList <Tuple <Guid, int, string, IEnumerable <string> > > > { { version, new List <Tuple <Guid, int, string, IEnumerable <string> > >() } }) } }); var createdAt = DateTime.UtcNow; var expected = new StoredConfig { Type = dataType, Values = new List <StoredConfigValues> { new StoredConfigValues { Id = valueId, Sequence = 1, EnvironmentTags = tags, Data = data, CreatedAt = createdAt } } }; // act await _sut .AddNewValueToConfiguration(key, version, valueId, tags, data, createdAt) .ConfigureAwait(false); // assert (await _sut .GetConfiguration(key, version) .ConfigureAwait(false)) .ShouldBeEquivalentTo( expected, options => options .Excluding((ISubjectInfo si) => si.SelectedMemberInfo.Name == "CreatedAt")); }
public async Task GetConfiguration_ShouldReturnNull_WhenNoConfigurationIsAvailable() { // arrange var key = _fixture.Create <string>(); var version = _fixture.Create <Version>(); _sut = new InMemoryConfigurationRepository(); // act var config = await _sut .GetConfiguration(key, version) .ConfigureAwait(false); // assert config.Should().BeNull(); }
public async Task GetConfiguration_ShouldReturnNull_WhenKeyIsAvailableButVersionIsNot() { // arrange var key = _fixture.Create <string>(); var versionToQuery = _fixture.Create <Version>(); var versionInStore = _fixture.Create <Version>(); _sut = new InMemoryConfigurationRepository(new Dictionary <string, Tuple <string, IDictionary <Version, IList <Tuple <Guid, int, string, IEnumerable <string> > > > > > { { key, new Tuple <string, IDictionary <Version, IList <Tuple <Guid, int, string, IEnumerable <string> > > > >( _fixture.Create <ValueType>().ToString(), new Dictionary <Version, IList <Tuple <Guid, int, string, IEnumerable <string> > > > { { versionInStore, new List <Tuple <Guid, int, string, IEnumerable <string> > > { new Tuple <Guid, int, string, IEnumerable <string> >( _fixture.Create <Guid>(), _fixture.Create <int>(), _fixture.Create <string>(), _fixture.CreateMany <string>().ToList()) } } }) } }); // act var config = await _sut .GetConfiguration(key, versionToQuery) .ConfigureAwait(false); // assert config.Should().BeNull(); }