Пример #1
0
        public async Task ScriptProvidedOutputPath()
        {
            // Setup:
            // ... Create a session with a proper query and metadata
            EditSession s = await GetBasicSession();

            // ... Add two mock edits that will generate a script
            Mock <RowEditBase> edit = new Mock <RowEditBase>();

            edit.Setup(e => e.GetScript()).Returns("test");
            s.EditCache[0] = edit.Object;
            s.EditCache[1] = edit.Object;

            using (SelfCleaningTempFile file = new SelfCleaningTempFile())
            {
                // If: I script the edit cache to a local output path
                string outputPath = s.ScriptEdits(file.FilePath);

                // Then:
                // ... The output path used should be the same as the one we provided
                Assert.Equal(file.FilePath, outputPath);

                // ... The written file should have two lines, one for each edit
                Assert.Equal(2, File.ReadAllLines(outputPath).Length);
            }
        }
Пример #2
0
        public async Task ScriptNullOrEmptyOutput(string outputPath)
        {
            // Setup: Create a session with a proper query and metadata
            EditSession s = await GetBasicSession();

            // If: I try to script the edit cache with a null or whitespace output path
            // Then: It should throw an exception
            Assert.Throws <ArgumentNullException>(() => s.ScriptEdits(outputPath));
        }
Пример #3
0
        public void ScriptEditsNotInitialized()
        {
            // Setup:
            // ... Create a session without initializing
            Mock <IEditMetadataFactory> emf = new Mock <IEditMetadataFactory>();
            EditSession s = new EditSession(emf.Object);

            // If: I ask to script edits without initializing
            // Then: I should get an exception
            Assert.Throws <InvalidOperationException>(() => s.ScriptEdits(string.Empty));
        }