Esempio n. 1
0
        public void RunStarted_creates_valid_context_name_if_safeitemname_is_not_valid_identifier()
        {
            var mockVsUtils = new Mock <IVsUtils>();
            var wizard      = new OneEFWizard(vsUtils: mockVsUtils.Object);

            var mockCodeGenerator = new Mock <CodeFirstModelGenerator>(MockDTE.CreateProject());

            mockCodeGenerator
            .Setup(g => g.Generate(It.IsAny <DbModel>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new[] { new KeyValuePair <string, string>(string.Empty, string.Empty) });

            var settings = new ModelBuilderSettings {
                VSApplicationType = VisualStudioProjectSystem.WebApplication
            };
            var replacenentsDictionary = new Dictionary <string, string>
            {
                { "$safeitemname$", "3My.Con text" },
                { "$rootnamespace$", "Project" }
            };

            wizard.RunStarted(settings, mockCodeGenerator.Object, replacenentsDictionary);

            mockCodeGenerator.Verify(
                g => g.Generate(
                    It.IsAny <DbModel>(),
                    "Project",
                    /*contextClassName*/ "_3MyContext",
                    /*connectionStringName*/ "_3MyContext"),
                Times.Once());
        }
        public void RunStarted_creates_valid_context_name_if_safeitemname_is_not_valid_identifier()
        {
            var mockVsUtils = new Mock<IVsUtils>();
            var wizard = new OneEFWizard(vsUtils: mockVsUtils.Object);

            var mockCodeGenerator = new Mock<CodeFirstModelGenerator>(MockDTE.CreateProject());
            mockCodeGenerator
                .Setup(g => g.Generate(It.IsAny<DbModel>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
                .Returns(new[] { new KeyValuePair<string, string>(string.Empty, string.Empty) });

            var settings = new ModelBuilderSettings { VSApplicationType = VisualStudioProjectSystem.WebApplication };
            var replacenentsDictionary = new Dictionary<string, string>
            {
                { "$safeitemname$", "3My.Con text" },
                { "$rootnamespace$", "Project" }
            };

            wizard.RunStarted(settings, mockCodeGenerator.Object, replacenentsDictionary);

            mockCodeGenerator.Verify(
                g => g.Generate(
                    It.IsAny<DbModel>(), 
                    "Project",
                    /*contextClassName*/ "_3MyContext",
                    /*connectionStringName*/ "_3MyContext"),
                Times.Once());
        }