public void InvokingExecuteCallsComparisonServiceWithJpgFilesFromSuppliedPath() { IImageComparison mockImageComparison = MockRepository.GenerateMock<IImageComparison>(); IMainWindowViewModel mockMainWindowViewModel = MockRepository.GenerateMock<IMainWindowViewModel>(); mockImageComparison .Expect(mock => mock .Compare(Arg<ReadOnlyCollection<FileInfo>> .Matches(coll => (coll.Count == 7) && (coll[0].Name == "TestFileA.jpg") ) ) ) .Return(null); BeginScanCommand sut = new BeginScanCommand(mockImageComparison, mockMainWindowViewModel); sut.Execute(Path.GetFullPath(@".\TestImages")); mockImageComparison.VerifyAllExpectations(); }
public void InvokingExecuteSetsResultValueOnViewModel() { IImageComparison mockImageComparison = MockRepository.GenerateMock<IImageComparison>(); mockImageComparison.Expect( mock => mock.Compare( Arg<ReadOnlyCollection<FileInfo>>.Matches(coll => (coll.Count == 7) && (coll[0].Name == "TestFileA.jpg")))) .Return( new Dictionary<FileInfo, ReadOnlyCollection<FileInfo>> { { new FileInfo(@".\TestImages\TestFileA.jpg"), new ReadOnlyCollection<FileInfo>( new List<FileInfo> { new FileInfo(@".\TestImages\TestFileA.jpg") } ) } } ); IMainWindowViewModel mockMainWindowViewModel = MockRepository.GenerateMock<IMainWindowViewModel>(); BeginScanCommand sut = new BeginScanCommand(mockImageComparison, mockMainWindowViewModel); sut.Execute(Path.GetFullPath(@".\TestImages")); mockMainWindowViewModel.AssertWasCalled( vm => vm.DisplayList = Arg<List<SourceImageFile>>.Matches(list => list.Count == 1)); }
public void InvokingExecuteWithNullParameterViolatesConstraint() { IImageComparison mockImageComparison = MockRepository.GenerateMock<IImageComparison>(); IMainWindowViewModel mockMainWindowViewModel = MockRepository.GenerateMock<IMainWindowViewModel>(); BeginScanCommand sut = new BeginScanCommand(mockImageComparison, mockMainWindowViewModel); XUnitHelper.ViolatesConstraint(() => sut.Execute(null), "parameter != null"); }