Пример #1
0
        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));
        }
        private Mock <RftContext> GetSingleBranchSingleLanguageNoResourcesContextMock()
        {
            var languageData = new List <Language>
            {
                new Language {
                    Culture = "de"
                },
            };
            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>()
            {
                new BranchResourceFile()
                {
                    FK_BranchId         = 400,
                    FK_ResourceFileId   = 4711,
                    SyncRawPathAbsolute = "gohere"
                }
            };
            var mockBranchResourceFiles = new Mock <DbSet <BranchResourceFile> >();

            EfMoqHelpers.SetupIQueryable(mockBranchResourceFiles, branchResourceFiles);

            var resourceStrings     = new List <ResourceString>();
            var mockResourceStrings = new Mock <DbSet <ResourceString> >();

            EfMoqHelpers.SetupIQueryable(mockResourceStrings, resourceStrings);

            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);
            mockContext.Setup(m => m.ResourceStrings).Returns(mockResourceStrings.Object);

            return(mockContext);
        }
Пример #3
0
        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));
        }