public void AddRemoveKeyShouldPassAndNonExistintKeyShouldFail() { JsonPublicKeySource obj = new JsonPublicKeySource(); string randFileName = RandomString(6) + ".json"; obj.LoadFromFile(randFileName, true); string nodeId = "0x00000000012"; string pubKey = "SADDFAJIONJKASD234ASDASNK34234="; obj.AddKey(nodeId, pubKey); string key = obj.GetKeyForNode(nodeId); Assert.Equal(key, pubKey); string nodeId2 = "0x00000000003"; string pubKey2 = "SASADDFAJIONJKASD234ASDASNK34234DDFAJIONJKASD234ASDASNK34234="; obj.AddKey(nodeId2, pubKey2); string key2 = obj.GetKeyForNode(nodeId2); Assert.Equal(key2, pubKey2); //now removing key obj.RemoveKey(nodeId2); //verifying that key is removed var exception = Assert.Throws <KeyNotFoundException>(() => obj.RemoveKey(nodeId2)); Assert.NotNull(exception); Assert.Contains("Node key is not known", exception.Message); //removing temp file File.Delete(randFileName); }