Exemple #1
0
        public void Verify_Get_ByKey_Should_ReturnTheCorrectObjectAppearedInIssue()
        {
            // Arrange
            Mock <IDbSet <ObjectAppearedInIssue> > mockSetObjectAppearedInIssues;
            var mockContext = ObjectAppearedInIssuesMockingSetup.DoMockingSetupForContext(true, out mockSetObjectAppearedInIssues);
            var repository  = new ObjectAppearedInIssuesRepository(mockContext.Object);
            // Act
            var objectAppearedInIssues = repository.Get("KING-STEPHEN");

            // Assert
            Assert.Equal("/TEST/KING-STEPHEN", objectAppearedInIssues.ApiDetailUrl);
        }
Exemple #2
0
        public void Verify_Deactivate_Should_SetTheActivePropertyToFalseOnTheEntity()
        {
            // Arrange
            Mock <IDbSet <ObjectAppearedInIssue> > mockSetObjectAppearedInIssues;
            var mockContext            = ObjectAppearedInIssuesMockingSetup.DoMockingSetupForContext(true, out mockSetObjectAppearedInIssues);
            var repository             = new ObjectAppearedInIssuesRepository(mockContext.Object);
            var objectAppearedInIssues = repository.Get(1);

            // Act
            repository.Deactivate(objectAppearedInIssues);
            // Assert
            Assert.Equal(false, objectAppearedInIssues.Active);
        }
Exemple #3
0
        public void Verify_Remove_Should_RemoveTheEntityFromTheContext()
        {
            // Arrange
            Mock <IDbSet <ObjectAppearedInIssue> > mockSetObjectAppearedInIssues;
            var mockContext            = ObjectAppearedInIssuesMockingSetup.DoMockingSetupForContext(true, out mockSetObjectAppearedInIssues);
            var repository             = new ObjectAppearedInIssuesRepository(mockContext.Object);
            var objectAppearedInIssues = repository.Get(1);

            // Act
            repository.Remove(objectAppearedInIssues);
            // Assert
            mockSetObjectAppearedInIssues.Verify(x => x.Remove((ObjectAppearedInIssue)objectAppearedInIssues), Times.Once);
        }
Exemple #4
0
        public void Verify_Update_Should_SetTheEntityStateToModified()
        {
            // Arrange
            Mock <IDbSet <ObjectAppearedInIssue> > mockSetObjectAppearedInIssues;
            var mockContext            = ObjectAppearedInIssuesMockingSetup.DoMockingSetupForContext(true, out mockSetObjectAppearedInIssues);
            var repository             = new ObjectAppearedInIssuesRepository(mockContext.Object);
            var objectAppearedInIssues = repository.Get(1);

            objectAppearedInIssues.ApiDetailUrl = "/TEST";
            // Act
            repository.Update(objectAppearedInIssues);
            // Assert
            mockContext.Verify(x => x.SetModified(It.IsAny <object>()), Times.Once);
        }
Exemple #5
0
        public void Verify_Add_Should_AddTheEntityToTheContext()
        {
            // Arrange
            Mock <IDbSet <ObjectAppearedInIssue> > mockSetObjectAppearedInIssues;
            var mockContext            = ObjectAppearedInIssuesMockingSetup.DoMockingSetupForContext(false, out mockSetObjectAppearedInIssues);
            var repository             = new ObjectAppearedInIssuesRepository(mockContext.Object);
            var objectAppearedInIssues = new ObjectAppearedInIssue {
                Active = true, CustomKey = "SALVATORE-RAA",
            };

            // Act
            repository.Add(objectAppearedInIssues);
            // Assert
            mockSetObjectAppearedInIssues.Verify(x => x.Add(objectAppearedInIssues), Times.Once);
        }
