コード例 #1
0
        public static void SyncBranchResourceFiles()
        {
            var proc = new SyncProcessor(new DefaultResxLoader());
            proc.LoadConfiguration();

            proc.Run(stopOnFirstError: false);
        }
        public void TestLoadingConfiguration()
        {
            var mockLoader = new Mock<IResxLoader>();

            var languageData = new List<Language>
            {
                new Language { Culture = "de" },
                new Language { Culture = "es" },
            };
            var mockLanguages = new Mock<DbSet<Language>>();
            EfMoqHelpers.SetupIQueryable(mockLanguages, languageData);

            var branchData = new List<Branch>
            {
                new Branch { Id = 400 }
            };
            var mockBranches = new Mock<DbSet<Branch>>();
            EfMoqHelpers.SetupIQueryable(mockBranches, branchData);

            var branchResourceFiles = new List<BranchResourceFile>(); // empty list
            var mockBranchResourceFiles = new Mock<DbSet<BranchResourceFile>>();
            EfMoqHelpers.SetupIQueryable(mockBranchResourceFiles, branchResourceFiles);

            var mockContext = new Mock<RftContext>();
            mockContext.Setup(m => m.Languages).Returns(mockLanguages.Object);
            mockContext.Setup(m => m.Branches).Returns(mockBranches.Object);
            mockContext.Setup(m => m.BranchResourceFiles).Returns(mockBranchResourceFiles.Object);

            var p = new SyncProcessor(mockLoader.Object, mockContext.Object);
            p.LoadConfiguration();

            Assert.That(p.Languages, Is.Not.Null);
            Assert.That(p.Languages.Count, Is.EqualTo(2));

            Assert.That(p.Branches, Is.Not.Null);
            Assert.That(p.Branches.Count, Is.EqualTo(1));
        }
        public void TestOnEmptyDatabase()
        {
            var mockLoader = new Mock<IResxLoader>();

            var languageData = new List<Language>();
            var mockLanguages = new Mock<DbSet<Language>>();
            EfMoqHelpers.SetupIQueryable(mockLanguages, languageData);

            var branchData = new List<Branch>();
            var mockBranches = new Mock<DbSet<Branch>>();
            EfMoqHelpers.SetupIQueryable(mockBranches, branchData);

            var branchResourceFiles = new List<BranchResourceFile>();
            var mockBranchResourceFiles = new Mock<DbSet<BranchResourceFile>>();
            EfMoqHelpers.SetupIQueryable(mockBranchResourceFiles, branchResourceFiles);

            var mockContext = new Mock<RftContext>();
            mockContext.Setup(m => m.Languages).Returns(mockLanguages.Object);
            mockContext.Setup(m => m.Branches).Returns(mockBranches.Object);
            mockContext.Setup(m => m.BranchResourceFiles).Returns(mockBranchResourceFiles.Object);

            var p = new SyncProcessor(mockLoader.Object, mockContext.Object);
            p.LoadConfiguration();
            bool result = p.Run(true);

            Assert.That(result, Is.True);
            Assert.That(p.Branches.Count, Is.EqualTo(0));
        }