예제 #1
0
 public void TryGetConfigurationReadError()
 {
     using var fakeTextFile = new ATF.FakeTextFile("alias.conf", string.Empty, string.Empty);
     fakeTextFile.Mock.Setup(file => file.OpenAsync(M.It.IsAny <SIO.FileMode>(), M.It.IsAny <SIO.FileAccess>(), M.It.IsAny <SIO.FileShare>()))
     .Throws(new SIO.IOException());
     Assert.IsType <TerminalFileException>(Utility.FromError(_effect.TryGetConfiguration(fakeTextFile.Mock.Object)));
 }
예제 #2
0
 public OperationTests()
 {
     _mockEffect = new M.Mock <IEffect>();
     _fakeApp    = new ATF.FakeFile(@"Application Name", @"Application Directory");
     _fakeConf   = new ATF.FakeTextFile(string.Empty, string.Empty, string.Empty);
     _fakeEnv    = new ATF.FakeEnvironment(_fakeApp.Mock.Object, Enumerable.Empty <string>(), _fakeConf.Mock.Object, _mockEffect.Object, @"Working Directory", string.Empty);
     _mockEnv    = _fakeEnv.Mock;
 }
예제 #3
0
        public STT.Task TryGetConfigurationDeserializationError(string input)
        {
            var fakeTextFile = new ATF.FakeTextFile("alias.conf", string.Empty, input);

            return(Utility.FromOk(_effect.TryGetConfiguration(fakeTextFile.Mock.Object))
                   .ContinueWith(task => {
                fakeTextFile.Dispose();
                Assert.Equal(STT.TaskStatus.Faulted, task.Status);
                Assert.IsType <DeserialException>(task.Exception.InnerException);
            }));
        }
예제 #4
0
 public async STT.Task EntryTest(ExitCode expectedExitCode, string expectedOut, string expectedError, string configuration, string name, Arguments arguments)
 {
     using var fake = new ATF.FakeTextFile
                          (@"alias.conf"
                          , @"directory"
                          , configuration
                          );
     using var fakeFileDisposable = new ATF.FakeFile(name, string.Empty);
     using var environment        = new ATF.FakeEnvironment(fakeFileDisposable.Mock.Object, arguments, fake.Mock.Object, new Effect(), S.Environment.CurrentDirectory, string.Empty);
     Assert.Equal(expectedExitCode, await Program.Entry(() => environment.Mock.Object).ConfigureAwait(false));
     Assert.Equal(expectedOut, environment.StreamOut.ToString());
     Assert.Equal(expectedError, environment.StreamError.ToString());
 }
예제 #5
0
 public async STT.Task TryGetConfigurationSucceeds(AC.Configuration?expected, string input)
 {
     using var fakeTextFile = new ATF.FakeTextFile("alias.conf", string.Empty, input);
     Assert.Equal(expected.ToMaybe(), await Utility.FromOk(_effect.TryGetConfiguration(fakeTextFile.Mock.Object)).ConfigureAwait(false));
 }