Esempio n. 1
0
        void ListPoemsByTitle_RepositoryReturnsPoemList_ExpectPoemDTOList()
        {
            //Arrange
            var poemList       = new PoemBuilder().Default().BuildCollection(size: 3);
            var mockRepository = new Mock <IEntityRepository <Poem> >();

            mockRepository.Setup(r => r.List(It.IsAny <ListPoemsByTitleSpec>()))
            .Returns(poemList);

            //Act
            var service    = new ListPoemsService(mockRepository.Object);
            var testResult = service.ListPoemsByTitle();

            //Assert
            var expectResult = poemList.Select(p => PoemDTO.CreateDTOFromEntity(p));

            Assert.Equal(expectResult.Count(), testResult.Count());
        }
Esempio n. 2
0
        public void OnGet_VerifyPageIsReturnedAndPoemListIsSet()
        {
            //Arrange
            var poems       = new PoemBuilder().Default().BuildCollection(size: 3);
            var poemDTOList = poems.Select(p => PoemDTO.CreateDTOFromEntity(p));

            var mockService = new Mock <IListPoemsService>();

            mockService.Setup(s => s.ListPoemsByDate()).Returns(poemDTOList);

            //Act
            var listModel  = new ListPoemsByDateModel(mockService.Object);
            var testResult = listModel.OnGet();

            //Assert

            Assert.IsType <PageResult>(testResult);
            Assert.Equal(poemDTOList.Count(), listModel.Poems.Count());
        }
Esempio n. 3
0
        public void OnGet_ExistingPoems_VerifyPoemListIsNotEmpty()
        {
            //Arrange
            var poems       = new PoemBuilder().Default().BuildCollection(size: 3);
            var poemDTOList = poems.Select(p => PoemDTO.CreateDTOFromEntity(p));

            var mockService = new Mock <IListPoemsService>();

            mockService.Setup(s => s.ListByConceivedDate()).Returns(poemDTOList);

            //Act
            var listModel = new ListPoemsByConceivedDateModel(mockService.Object);

            listModel.OnGet();

            //Assert

            Assert.Equal(poemDTOList.Count(), listModel.Poems.Count());
        }