Ejemplo n.º 1
0
        public Word Add(string name, string description, string tags)
        {
            Contract.Assert(!wordsByName.ContainsKey(name));
            Modified = true;

            Word word = new Word();

            word.Name        = name;
            word.Description = description;
            word.Tags        = TagParser.ReformatTags(tags);
            word.Mark(WordEventType.Added);

            WordInfo wordInfo = WordInfo.Create(this, word);

            wordsByName.Add(name, wordInfo);

            tagIndex.Add(name, wordInfo.Tags);
            translationIndex.Add(name, wordInfo.Translations);

            UpdateTranslations(wordInfo.Translations);

            UpdateStats();

            OnContentsChanged();

            return(word);
        }
Ejemplo n.º 2
0
        public Word Add(string name, string description, string tags)
        {
            Contract.Assert(!wordsByName.ContainsKey(name));
            Modified = true;

            Word word = new Word();
            word.Name = name;
            word.Description = description;
            word.Tags = TagParser.ReformatTags(tags);
            word.Mark(WordEventType.Added);

            WordInfo wordInfo = WordInfo.Create(this, word);
            wordsByName.Add(name, wordInfo);

            tagIndex.Add(name, wordInfo.Tags);
            translationIndex.Add(name, wordInfo.Translations);

            UpdateTranslations(wordInfo.Translations);

            UpdateStats();

            OnContentsChanged();

            return word;
        }
Ejemplo n.º 3
0
        public void TestEventOrdering1()
        {
            Word word = new Word();

            word.Mark(WordEventType.Added);
            Assert.That(word.Events.Count, Is.EqualTo(1));
            Assert.That(word.Events[0].EventType, Is.EqualTo(WordEventType.Added));

            word.Mark(WordEventType.Remembered);
            Assert.That(word.Events.Count, Is.EqualTo(2));
            Assert.That(word.Events[0].EventType, Is.EqualTo(WordEventType.Added));
            Assert.That(word.Events[1].EventType, Is.EqualTo(WordEventType.Remembered));
            Assert.That(word.Events[0].EventDate, Is.LessThanOrEqualTo(word.Events[1].EventDate));

            word.Mark(WordEventType.Forgotten);
            Assert.That(word.Events.Count, Is.EqualTo(2));
            Assert.That(word.Events[0].EventType, Is.EqualTo(WordEventType.Added));
            Assert.That(word.Events[1].EventType, Is.EqualTo(WordEventType.Forgotten));
            Assert.That(word.Events[0].EventDate, Is.LessThanOrEqualTo(word.Events[1].EventDate));
        }
Ejemplo n.º 4
0
        public void TestEventOrderingWithFutureDates()
        {
            Word word = new Word();

            word.Events.Add(new WordEvent(DateTime.UtcNow.AddDays(1), WordEventType.Added));
            word.Events.Add(new WordEvent(DateTime.UtcNow.AddDays(2), WordEventType.Remembered));

            word.Mark(WordEventType.Forgotten);
            Assert.That(word.Events.Count, Is.EqualTo(2));
            Assert.That(word.Events[0].EventType, Is.EqualTo(WordEventType.Added));
            Assert.That(word.Events[1].EventType, Is.EqualTo(WordEventType.Forgotten));
            Assert.That(word.Events[0].EventDate, Is.LessThanOrEqualTo(word.Events[1].EventDate));
        }
Ejemplo n.º 5
0
 //todo: is this wrapper required?
 public void Mark(WordEventType eventType)
 {
     Word.Mark(eventType);
     Update();
 }