public async Task DeleteValueOnConfiguration_ShouldDeleteValue_WhenConfigurationAndValueExistButIsNotTheLastOne() { // 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 store = 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), new Tuple <Guid, int, string, IEnumerable <string> >( _fixture.Create <Guid>(), _fixture.Create <int>(), _fixture.Create <string>(), _fixture.CreateMany <string>().ToArray()) } } }) } }; _sut = new InMemoryConfigurationRepository(store); // act await _sut .DeleteValueOnConfiguration(key, version, valueId) .ConfigureAwait(false); // assert store[key] .Item2[version] .FirstOrDefault(t => t.Item1 == valueId) .Should() .BeNull(); }
public void DeleteValueOnConfiguration_ShouldThrowException_WhenConfigurationAndVersionExistButValueDoesNot() { // 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 wrongValueId = _fixture.Create <Guid>(); var store = 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) } } }) } }; _sut = new InMemoryConfigurationRepository(store); Func <Task> exceptionThrower = async() => await _sut .DeleteValueOnConfiguration(key, version, wrongValueId) .ConfigureAwait(false); // act/assert exceptionThrower.ShouldThrow <ArgumentException>(); }