protected virtual Action <OnCreatingContext <TObjectType, TDefinitionType> > CreateOnProvisionedHook <TObjectType, TDefinitionType>()
            where TDefinitionType : DefinitionBase
        {
            return(new Action <OnCreatingContext <TObjectType, TDefinitionType> >(context =>
            {
                var id = context.GetType().GetGenericArguments()[0].AssemblyQualifiedName + ":" + context.ObjectDefinition.GetHashCode();
                var hook = _hookMap[id];

                hook.OnProvisioned = true;

                var farmDef = context.ObjectDefinition as FarmSolutionDefinition;

                if (farmDef != null && farmDef.ShouldDelete == true)
                {
                    // by passing checking the object within onb provisioed event
                    // farm solution is expected to be deleted
                }
                else
                {
                    if (context.Object == null)
                    {
                        Console.WriteLine("");
                    }

                    AssertService.IsNotNull(context.Object);
                    AssertService.IsNotNull(context.ObjectDefinition);

                    AssertService.IsNotNull(context.ModelHost);
                    AssertService.IsInstanceOfType(context.Object, typeof(TObjectType));
                }
            }));
        }
        protected void ResolveHook(EventHooks eventHooks, string start)
        {
            TraceUtils.WithScope(traceScope =>
            {
                if (eventHooks.OnProvisioning)
                {
                    if (!ShowOnlyFalseResults)
                    {
                        traceScope.WriteLine(string.Format("[INF]{0} [VALIDATED] - [OnProvisioning]", start));
                    }
                }
                else
                {
                    traceScope.WriteLine(string.Format("[ERR]{0} [MISSED] - [OnProvisioning]", start));
                }

                if (eventHooks.OnProvisioned)
                {
                    if (!ShowOnlyFalseResults)
                    {
                        traceScope.WriteLine(string.Format("[INF]{0} [VALIDATED] - [OnProvisioned]", start));
                    }
                }
                else
                {
                    traceScope.WriteLine(string.Format("[IERR]{0} [MISSED] - [OnProvisioned]", start));
                }

                AssertService.AreEqual(true, eventHooks.OnProvisioning);
                AssertService.AreEqual(true, eventHooks.OnProvisioned);
            });
        }
예제 #3
0
        public void TestModels(IEnumerable <ModelNode> models)
        {
            // force XML serialiation
            EnsureSerializationSupport(models);

            _hookMap.Clear();

            foreach (var model in models)
            {
                var allHooks = new List <EventHooks>();

                WithProvisionRunnerContext(runnerContext =>
                {
                    var runner = runnerContext.Runner;

                    var omModelType = GetRunnerType(runner);
                    var hooks       = GetHooks(model);

                    foreach (var hook in hooks)
                    {
                        hook.Tag = runner.Name;
                    }

                    allHooks.AddRange(hooks);

                    if (model.Value.GetType() == typeof(FarmDefinition))
                    {
                        runner.DeployFarmModel(model);
                    }
                    else if (model.Value.GetType() == typeof(WebApplicationDefinition))
                    {
                        runner.DeployWebApplicationModel(model);
                    }
                    else if (model.Value.GetType() == typeof(SiteDefinition))
                    {
                        runner.DeploySiteModel(model);
                    }
                    else if (model.Value.GetType() == typeof(WebDefinition))
                    {
                        runner.DeployWebModel(model);
                    }
                    else if (model.Value.GetType() == typeof(ListDefinition))
                    {
                        runner.DeployListModel(model);
                    }
                    else
                    {
                        throw new SPMeta2NotImplementedException(
                            string.Format("Runner does not support model of type: [{0}]", model.Value.GetType()));
                    }

                    if (this.EnableDefinitionValidation)
                    {
                        var hasMissedOrInvalidProps = ResolveModelValidation(model, hooks);
                        AssertService.IsFalse(hasMissedOrInvalidProps);
                    }
                });
            }
        }
        public void TestToDeleteProject()
        {
            RestRequest   GetRequest   = RequestFactory.ProjectRequest(_requestUrlUpdateProject, Method.DELETE, NewProject);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        statusCode   = RestResponse.StatusCode.ToString();

            AssertService.AreEqual(StatusCode.Accepted.ToString(), statusCode);
        }
