Пример #1
0
        public void WebApiConfigClassIsDefined()
        {
            var webApiConfigClass = IssueTrackerAssembly
                                    .ShouldHaveType("IssueTracker.WebApiConfig")
                                    .ThatIsPublic()
                                    .AndStatic();

            var registerMethod = webApiConfigClass
                                 .ShouldHaveMethod(
                "Register",
                new[] { new Parameter(typeof(HttpConfiguration), "config") },
                validateParameterNames: true)
                                 .ThatIsPublic()
                                 .AndStatic()
                                 .AndReturnsVoid();
        }
Пример #2
0
        public void ApplicationStartMethodCallsTheGlobalConfigurationConfigureMethod()
        {
            var webApiApplicationClass = IssueTrackerAssembly
                                         .ShouldHaveType("IssueTracker.WebApiApplication")
                                         .ThatIsPublic()
                                         .AndNonStatic()
                                         .AndInheritsFrom(typeof(System.Web.HttpApplication));

            var applicationStartMethod = webApiApplicationClass
                                         .ShouldHaveMethod("Application_Start")
                                         .ThatIsProtected()
                                         .AndNonStatic()
                                         .AndReturnsVoid();

            FileContains(ProjectPath + "Global.asax.cs",
                         @"protected\s+void\s+Application_Start\s*\(\s*\)\s*\{\s*GlobalConfiguration\.Configure\s*\(\s*WebApiConfig\.Register\s*\)\s*;\s*\}",
                         "In the 'WebApiApplication.Application_Start' method, are you making a call to the 'GlobalConfiguration.Configure' method and passing a reference to the 'WebApiConfig.Register' method?");
        }