コード例 #1
0
 public void InsertBibliography(Bibliography entity)
 {
     using (var context = new QualificationsDBEntities())
     {
         context.Bibliography.Attach(entity);
         context.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Added);
         context.SaveChanges();
     }
 }
コード例 #2
0
        public void Test_Open_Bibliography()
        {
            ExhibitHelper.NavigateToExhibit(_newExhibit);
            Bibliography bibliography         = ExhibitHelper.GetBibliography();
            bool         isBibliographyOpened = ExhibitHelper.IsBibliographyOpened();

            ExhibitHelper.CloseBibliography();
            Assert.IsTrue(isBibliographyOpened, "Bibliography is not opened");
            StringAssert.Contains(bibliography.Sources[0].Name, _newExhibit.ContentItems[0].MediaSource);
            StringAssert.StartsWith(bibliography.Sources[0].Description, _newExhibit.ContentItems[0].Title);
        }
コード例 #3
0
        public void WhenReferenceListIsNotPresentInContent_ReferencesAreNotRendered()
        {
            // Arrange
            var sampleContent   = "lorem ipsum <reference /> reference exists but no reference list";
            var expectedContent = "lorem ipsum  reference exists but no reference list";
            var sut             = new Bibliography();

            // Act
            var outputContent = sut.ProcessBibliographicReferences(sampleContent);

            // Assert
            Assert.Equal(expectedContent, outputContent);
        }
コード例 #4
0
        public void WhenNoReferencesArePresentInContent_ReferenceListIsNotRendered()
        {
            // Arrange
            var sampleContent   = "reference list exists but no references<reference-list />";
            var expectedContent = "reference list exists but no references";
            var sut             = new Bibliography();

            // Act
            var outputContent = sut.ProcessBibliographicReferences(sampleContent);

            // Assert
            Assert.Equal(expectedContent, outputContent);
        }
コード例 #5
0
        private static LibraryCard Convert(Bibliography bibliography)
        {
            if (bibliography == null)
            {
                throw new ArgumentNullException(nameof(bibliography));
            }

            return(new LibraryCard()
            {
                DateRentBook = bibliography.give_date,
                DateReturnBook = bibliography.get_date,
                CodeRentedBook = bibliography.id_book_instance,
                Client = ClientInformation.Convert(bibliography.Reader)
            });
        }
コード例 #6
0
        public void Write_WritesContents_CallsCorrectMethods()
        {
            // Arrange
            var bibliography = new Bibliography(_mockFileManager.Object, _mockLogger.Object)
            {
                TargetAuxPath = AuxPath, TargetPath = BblPath
            };

            // Act
            bibliography.Write();

            // Assert
            _mockFileManager.Verify(x => x.ThrowIfFileDoesNotExist(AuxPath), Times.Once);
            _mockFileManager.Verify(x => x.WriteStream(AuxPath, It.IsAny <Action <StreamWriter> >(), true), Times.Once);
            _mockFileManager.Verify(x => x.DeleteIfExists(BblPath), Times.Once);
            _mockFileManager.Verify(x => x.WriteStream(BblPath, It.IsAny <Action <StreamWriter> >(), false), Times.Once);
            _mockFileManager.VerifyNoOtherCalls();
        }
コード例 #7
0
        public Bibliography GetBibliography()
        {
            Logger.Log("<-");
            OpenBibliography();
            Bibliography bibliography = new Bibliography();

            bibliography.Sources = new List <Source>();
            Source bibliographySource = new Source();
            ReadOnlyCollection <IWebElement> sources = FindElements(By.ClassName("source"));

            foreach (IWebElement source in sources)
            {
                bibliographySource.Name        = source.FindElement(By.ClassName("sourceName")).Text;
                bibliographySource.Description = source.FindElement(By.ClassName("sourceDescr")).Text;
                bibliography.Sources.Add(bibliographySource);
            }
            Logger.Log("->");
            return(bibliography);
        }
コード例 #8
0
        public void WhenNoReferencesAndNoReferenceListArePresent_ContentDoesNotChange()
        {
            // Arrange
            var sampleContent1 = "";
            var sampleContent2 = "test";
            var sampleContent3 = "TEST";
            var sampleContent4 = "<b>test</b>";
            var sampleContent5 = "\t\t<B>test</B>\nline2";
            var sut            = new Bibliography();

            // Act
            var outputContent1 = sut.ProcessBibliographicReferences(sampleContent1);
            var outputContent2 = sut.ProcessBibliographicReferences(sampleContent2);
            var outputContent3 = sut.ProcessBibliographicReferences(sampleContent3);
            var outputContent4 = sut.ProcessBibliographicReferences(sampleContent4);
            var outputContent5 = sut.ProcessBibliographicReferences(sampleContent5);

            // Assert
            Assert.Equal(sampleContent1, outputContent1);
            Assert.Equal(sampleContent2, outputContent2);
            Assert.Equal(sampleContent3, outputContent3);
            Assert.Equal(sampleContent4, outputContent4);
            Assert.Equal(sampleContent5, outputContent5);
        }