public ReadingProgramInfo AddNewReadingProgram(string userId = null, string languageCode = "sv")
        {
            userId ??= CurrentUser.UserId;

            var children = new[]
            {
                AddNewChild(adults: userId),
                AddNewChild(adults: userId)
            };

            WaitOfIndexesInDocumentStore();

            var dto = new ReadingProgramInfoDTO
            {
                ChildrenIds  = children.Select(x => x.Id),
                LanguageCode = languageCode
            };

            using var session = DocumentStore.OpenSession();
            session.Store(dto);
            TestLogger().Information("Add new ReadingProgram to RavenDb from TestFactory");
            session.SaveChanges();

            WaitOfIndexesInDocumentStore();

            return(dto.ToReadingProgramInfo());
        }
Example #2
0
 public static bool AreEqual(ReadingProgramInfoDTO expected, ReadingProgramInfo actual)
 {
     Assert.NotNull(actual);
     Assert.AreEqual(expected.Id, actual.Id);
     CollectionAssert.AreEquivalent(expected.ChildrenIds, actual.Children);
     return(true);
 }
 public SingleWordReadingProgramOnRavenDb(ReadingProgramInfoDTO programInfo, IAsyncDocumentSession session, DictionaryService dictionary,
                                          ILogger logger)
 {
     ProgramId   = programInfo.Id;
     ChildrenIds = programInfo.ChildrenIds;
     _session    = session;
     _dictionary = dictionary;
     _logger     = logger.ForContext <SingleWordReadingProgramOnRavenDb>().ForContext("ProgramId", ProgramId);
 }
Example #4
0
        public void Setup()
        {
            _testFactory.GenerateNewDocumentStore(new ReadingWordStatusIndex());
            var info = new ReadingProgramInfoDTO
            {
                Id          = _programId,
                ChildrenIds = new[] { "child1" }
            };

            _dictionary = new Mock <DictionaryService>();
            SUT         = new SingleWordReadingProgramOnRavenDb(info, _testFactory.DocumentStore.OpenAsyncSession(), _dictionary.Object, _testFactory.TestLogger());
        }
        private async Task <ReadingProgramInfoDTO> CreateNewProgram(IEnumerable <string> forChildren, string languageCode, ReadingProgramType programType)
        {
            var programDto = new ReadingProgramInfoDTO
            {
                ChildrenIds  = forChildren,
                LanguageCode = languageCode,
                ProgramType  = programType
            };
            await _session.StoreAsync(programDto);

            _logger.ForContext("Children", forChildren).ForContext("ProgramType", programType).Information("Added new reading program to session");

            await SaveChanges();

            return(programDto);
        }
Example #6
0
 public static ReadingProgramInfo ToReadingProgramInfo(this ReadingProgramInfoDTO dto)
 {
     return(new ReadingProgramInfo(dto.Id, dto.ProgramType, dto.ChildrenIds.ToArray()));
 }
        private DictionaryService GetDictionaryService(ReadingProgramInfoDTO programInfo)
        {
            var dictionary = DictionaryFactory.CreateForLanguage(programInfo.LanguageCode, _client, _session, _logger);

            return(dictionary);
        }