public void Verify_Deactivate_ByID_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
 {
     // Arrange
     var mockEpisodePeopleRepository = EpisodePeopleMockingSetup.DoMockingSetupForRepository();
     mockEpisodePeopleRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => null);
     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);
     // Act/Assert
     Assert.Throws<System.InvalidOperationException>(() => businessWorkflow.Deactivate(1));
 }
コード例 #2
0
        public void Verify_Deactivate_ByKey_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
        {
            // Arrange
            var mockEpisodePeopleRepository = EpisodePeopleMockingSetup.DoMockingSetupForRepository();

            mockEpisodePeopleRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null);
            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);

            // Act/Assert
            Assert.Throws <System.InvalidOperationException>(() => businessWorkflow.Deactivate("TEST"));
        }
コード例 #3
0
        public void Verify_Deactivate_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.Deactivate("KING-STEPHEN");

            // Assert
            mockEpisodePeopleRepository.Verify(m => m.Deactivate(It.IsAny <IEpisodePerson>()), Times.Once);
            Assert.Equal(true, result);
        }
 public void Verify_Deactivate_ByID_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<int>())).Returns(() => new Mock<IEpisodePerson>().Object);
     mockEpisodePeopleRepository.Setup(m => m.SaveChanges()).Returns(() => true);
     // Act
     var result = businessWorkflow.Deactivate(1);
     // Assert
     mockEpisodePeopleRepository.Verify(m => m.Deactivate(It.IsAny<IEpisodePerson>()), Times.Once);
     Assert.Equal(true, result);
 }