예제 #5
0
        public void TestGetUserState()
        {
            RestRequest   GetRequest   = RequestFactory.UserRequest(_requestUrlGetUserState, Method.GET, _userId);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        state        = JsonDeserializer.ReturnJsonValue("state", RestResponse);;

            AssertService.AreEqual(state, _state);
        }
        public void TestUnarchiveProject()
        {
            RestRequest   GetRequest   = RequestFactory.ProjectRequest(_requestUrlUnarchived, Method.POST, _projectId);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        statusCode   = RestResponse.StatusCode.ToString();

            AssertService.AreEqual(StatusCode.Created.ToString(), statusCode);
        }
        public void TestDeleteBranch()
        {
            RestRequest   GetRequest   = RequestFactory.BranchRequest(_requestUrlDeleteBranch, Method.DELETE, _projectId, _newBranch);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        statusCode   = RestResponse.StatusCode.ToString();

            AssertService.AreEqual(StatusCode.NoContent.ToString(), statusCode.ToString());
        }
        public void TestGetNameSpaces()
        {
            RestRequest   GetRequest   = RequestFactory.CustomRequest(_requestUrlNamespaces, Method.GET);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        statusCode   = RestResponse.StatusCode.ToString();

            AssertService.AreEqual(StatusCode.Ok.ToString().ToUpper(), statusCode);
        }
        public void TestDeleteWikiPage()
        {
            RestRequest GetRequest = RequestFactory.ProjectRequest(_requestUrlWikiDelete, Method.DELETE, NewProject);

            GetRequest.AddUrlSegment("slug", _wikiTitle);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        statusCode   = RestResponse.StatusCode.ToString();

            AssertService.AreEqual(StatusCode.NoContent.ToString(), statusCode);
        }
        public void TestCreateWikiPage()
        {
            object json = WikiJsonBody.SetContent(_wikiContent).SetTitle(_wikiTitle).Build();

            RestRequest   GetRequest   = RequestFactory.ProjectRequestWithJson(_requestUrlWiki, Method.POST, NewProject, json);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        title        = JsonDeserializer.ReturnJsonValue("title", RestResponse);;

            AssertService.AreEqual(_wikiTitle, title);
        }
예제 #11
0
        public void TestAddEmailThatAlreadyExisted()
        {
            object json = UserJsonBodyBuilder.SetId(_userId).SetEmail(_email).Build();

            RestRequest   GetRequest   = RequestFactory.RequestWithJsonBody(_requestUrlEmails, Method.POST, json);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        message      = RegexMessage.RegexWarningMessage(JsonDeserializer.ReturnJsonValue("message", RestResponse));

            AssertService.AreEqual(_warningMessageExistedEmail, message);
        }
예제 #12
0
        public void TestUpdateUserStatusMessage()
        {
            object json = UserJsonBodyBuilder.SetMessage(_message).Build();

            RestRequest   GetRequest   = RequestFactory.RequestWithJsonBody(_requestUrlUserStatus, Method.PUT, json);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        message      = JsonDeserializer.ReturnJsonValue("message", RestResponse);;

            AssertService.AreEqual(_message, message);
        }
        public void TestRenameProject()
        {
            object json = ProjectJsonBody.SetDescription(_description).SetName(_newProjectName).Build();

            RestRequest   GetRequest   = RequestFactory.ProjectRequestWithJson(_requestUrlUpdateProject, Method.PUT, NewProject, json);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        name         = JsonDeserializer.ReturnJsonValue("name", RestResponse);;

            AssertService.AreEqual(_newProjectName, name);
        }
예제 #14
0
        public void TestArchiveProject()
        {
            RestRequest   GetRequest   = RequestFactory.ProjectRequest(_requestUrlArchived, Method.POST, _projectId);
            IRestResponse RestResponse = Client.Execute(GetRequest);

            _logger.Info($"Response {RestResponse.ResponseUri} received");
            string statusCode = RestResponse.StatusCode.ToString();

            AssertService.AssertEqual(StatusCode.Created.ToString(), statusCode);
        }
