public void Delete_OnValidPost_ExecutesCommand() { int id = new Random().Next(1, 100); // setup var currentUser = new UserIdentity() { Id = Guid.NewGuid(), UserName = "******" }; currentUser.Claims = new string[] { Claims.ProjectEdit }; var browser = new Browser((bootstrapper) => bootstrapper.Module(new ProjectRequestAggregateModule(_dbContext, _createProjectRequestAggregateCommand, _deleteProjectRequestAggregateCommand)) .RequestStartup((container, pipelines, context) => { context.CurrentUser = currentUser; }) ); // execute var url = Actions.ProjectRequestAggregate.Delete(); var response = browser.Post(url, (with) => { with.HttpRequest(); with.FormsAuth(currentUser.Id, new Nancy.Authentication.Forms.FormsAuthenticationConfiguration()); with.FormValue("id", id.ToString()); }); // assert Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); _deleteProjectRequestAggregateCommand.Received(1).Execute(id); _dbContext.Received(1).Commit(); }