public async Task TestFilesRemoving() { var operationsFactoryMock = new Mock <IOperationsFactory>(); var operationMock = new Mock <IOperation>(); operationMock .Setup(m => m.RunAsync(It.IsAny <CancellationToken>())) .Verifiable(); operationsFactoryMock .Setup(m => m.CreateDeleteFileOperation(It.IsAny <IList <UnaryFileOperationSettings> >())) .Callback <IList <UnaryFileOperationSettings> >(l => { Assert.Equal(FileName, l.Single().FilePath); }) .Returns(operationMock.Object); var directoryServiceMock = new Mock <IDirectoryService>(); var fileOpeningServiceMock = new Mock <IFileOpeningService>(); var fileServiceMock = new Mock <IFileService>(); var pathServiceMock = new Mock <IPathService>(); IOperationsService operationsService = new OperationsService( operationsFactoryMock.Object, directoryServiceMock.Object, fileOpeningServiceMock.Object, fileServiceMock.Object, pathServiceMock.Object); await operationsService.RemoveFilesAsync(new[] { FileName }); operationMock.Verify(m => m.RunAsync(It.IsAny <CancellationToken>()), Times.Once()); }