예제 #15
0
        public void TestAddFileWithAlreadyExistedName()
        {
            object json = new FileJsonBodyChield(_fileName, _branch, _content, _commitMessage);

            RestRequest   GetRequest   = RequestFactory.FileRequest(_requestUrlFile, Method.POST, _projectId, _fileName, json);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        message      = JsonDeserializer.ReturnJsonValue("message", RestResponse);;

            AssertService.AssertEqual(_errorMessageUploadFileWithExistedName, message);
        }
예제 #16
0
        private void UploadFileToRepo(string fileName, string branch, string content, string commit, Method method, string expectedStatusCode)
        {
            object json = new FileJsonBodyChield(fileName, branch, content, commit);

            RestRequest   GetRequest   = RequestFactory.FileRequest(_requestUrlFile, method, _projectId, fileName, json);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        statusCode   = RestResponse.StatusCode.ToString();

            AssertService.AssertEqual(statusCode, statusCode);
        }
예제 #17
0
        public void TestUploadFileWithoutSelectBrunch()
        {
            object json = new FileJsonBodyChield(_fileName, _commitMessage);

            RestRequest   GetRequest   = RequestFactory.FileRequest(_requestUrlFile, Method.POST, _projectId, _fileName, json);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        message      = JsonDeserializer.ReturnJsonValue("message", RestResponse);;

            AssertService.AreEqual(_errorMessageUploadFileIncorrectBrunch, message);
        }
예제 #18
0
        public void TestUploadFileWithoutCommitMessage()
        {
            object json = new FileJsonBody(_fileName, _branch);

            RestRequest   GetRequest   = RequestFactory.FileRequest(_requestUrlFile, Method.POST, _projectId, _fileName, json);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        error        = JsonDeserializer.ReturnJsonValue("error", RestResponse);;

            AssertService.AssertEqual(_errorMessageUploadFileWithoutCommitMessage, error);
        }
        public void TestToUploadFileToArchivedRepository()
        {
            object json = new FileJsonBodyChield(_fileName, _branch, _commitMessage, _commitMessage);

            RestRequest   GetRequest   = RequestFactory.FileRequest(_requestUrlFile, Method.POST, _projectId, _fileName, json);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        statusCode   = RestResponse.StatusCode.ToString();

            AssertService.AreEqual(StatusCode.Forbidden.ToString(), statusCode);
        }
        public void TestCreateNewBrunch()
        {
            RestRequest GetRequest = RequestFactory.BranchRequest(_requestUrlBranch, Method.POST, _projectId, _newBranch);

            GetRequest.AddUrlSegment("branch", _branch);
            IRestResponse RestResponse = Client.Execute(GetRequest);
            string        statusCode   = RestResponse.StatusCode.ToString();

            AssertService.AreEqual(StatusCode.Created.ToString(), statusCode);
        }
예제 #21
0
        public void TestUpdateUserStatusMessage()
        {
            object json = UserJsonBodyBuilder.SetMessage(_message).Build();

            RestRequest   GetRequest   = RequestFactory.ProjectRequest(_requestUrlUserStatus, Method.PUT, json);
            IRestResponse RestResponse = Client.Execute(GetRequest);

            _logger.Info($"Response {RestResponse.ResponseUri} received");
            string message = JsonDeserializer.ReturnJsonValue("message", RestResponse);;

            AssertService.AssertEqual(_message, message);
        }
