Ejemplo n.º 1
0
        public void shouldInitDatabase()
        {
            var expectedPath = "~/App_Data/Ingredients.csv";

            var schemaExportEngineMock = new Mock<ISchemaExportEngine>();
            schemaExportEngineMock.Setup(x => x.Export());

            var pathfinderMock = new Mock<IPathFinder>();
            pathfinderMock.Setup(x => x.GetPath(expectedPath)).Returns(@"c:\/App_Data/Ingredients.csv");

            var initialDataValuesExportEngine = new Mock<IInitialDataValuesExportEngine>();
            initialDataValuesExportEngine.Setup(x => x.Export());

            var ingredientImporterEngineMock = new Mock<IIngredientImporterEngine>();
            ingredientImporterEngineMock.Setup(x => x.Import(It.Is<String>(y=>y.EndsWith("/App_Data/Ingredients.csv") && y.StartsWith("c:\\") )));

            var nutrientRecommendationImporterMock = new Mock<INutrientRecommendationImporter>();
            nutrientRecommendationImporterMock.Setup(x => x.Import());

            var controller = new CarbonFitness.App.Web.Controllers.AdminController(schemaExportEngineMock.Object,nutrientRecommendationImporterMock.Object, ingredientImporterEngineMock.Object, initialDataValuesExportEngine.Object, pathfinderMock.Object);

            InputDbInitModel model = new InputDbInitModel { ImportFilePath = expectedPath };

            ActionResult result = controller.DBInit(model);

            pathfinderMock.VerifyAll();
            schemaExportEngineMock.VerifyAll();
            ingredientImporterEngineMock.VerifyAll();
            initialDataValuesExportEngine.VerifyAll();
            nutrientRecommendationImporterMock.VerifyAll();
        }
Ejemplo n.º 2
0
        public ActionResult DBInit(InputDbInitModel model)
        {
            schemaExportEngine.Export();

            initialDataValuesExportEngine.Export();

            ingredientImporterEngine.Import(PathFinder.GetPath(model.ImportFilePath));

            nutrientRecommendationImporter.Import();

            return View(model);
        }