Exemplo n.º 1
0
        public void Delete_ValidProjectId_DeletesProject()
        {
            int projectId = new Random().Next(1, 1000);

            // setup
            var currentUser = new UserIdentity()
            {
                Id = Guid.NewGuid(), UserName = "******"
            };

            currentUser.Claims = new string[] { Claims.ProjectEdit };
            var browser = new Browser((bootstrapper) =>
                                      bootstrapper.Module(new ProjectModule(_dbContext, _projectValidator, _createProjectCommand, _deleteProjectCommand, _projectRepo, _logFileRepo, _requestRepo, _projectRequestAggregateRepo))
                                      .RequestStartup((container, pipelines, context) => {
                context.CurrentUser = currentUser;
            })
                                      );

            // execute
            var url      = Actions.Project.Delete(projectId);
            var response = browser.Post(url, (with) =>
            {
                with.HttpRequest();
                with.FormsAuth(currentUser.Id, new Nancy.Authentication.Forms.FormsAuthenticationConfiguration());
            });

            // assert
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            _deleteProjectCommand.Received(1).Execute(projectId);
        }