public void When_SettingRight_Should_NotChangeLeftData() { 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("left").SequenceEqual(item.Left)))).Verifiable(); var dataComparisonService = new DataComparisonService(repositoryMock.Object); dataComparisonService.SetRight(GetData("test data")); repositoryMock.VerifyAll(); }
public void When_SettingRight_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.SetRight(GetData("test data"))); }