예제 #1
0
        public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue()
        {
            // Arrange
            var mockEpisodePeopleRepository = EpisodePeopleMockingSetup.DoMockingSetupForRepository();

            mockEpisodePeopleRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null);
            var businessWorkflow = new EpisodePeopleBusinessWorkflow(mockEpisodePeopleRepository.Object, new EpisodePersonMapper());
            // Act
            var result = businessWorkflow.Remove("DOESNT-EXIST");

            // Assert
            Assert.Equal(true, result);
        }
예제 #2
0
        public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue()
        {
            // Arrange
            var mockEpisodePeopleRepository = EpisodePeopleMockingSetup.DoMockingSetupForRepository();
            var mockEpisodePeopleMapper     = new Mock <IEpisodePersonMapper>();

            mockEpisodePeopleMapper.Setup(m => m.AreEqual(It.IsAny <IEpisodePersonModel>(), It.IsAny <IEpisodePerson>())).Returns(() => true);
            var businessWorkflow = new EpisodePeopleBusinessWorkflow(mockEpisodePeopleRepository.Object, mockEpisodePeopleMapper.Object);

            mockEpisodePeopleRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <IEpisodePerson>().Object);
            mockEpisodePeopleRepository.Setup(m => m.SaveChanges()).Returns(() => true);
            // Act
            var result = businessWorkflow.Remove("KING-STEPHEN");

            // Assert
            mockEpisodePeopleRepository.Verify(m => m.Remove(It.IsAny <IEpisodePerson>()), Times.Once);
            Assert.Equal(true, result);
        }
 public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue()
 {
     // Arrange
     var mockEpisodePeopleRepository = EpisodePeopleMockingSetup.DoMockingSetupForRepository();
     var mockEpisodePeopleMapper = new Mock<IEpisodePersonMapper>();
     mockEpisodePeopleMapper.Setup(m => m.AreEqual(It.IsAny<IEpisodePersonModel>(), It.IsAny<IEpisodePerson>())).Returns(() => true);
     var businessWorkflow = new EpisodePeopleBusinessWorkflow(mockEpisodePeopleRepository.Object, mockEpisodePeopleMapper.Object);
     mockEpisodePeopleRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => new Mock<IEpisodePerson>().Object);
     mockEpisodePeopleRepository.Setup(m => m.SaveChanges()).Returns(() => true);
     // Act
     var result = businessWorkflow.Remove("KING-STEPHEN");
     // Assert
     mockEpisodePeopleRepository.Verify(m => m.Remove(It.IsAny<IEpisodePerson>()), Times.Once);
     Assert.Equal(true, result);
 }
 public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue()
 {
     // Arrange
     var mockEpisodePeopleRepository = EpisodePeopleMockingSetup.DoMockingSetupForRepository();
     mockEpisodePeopleRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null);
     var businessWorkflow = new EpisodePeopleBusinessWorkflow(mockEpisodePeopleRepository.Object, new EpisodePersonMapper());
     // Act
     var result = businessWorkflow.Remove("DOESNT-EXIST");
     // Assert
     Assert.Equal(true, result);
 }