Beispiel #1
0
        public void Aggregates_InvalidProjectId_Returns400(string projectId)
        {
            // setup
            var currentUser = new UserIdentity()
            {
                Id = Guid.NewGuid(), UserName = "******"
            };
            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.Aggregates(projectId);
            var response = browser.Post(url, (with) =>
            {
                with.HttpRequest();
                with.FormsAuth(currentUser.Id, new Nancy.Authentication.Forms.FormsAuthenticationConfiguration());
            });

            // assert
            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
            _logFileRepo.DidNotReceive().GetByProject(Arg.Any <int>());
        }
Beispiel #2
0
        public void Execute_NoRequests_AggregatesNotLoadedAndLogFileMarkedAsProcessed()
        {
            int logFileId = new Random().Next(1, 1000);

            // setup
            IEnumerable <RequestModel> requests = Enumerable.Empty <RequestModel>();

            _requestRepo.GetByLogFile(logFileId).Returns(requests);

            // execute
            _resetRequestAggregateCommand.Execute(logFileId);

            // assert
            _requestRepo.Received(1).GetByLogFile(logFileId);
            _logFileRepo.DidNotReceive().GetById(Arg.Any <int>());
            _dbContext.Received(1).ExecuteNonQuery(Arg.Any <string>(), Arg.Any <object>());
        }