예제 #1
0
        public async STT.Task ListTest()
        {
            var mock   = new M.Mock <IOperation>();
            var option = new AO.List();

            mock.Setup(op => op.List(M.It.IsAny <AO.List>())).Returns(A.Utility.TaskExitSuccess);
            Assert.Equal(ExitCode.Success, await AT.Utility.FromOk(option.Operate(mock.Object)).ConfigureAwait(false));
            mock.Verify(op => op.List(option));
        }
예제 #2
0
        public STT.Task ListFailTest()
        {
            var mock  = new M.Mock <SIO.TextWriter>();
            var inner = new SIO.IOException();

            mock.Setup(stream => stream.WriteLineAsync(M.It.IsAny <string>())).Throws(inner);
            _mockEnv.Setup(env => env.StreamOut).Returns(mock.Object);
            var environment = _mockEnv.Object;
            var option      = new AO.List();

            return(Utility.FromOk(Operation(environment).List(option))
                   .ContinueWith(task => {
                Assert.Equal(STT.TaskStatus.Faulted, task.Status);
                var error = (ListOperationException)task.Exception.InnerExceptions.Single();
                Assert.Equal(option, error.Option);
                Assert.Equal(inner, ((S.AggregateException)error.InnerException).InnerExceptions.Single());
            }));
        }
예제 #3
0
 /**
  * <summary>
  * Print alias assignments as specified by options to <see cref='Environment.StreamOut'/>.
  * </summary>
  * <param name="options">List specifications.</param>
  * <returns>Possible task yielding exit code.</returns>
  * <exception cref='ListOperationException'>List command fails.</exception>
  */
 public virtual ST.Result <STT.Task <ExitCode> > List(AO.List options)
 => ListAsync().SelectErrorAsync(ListOperationException.OutputFailureMap(options));