public void AddNewConfiguration_ShouldThrowException_WhenItAlreadyExists() { // arrange var key = _fixture.Create <string>(); var version = _fixture.Create <Version>(); var dataType = _fixture.Create <ValueType>(); _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> > >() } }) } }); Func <Task> exThrower = async() => await _sut .AddNewConfiguration(key, dataType.ToString(), DateTime.UtcNow) .ConfigureAwait(false); // act/assert exThrower .ShouldThrow <ArgumentException>(); }
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")); }