Пример #1
0
        public void SearchForFiles_WithCharacters_CharacterWithBothCoverFileAndAttached_OtherCharacterNotFound()
        {
            var fileId = repository.CreateMediaFile(new CreateMediaFileDto("", MediaFileType.VIDEO_TYPE, ""));
            var file   = repository.GetMediaFile(fileId);

            var characterRepository = new CharacterRepository();
            var characterDto        = CreateCharacterUtil.GetNewCharacterDetails(testLibrary.LibraryId);

            characterDto.Name = "test 1";
            var character1 = characterRepository.CreateCharacter(characterDto);

            characterDto.Name         = "test 2";
            characterDto.CoverMediaId = fileId;
            var character2 = characterRepository.CreateCharacter(characterDto);

            repository.AddFileToCharacter(character2, file).ConfigureAwait(false);

            var queries = new List <IMediaFileSearchQueryGenerator>();

            queries.Add(new MediaFileWithCharacterNameGenerator("[\"1\", \"2\"]"));

            var actualFiles   = repository.SearchForFiles(GetFirstPage(), queries).Result.Results;
            var expectedFiles = new List <MediaFile>();

            CollectionAssert.AreEquivalent(expectedFiles, actualFiles);
        }
        public void DeleteCalendar_ShouldRemoveFromCharacter()
        {
            var characterRepository = new CharacterRepository();
            var deletedCalendar     = CreateAndRetrieveCalendar();
            var notDeletedCalendar  = CreateAndRetrieveCalendar();

            var dto = CreateCharacterUtil.GetNewCharacterDetails(testLibrary.LibraryId);

            dto.CalendarId = deletedCalendar.CalendarId;
            var characterId = characterRepository.CreateCharacter(dto);

            dto.CalendarId = notDeletedCalendar.CalendarId;
            var character2Id = characterRepository.CreateCharacter(dto);

            repository.DeleteCalendar(deletedCalendar.CalendarId);

            var character  = characterRepository.GetCharacter(characterId);
            var character2 = characterRepository.GetCharacter(character2Id);

            Assert.AreEqual(DatabaseConstants.DEFAULT_ID, character.CalendarId);
            Assert.AreEqual(notDeletedCalendar.CalendarId, character2.CalendarId);
        }
Пример #3
0
        /// <summary>
        /// Takes in a character model view and either creates a new entity of a character
        /// or updates an existing character depending on if the ID is populated.
        /// It also associates a character with a session is if the session Id is populated.
        /// </summary>
        /// <param name="character">Character view model to be updated/created/associated</param>
        /// <returns>HTTP Response with modified or created character object</returns>
        public HttpResponseMessage Post(CharacterViewModel character)
        {
            Character dbCharacter = ModelConverter.ToDbCharacterModel(character);

            if (dbCharacter.Id > 0)
            {
                characterRepro.UpdateCharacter(dbCharacter);
            }
            else
            {
                dbCharacter = characterRepro.CreateCharacter(dbCharacter);
            }

            if (character.SessionId > 0)
            {
                sessionRepro.AssociateCharacterToSession(dbCharacter.Id, character.SessionId);
            }

            // This is a hack to cover up for the fact session list is dropping off somewhere?
            dbCharacter = characterRepro.GetCharacter(dbCharacter.Id);

            return(Request.CreateResponse(HttpStatusCode.OK, ModelConverter.ToCharacterViewModel(dbCharacter)));
        }
Пример #4
0
        public void SearchForFiles_WithCharacters_MatchUppercase()
        {
            var characterRepository = new CharacterRepository();
            var characterDto        = CreateCharacterUtil.GetNewCharacterDetails(testLibrary.LibraryId);

            characterDto.Name = "test 1";
            var character1 = characterRepository.CreateCharacter(characterDto);

            var fileId = repository.CreateMediaFile(new CreateMediaFileDto("", MediaFileType.VIDEO_TYPE, ""));
            var file   = repository.GetMediaFile(fileId);

            repository.AddFileToCharacter(character1, file).ConfigureAwait(false);

            var queries = new List <IMediaFileSearchQueryGenerator>();

            queries.Add(new MediaFileWithCharacterNameGenerator("[\"TEST 1\"]"));

            var actualFiles   = repository.SearchForFiles(GetFirstPage(), queries).Result.Results;
            var expectedFiles = new List <MediaFile> {
                file
            };

            CollectionAssert.AreEquivalent(expectedFiles, actualFiles);
        }
Пример #5
0
        private Character CreateAndRetrieveCharacter(CreateCharacterDto dto)
        {
            var characterId = characterRepository.CreateCharacter(dto);

            return(characterRepository.GetCharacter(characterId));
        }
Пример #6
0
 public long CreateCharacter(CreateCharacterDto dto)
 {
     return(characterRepository.CreateCharacter(dto));
 }