예제 #22
0
        protected virtual Action <OnCreatingContext <TObjectType, TDefinitionType> > CreateOnProvisioningHook <TObjectType, TDefinitionType>()
            where TDefinitionType : DefinitionBase
        {
            return(new Action <OnCreatingContext <TObjectType, TDefinitionType> >(context =>
            {
                var id = context.GetType().GetGenericArguments()[0].AssemblyQualifiedName + ":" + context.ObjectDefinition.GetHashCode();
                var hook = _hookMap[id];

                hook.OnProvisioning = true;

                AssertService.IsNotNull(context.ObjectDefinition);
            }));
        }
        public void TestAddProject()
        {
            object json = ProjectJsonBody.SetDescription(_description).SetName(_projectName).Build();

            RestRequest   GetRequest   = RequestFactory.RequestWithJsonBody("projects", Method.POST, json);
            IRestResponse RestResponse = Client.Execute(GetRequest);

            //Set project id
            NewProject = int.Parse(JsonDeserializer.ReturnJsonValue("id", RestResponse));
            string name = JsonDeserializer.ReturnJsonValue("name", RestResponse);;

            AssertService.AreEqual(_projectName, name);
        }
예제 #24
0
        public void TestModels(IEnumerable <ModelNode> models)
        {
            _hookMap.Clear();

            foreach (var model in models)
            {
                var allHooks = new List <EventHooks>();

                WithProvisionRunnerContext(runnerContext =>
                {
                    var runner = runnerContext.Runner;

                    //ValidateDefinitionHostRunnerSupport<TDefinition>(runner);

                    var omModelType = GetRunnerType(runner);
                    var hooks       = GetHooks(model);

                    foreach (var hook in hooks)
                    {
                        hook.Tag = runner.Name;
                    }

                    allHooks.AddRange(hooks);

                    if (model.Value.GetType() == typeof(FarmDefinition))
                    {
                        runner.DeployFarmModel(model);
                    }

                    if (model.Value.GetType() == typeof(WebApplicationDefinition))
                    {
                        runner.DeployWebApplicationModel(model);
                    }

                    if (model.Value.GetType() == typeof(SiteDefinition))
                    {
                        runner.DeploySiteModel(model);
                    }

                    if (model.Value.GetType() == typeof(WebDefinition))
                    {
                        runner.DeployWebModel(model);
                    }

                    var hasMissedOrInvalidProps = ResolveModelValidation(model, hooks);
                    AssertService.IsFalse(hasMissedOrInvalidProps);
                });
            }
        }
예제 #25
0
        public static void PerformAction(string keyword, RestClient client, string value, StatusCode statusCode, string branchName)
        {
            switch (keyword)
            {
            case ("request"):
                GetRequestFactory(value, branchName);
                break;

            case ("addSegment"):
                _logger.Info($"Adding header \"branch\": {value}");
                _restRequest.AddUrlSegment("branch", value);
                break;

            case "response":
                IRestResponse response = client.Execute(_restRequest);
                _logger.Info($"Response {response.ResponseUri} received");
                _statusCode = response.StatusCode.ToString();
                break;

            case "assert":
                AssertService.AssertEqual(statusCode.ToString(), _statusCode);
                break;
            }
        }
예제 #26
0
        public ModelNode TestRandomDefinition <TDefinition>(Action <TDefinition> definitionSetup)
            where TDefinition : DefinitionBase, new()
        {
            _hookMap.Clear();

            ModelNode result = null;

            var allHooks = new List <EventHooks>();

            WithProvisionRunnerContext(runnerContext =>
            {
                var runner = runnerContext.Runner;

                ValidateDefinitionHostRunnerSupport <TDefinition>(runner);

                var omModelType = GetRunnerType(runner);

                var definitionSandbox     = ModelGeneratorService.GenerateModelTreeForDefinition <TDefinition>(omModelType);
                var additionalDefinitions = ModelGeneratorService.GetAdditionalDefinition <TDefinition>();

                ModelGeneratorService.ComposeModelWithAdditionalDefinitions(definitionSandbox, additionalDefinitions, omModelType);

                if (definitionSetup != null)
                {
                    foreach (var def in ModelGeneratorService.CurrentDefinitions)
                    {
                        definitionSetup(def as TDefinition);
                    }
                }

                var hooks = GetHooks(definitionSandbox);

                foreach (var hook in hooks)
                {
                    hook.Tag = runner.Name;
                }

                GetSerializedAndRestoredModels(definitionSandbox);

                allHooks.AddRange(hooks);

                if (definitionSandbox.Value.GetType() == typeof(FarmDefinition))
                {
                    runner.DeployFarmModel(definitionSandbox);
                }

                if (definitionSandbox.Value.GetType() == typeof(WebApplicationDefinition))
                {
                    runner.DeployWebApplicationModel(definitionSandbox);
                }

                if (definitionSandbox.Value.GetType() == typeof(SiteDefinition))
                {
                    runner.DeploySiteModel(definitionSandbox);
                }

                if (definitionSandbox.Value.GetType() == typeof(WebDefinition))
                {
                    runner.DeployWebModel(definitionSandbox);
                }

                if (this.EnableDefinitionValidation)
                {
                    var hasMissedOrInvalidProps = ResolveModelValidation(definitionSandbox, hooks);
                    AssertService.IsFalse(hasMissedOrInvalidProps);
                }

                result = definitionSandbox;
            });

            return(result);
        }
