public void TryGetEntry_Empty_ShouldReturnFalse() { // Arrange KeyValuePair <string, int>[] source = Array.Empty <KeyValuePair <string, int> >(); FixedSizeDictionary <int> dictionary = FixedSizeDictionary <int> .Create(source, x => x.Key, x => x.Value); // Act bool value = dictionary.TryGetEntry(new Fixture().Create <string>(), out FixedSizeDictionary <int> .Entry entry); // Assert value.ShouldBeFalse(); entry.ShouldBe(default);
public void TryGetEntry_ExistingKey_ShouldReturnEntryAndTrue(int elementsCount) { // Arrange var fixture = new Fixture { RepeatCount = elementsCount }; KeyValuePair <string, int>[] source = fixture.CreateMany <KeyValuePair <string, int> >().Distinct().ToArray(); var keyValuePair = elementsCount is 0 ? fixture.Create <KeyValuePair <string, int> >() : source.RandomElement(); FixedSizeDictionary <int> dictionary = FixedSizeDictionary <int> .Create(source, x => x.Key, x => x.Value); // Act bool value = dictionary.TryGetEntry(keyValuePair.Key, out FixedSizeDictionary <int> .Entry entry); // Assert value.ShouldBeTrue(); entry.Key.ShouldBe(keyValuePair.Key); entry.Value.ShouldBe(keyValuePair.Value); }