Example #1
0
        public void NoteApiUsesKVStoreToStoreNotes()
        {
            var kvStore = new Mock <IKeyValueStore>();
            var noteApi = new NoteApi(kvStore.Object);

            noteApi.AddNote("user-id", "this is a note");

            kvStore.Verify(x => x.Set("notes:user-id", "[{\"Id\":\"1\",\"Text\":\"this is a note\"}]"));
            kvStore.Verify(x => x.Set("notes:user-id:next", "2"));
        }
Example #2
0
        public void NoteApiUsesKVStoreToStoreSecondNote()
        {
            var kvStore = new Mock <IKeyValueStore>();
            var noteApi = new NoteApi(kvStore.Object);

            kvStore.Setup(x => x.Get("notes:user-id:next")).Returns("2");
            kvStore.Setup(x => x.Get("notes:user-id")).Returns("[{\"Id\":\"1\",\"Text\":\"this is a note\"}]");

            noteApi.AddNote("user-id", "this is another note");

            kvStore.Verify(x => x.Set("notes:user-id", "[{\"Id\":\"1\",\"Text\":\"this is a note\"},{\"Id\":\"2\",\"Text\":\"this is another note\"}]"));
            kvStore.Verify(x => x.Set("notes:user-id:next", "3"));
        }