public void UpdateValueOnConfiguration_ShouldThrowException_WhenConfigurationExistsButNotTheVersion() { // 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 tags = _fixture.CreateMany <string>().ToList(); var unknownVersion = _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> > > > >( dataType, 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, 1, data, tags) } } }) } }); Func <Task> exceptionThrower = async() => await _sut .UpdateValueOnConfiguration(key, unknownVersion, valueId, tags, data) .ConfigureAwait(false); // act/assert exceptionThrower .ShouldThrow <ArgumentException>(); }
public async Task UpdateValueOnConfiguration_ShouldAddNewDataWithBumpedVersion_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(); var newData = _fixture.Create <string>(); _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> > > { new Tuple <Guid, int, string, IEnumerable <string> >( valueId, sequence, data, tags) } } }) } }); var expected = new StoredConfig { Type = dataType, Values = new List <StoredConfigValues> { new StoredConfigValues { Id = valueId, Sequence = sequence + 1, EnvironmentTags = tags, Data = newData } } }; // act await _sut .UpdateValueOnConfiguration(key, version, valueId, tags, newData) .ConfigureAwait(false); // actual (await _sut .GetConfiguration(key, version) .ConfigureAwait(false)) .ShouldBeEquivalentTo( expected, options => options .Excluding((ISubjectInfo si) => si.SelectedMemberInfo.Name == "CreatedAt")); }