Пример #1
0
        public void Load()
        {
            var loader = new MigrationFilesLoader();

            var fileProviderMock = new Mock <IFileProvider>();

            var files = new TestableIDirectoryContents(Array.Empty <IFileInfo>());

            fileProviderMock.Setup(x => x.GetDirectoryContents(It.IsAny <string>())).Returns(() => files);

            var migrations = loader.Load(new List <IFileProvider> {
                fileProviderMock.Object
            }, "*.sql");

            Assert.NotNull(migrations);
            Assert.Empty(migrations);
        }
Пример #2
0
        public void Load_one_file_with_invalid_name_throws()
        {
            var loader = new MigrationFilesLoader();

            var fileProviderMock = new Mock <IFileProvider>();

            var files = new TestableIDirectoryContents(new IFileInfo[] { new TestableFileInfo("create table.sql", "some sql", false) });

            fileProviderMock.Setup(x => x.GetDirectoryContents(It.IsAny <string>())).Returns(() => files);

            Assert.Throws <InvalidOperationException>(() =>
            {
                var migrations = loader.Load(new List <IFileProvider> {
                    fileProviderMock.Object
                }, "*.sql");
                Assert.NotNull(migrations);
                Assert.NotEmpty(migrations);
            });
        }
Пример #3
0
        public void Load_one_file_with_valid_name_file_loaded()
        {
            var loader = new MigrationFilesLoader();

            var fileProviderMock = new Mock <IFileProvider>();

            var files = new TestableIDirectoryContents(new IFileInfo[] { new TestableFileInfo("2014010101 - create table.sql", "some sql", false) });

            fileProviderMock.Setup(x => x.GetDirectoryContents(It.IsAny <string>())).Returns(() => files);

            var migrations = loader.Load(new List <IFileProvider> {
                fileProviderMock.Object
            }, "*.sql");

            Assert.NotNull(migrations);
            Assert.NotEmpty(migrations);

            var migrationInfo = migrations.First();

            Assert.NotEmpty(migrationInfo.Data);
        }