public void When_SettingLeft_And_ComparisonItemIsNotFound_Should_ThrowInvalidOpException() { var repositoryMock = new Mock<IDataComparisonRepository>(MockBehavior.Strict); repositoryMock.Setup(x => x.Get()).Returns<DataComparisonItem>(null); var dataComparisonService = new DataComparisonService(repositoryMock.Object); Assert.Throws<InvalidOperationException>(() => dataComparisonService.SetLeft(GetData("test data"))); }
public void When_SettingLeft_Should_NotChangeRightData() { var comparisonItem = new DataComparisonItem(GetData("left"), GetData("right")); var repositoryMock = new Mock<IDataComparisonRepository>(MockBehavior.Strict); repositoryMock.Setup(x => x.Get()).Returns(comparisonItem).Verifiable(); repositoryMock.Setup(x => x.Save(It.Is<DataComparisonItem>(item => GetData("right").SequenceEqual(item.Right)))).Verifiable(); var dataComparisonService = new DataComparisonService(repositoryMock.Object); dataComparisonService.SetLeft(GetData("test data")); repositoryMock.VerifyAll(); }