예제 #27
0
        public void TestModels(IEnumerable <ModelNode> models, bool deployOnce)
        {
            // force XML serialiation
            GetSerializedAndRestoredModels(models);

            _hookMap.Clear();

            foreach (var model in models)
            {
                Trace.WriteLine(string.Format(".ToPrettyPrint() result:"));
                Trace.WriteLine(model.ToPrettyPrint());

                Trace.WriteLine(string.Format(".ToDotGraph result:"));
                Trace.WriteLine(model.ToDotGraph());

                if (EnableDefinitionImmutabilityValidation)
                {
                    PersistDefinitionHashes(new[] { model });
                }

                var allHooks = new List <EventHooks>();

                WithProvisionRunnerContext(runnerContext =>
                {
                    var runner = runnerContext.Runner;

                    var omModelType = GetRunnerType(runner);
                    var hooks       = GetHooks(model);

                    foreach (var hook in hooks)
                    {
                        hook.Tag = runner.Name;
                    }

                    allHooks.AddRange(hooks);

                    if (model.Value.GetType() == typeof(FarmDefinition))
                    {
                        runner.DeployFarmModel(model);
                    }
                    else if (model.Value.GetType() == typeof(WebApplicationDefinition))
                    {
                        runner.DeployWebApplicationModel(model);
                    }
                    else if (model.Value.GetType() == typeof(SiteDefinition))
                    {
                        runner.DeploySiteModel(model);
                    }
                    else if (model.Value.GetType() == typeof(WebDefinition))
                    {
                        runner.DeployWebModel(model);
                    }
                    else if (model.Value.GetType() == typeof(ListDefinition))
                    {
                        runner.DeployListModel(model);
                    }
                    else
                    {
                        throw new SPMeta2NotImplementedException(
                            string.Format("Runner does not support model of type: [{0}]", model.Value.GetType()));
                    }

                    if (!deployOnce)
                    {
                        if (this.EnableDefinitionValidation)
                        {
                            var hasMissedOrInvalidProps = ResolveModelValidation(model, hooks);
                            AssertService.IsFalse(hasMissedOrInvalidProps);
                        }
                    }
                });

                if (!deployOnce)
                {
                    if (EnableDefinitionImmutabilityValidation)
                    {
                        PleaseMakeSureDefinitionsWereNotChangedByModelHandlers(new[] { model });
                    }
                }
            }
        }
예제 #28
0
파일: Test.cs 프로젝트: oddMary/dockerHell
 public void CorrectLoginTest()
 {
     LoginService.LogIn(_correctLoginName, _correctLoginPass);
     AssertService.AssetEqual(LoginService.GetLoginName(), StringTransform.FirstUpper(_correctLoginName));
 }
예제 #29
0
파일: Test.cs 프로젝트: oddMary/dockerHell
 public void AnErrorMsgIfIncorrectPassLoginTest()
 {
     LoginService.LogIn(_incorrectLoginName, _incorrectLoginPath);
     AssertService.AssetEqual(LoginService.GetErrorMessage(), _loginPopUperrorMsg);
 }