pszczyg

Unit testing Cmdlet-derived classes

May 6th, 2021
531
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     [Test]
  2.         public void Exemplary_Cmdlet_Test() {
  3.  
  4.             var fileInteractorMock = new Mock<IFileInteractor>();
  5.             fileInteractorMock.Setup(m => m.CreateDirectory(null)).Throws<ArgumentNullException>();
  6.  
  7.             var logger = new SimpleLogger();
  8.  
  9.             var fileManager = new InvocationFileManager(logger, fileInteractorMock.Object);
  10.  
  11.             var parser = new InvokeCvApiParameterParser(fileInteractorMock.Object, fileManager, logger);
  12.  
  13.             var testBLContextProvider = new Mock<IContextProvider>();
  14.  
  15.             var cmdlet = new InvokeCVApiCommand(testBLContextProvider.Object, fileManager, logger, parser) {
  16.                 FunctionFilePath = "fakePath",
  17.                 OutputFolder = "fakeOutputFolder"
  18.             };
  19.            
  20.             var results = cmdlet.Invoke().OfType<string>().ToList();
  21.             Assert.That(results[0] == "success");
  22.         }
RAW Paste Data