Exemple #6
0
        public void Verify_Search_WithSelectStatement_Should_ReturnAListOfDynamicObjects()
        {
            // Arrange
            Mock <IDbSet <ObjectAppearedInIssue> > mockSetObjectAppearedInIssues;
            var mockContext = ObjectAppearedInIssuesMockingSetup.DoMockingSetupForContext(true, out mockSetObjectAppearedInIssues, true);
            var repository  = new ObjectAppearedInIssuesRepository(mockContext.Object);
            var searchModel = new Mock <IObjectAppearedInIssueSearchModel>();
            // Act
            var objectAppearedInIssues = repository.Search(searchModel.Object, i => new { i.Id, MyApiDetailUrl = i.ApiDetailUrl }).ToArray();

            // Assert
            Assert.Equal(1, objectAppearedInIssues.Length);
            Assert.Equal(2, objectAppearedInIssues[0].Id);
            Assert.Equal("/TEST/NIVEN-LARRY", objectAppearedInIssues[0].MyApiDetailUrl);
            // Stephen King was filtered out because he was Inactive
        }
Exemple #7
0
        public void Verify_List_Should_ReturnAListOfObjectAppearedInIssuesWithData()
        {
            // Arrange
            Mock <IDbSet <ObjectAppearedInIssue> > mockSetObjectAppearedInIssues;
            var mockContext = ObjectAppearedInIssuesMockingSetup.DoMockingSetupForContext(true, out mockSetObjectAppearedInIssues);
            var repository  = new ObjectAppearedInIssuesRepository(mockContext.Object);
            // Act
            var objectAppearedInIssues = repository.List.ToArray();

            // Assert
            Assert.Equal(2, objectAppearedInIssues.Length);
            Assert.Equal(1, objectAppearedInIssues[0].Id);
            Assert.Equal("/TEST/KING-STEPHEN", objectAppearedInIssues[0].ApiDetailUrl);
            Assert.Equal(2, objectAppearedInIssues[1].Id);
            Assert.Equal("/TEST/NIVEN-LARRY", objectAppearedInIssues[1].ApiDetailUrl);
        }
Exemple #8
0
        public void Verify_Search_WithPaging_Should_ReturnAListOfObjectAppearedInIssuesWithDataMatchingSearchParameters()
        {
            // Arrange
            Mock <IDbSet <ObjectAppearedInIssue> > mockSetObjectAppearedInIssues;
            var mockContext = ObjectAppearedInIssuesMockingSetup.DoMockingSetupForContext(true, out mockSetObjectAppearedInIssues);
            var repository  = new ObjectAppearedInIssuesRepository(mockContext.Object);
            var searchModel = new ObjectAppearedInIssueSearchModel {
                Paging = new Paging {
                    Skip = 1, Take = 1
                }
            };
            // Act
            var objectAppearedInIssues = repository.Search(searchModel /*.Object*/).ToArray();

            // Assert
            Assert.Equal(1, objectAppearedInIssues.Length);
            Assert.Equal(2, objectAppearedInIssues[0].Id);
            Assert.Equal("/TEST/NIVEN-LARRY", objectAppearedInIssues[0].ApiDetailUrl);
            // Stephen King was filtered out because he was Skipped
        }
Exemple #9
0
        public void Verify_Search_WithModifiedSince_Should_ReturnAListOfObjectAppearedInIssuesWithDataMatchingSearchParameters()
        {
            // Arrange
            Mock <IDbSet <ObjectAppearedInIssue> > mockSetObjectAppearedInIssues;
            var mockContext = ObjectAppearedInIssuesMockingSetup.DoMockingSetupForContext(true, out mockSetObjectAppearedInIssues, true);
            var repository  = new ObjectAppearedInIssuesRepository(mockContext.Object);
            var createDate  = new System.DateTime(2015, 05, 28, 10, 45, 00).AddDays(1).AddMinutes(-1);
            //var searchModel = new Mock<IObjectAppearedInIssueSearchModel>();
            //searchModel.Setup(m => m.ModifiedSince).Returns(() => createDate);
            var searchModel = new ObjectAppearedInIssueSearchModel {
                ModifiedSince = createDate
            };
            // Act
            var objectAppearedInIssues = repository.Search(searchModel /*.Object*/).ToArray();

            // Assert
            Assert.Equal(1, objectAppearedInIssues.Length);
            Assert.Equal(2, objectAppearedInIssues[0].Id);
            Assert.Equal("/TEST/NIVEN-LARRY", objectAppearedInIssues[0].ApiDetailUrl);
            // Stephen King was filtered out because he was created before the modified since date
        }