Esempio n. 1
0
        async STT.Task WriteConfigurationSucceeds(string expected, AC.Configuration conf)
        {
            using var fakeFile = new ATF.FakeFile(string.Empty, string.Empty);
            await Utility.FromOk(_effect.WriteConfiguration(conf, fakeFile.Mock.Object)).ConfigureAwait(false);

            Assert.Equal(expected, new S.Text.UTF8Encoding().GetString(fakeFile.MemoryStream.ToArray()));
        }
Esempio n. 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;
 }
Esempio n. 3
0
        void WriteConfigurationSerializationError()
        {
            using var fakeFile = new ATF.FakeFile(string.Empty, string.Empty);
            var mockConfiguration = new M.Mock <AC.Configuration>(new AC.BindingDictionary());

            mockConfiguration.Setup(c => c.Serialize(M.It.IsAny <SIO.TextWriter>())).Throws(SerializerException.Failure(string.Empty, new S.Exception()));
            Assert.IsType <SerializerException>(Utility.FromError(_effect.WriteConfiguration(mockConfiguration.Object, fakeFile.Mock.Object)));
        }
Esempio n. 4
0
        public async STT.Task DisplayMessageTest(S.Exception exception, string message)
        {
            using var fakeFileDisposable = new ATF.FakeFile(string.Empty, string.Empty);
            var fakeFile = fakeFileDisposable.Mock.Object;

            using var env = new ATF.FakeEnvironment(fakeFile, Enumerable.Empty <string>(), fakeFile, new M.Mock <IEffect>().Object, string.Empty, string.Empty);
            await exception.DisplayMessage(ST.Factory.Maybe(env.Mock.Object)).ConfigureAwait(false);

            Assert.Equal(message, env.StreamError.ToString().Trim());
        }
Esempio n. 5
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());
 }
Esempio n. 6
0
 void WriteConfigurationWriteError()
 {
     using var fakeFile = new ATF.FakeFile(string.Empty, string.Empty);
     fakeFile.Mock.Setup(file => file.CreateStream()).Throws(TerminalFileException.WriteErrorMap(string.Empty)(new S.Exception()));
     Assert.IsType <TerminalFileException>(Utility.FromError(_effect.WriteConfiguration(ATF.Sample.Configuration, fakeFile.Mock.Object)));
 }