Exemplo 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();
        }
Exemplo n.º 2
0
        public void shouldBeAbleToViewPage()
        {
            var controller = new CarbonFitness.App.Web.Controllers.AdminController(null, null, null, null);

            ViewResult result = (ViewResult)controller.DBInit();
            Assert.That(result, Is.Not.Null);

            var model = (InputDbInitModel) result.ViewData.Model;
            Assert.That(model.ImportFilePath, Is.EqualTo("~/App_data/Ingredients.csv"));
        }