Esempio n. 1
0
        public void UpdateFlashcardTestB()
        {
            ResetTestDatabasev5.Reset();

            var _processor = new UpdateFlashcard(
                new CheckIfFlashcardIsUnique(),
                new ValidateFlashcard(),
                new UpdateFlashcardWords());

            Assert.False(_processor.Update(
                             "Flashcard 7.1 native ",
                             "Flashcard 7.1 foreign",
                             Guid.Parse("45433894-5820-413f-93fb-46429ba8486a"),
                             Guid.Parse("d7e0f1ef-49de-486e-b88a-d0e0c1d8f496")));

            Assert.NotEmpty(_processor.GetUserMessages());

            using (var db = new FlashcardsDbContext())
            {
                Assert.Equal(0, db.FlashcardsDbModels
                             .Where(e => e.Id == Guid.Parse("45433894-5820-413f-93fb-46429ba8486a") &&
                                    e.ForeignLanguage == "Flashcard 7.1 foreign" &&
                                    e.NativeLanguage == "Flashcard 7.1 native")
                             .Count());
            }
        }
Esempio n. 2
0
        public void ReCalculateAndUpdatePracticePropertiesListTestC()
        {
            ResetTestDatabasev5.Reset();

            FlashcardDbModel       flashcard;
            FlashcardPracticeModel flashcardPractice;

            using (var db = new FlashcardsDbContext())
            {
                flashcard = db.FlashcardsDbModels.FirstOrDefault(e => e.Id == Guid.Parse("32aee329-6675-4ae8-898a-95bb94ea0143") && e.PracticeDirection == PracticeDirection.FromForeignToNative);

                flashcardPractice = new FlashcardPracticeModel()
                {
                    Id = flashcard.Id,
                    PracticeDirection     = flashcard.PracticeDirection,
                    FlashcardKnowledgeInt = 3,
                    CorreactAnsInRow      = flashcard.CorreactAnsInRow
                };
            }

            ReCalculateAndUpdatePracticePropertiesList _processor = new ReCalculateAndUpdatePracticePropertiesList(new ReCalculateFlashcardPracticeProps(
                                                                                                                       new CalculateNextPracticeDate()),
                                                                                                                   new UpdateFlashcardsListPracticeProperties(
                                                                                                                       new UpdateFlashcardPracticeProperties()));

            _processor.ReCauculate(new List <FlashcardPracticeModel>()
            {
                flashcardPractice
            });

            using (var db = new FlashcardsDbContext())
            {
                Assert.NotNull(db.FlashcardsDbModels
                               .FirstOrDefault(e => e.Id == Guid.Parse("32aee329-6675-4ae8-898a-95bb94ea0143") &&
                                               e.PracticeDirection == PracticeDirection.FromForeignToNative &&
                                               e.CorreactAnsInRow == 4 &&
                                               e.NextPracticeDate == DateTime.Now.Date.AddDays(7)));
            }
        }