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_CanAddItemWithUniqueKey() { NativeDictionaryModel <int> dict = null; "Given initialized dictionary" .x((() => { dict = new NativeDictionaryModel <int>(); dict.Initialize(20); })); "When user tries to put new item with unique key" .x(() => { dict.Put("Item", 2); }); "Then new item should be added" .x(() => { var items = dict.GetItems(); items.Should().BeEquivalentTo(new List <int>() { 2 }); // status var status = dict.LastPutStatus(); status.Should().Be(OperationCode.Ok); }); }
public void PutAndRemoveOperationsOfNotInitializedDictionaryReturnsOperationCodeNotInitialized() { NativeDictionaryModel <int> dict = null; OperationCode putStatus = OperationCode.Ok, removeStatus = OperationCode.Ok; "Given not initialized dictionary" .x((() => { dict = new NativeDictionaryModel <int>(); })); "When user tries to put new item and remove" .x(() => { dict.Put("Item", 2); putStatus = dict.LastPutStatus(); dict.Remove("Item"); removeStatus = dict.LastRemoveStatus(); }); "Then last put and remove statuses should be 'Not initialized'" .x(() => { putStatus.Should().Be(OperationCode.NotInitialized); removeStatus.Should().Be(OperationCode.NotInitialized); }); }
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);