public void User_CanNotAddItemWithNotUniqueKey() { NativeDictionaryModel <int> dict = null; "Given initialized dictionary with key = 'key' and item 10" .x((() => { dict = new NativeDictionaryModel <int>(); dict.Initialize(20); dict.Put("key", 10); })); "When user tries to put new item with same key 'key'" .x(() => { dict.Put("key", 20); }); "Then new item should not be added and status should be 'key already exists'" .x(() => { var items = dict.GetItems(); items.Should().BeEquivalentTo(new List <int>() { 10 }); // status var status = dict.LastPutStatus(); status.Should().Be(OperationCode.KeyAlreadyExists); }); }
public void User_CanGetItemByExistsKey() { NativeDictionaryModel <int> dict = null; var item = 0; "Given initialized dictionary with key = 'key' and item 10" .x((() => { dict = new NativeDictionaryModel <int>(); dict.Initialize(20); dict.Put("key", 10); })); "When user tries to get item by key 'key'" .x(() => { item = dict.GetItem("key"); }); "Then dictionary must return item 10" .x(() => { item.Should().Be(10); }); }
public void User_ReceivesDefaultValueWhenKeyIsNotExists() { NativeDictionaryModel <string> dict = null; string item = null; "Given initialized dictionary with key = 'key' and item 10" .x((() => { dict = new NativeDictionaryModel <string>(); dict.Initialize(20); dict.Put("key", "10"); })); "When user tries to get item by key 'key 2'" .x(() => { item = dict.GetItem("key 2"); }); "Then dictionary must return default item" .x(() => { item.Should().Be(default);