public async Task DeleteConfirmed_PostAsyncCallWithValidIdAndToDoList_RedirectToIndexView() { //Arrange var toDoList = ToDoListFactory.Create().Single(); await _fixture.DbContext.ToDoList.AddAsync(toDoList); await _fixture.DbContext.SaveChangesAsync(); var formData = new Dictionary <string, string> { { "__RequestVerificationToken", await AntiForgeryHelper.EnsureAntiForgeryTokenAsync(_fixture.Client) }, { "id", toDoList.Id.ToString() } }; //Act var response = await _fixture.Client .PostAsync( $"/ToDoList/Delete/", new FormUrlEncodedContent(formData)); //Assert response.Headers.Location.ToString().Should().Be("/"); }
public async Task Edit_PostAsyncCallWithModelStateInvalid_ShowErrorMessageOnEditView() { //Arrange var toDoList = ToDoListFactory.Create().Single(); await _fixture.DbContext.ToDoList.AddAsync(toDoList); await _fixture.DbContext.SaveChangesAsync(); var formData = new Dictionary <string, string> { { "__RequestVerificationToken", await AntiForgeryHelper.EnsureAntiForgeryTokenAsync(_fixture.Client) }, { "id", toDoList.Id.ToString() }, { "Id", toDoList.Id.ToString() } }; //Act var response = await _fixture.Client .PostAsync( "/ToDoList/Edit/", new FormUrlEncodedContent(formData)); //Assert response .Content .ReadAsStringAsync() .Result .Should() .Contain("The Name field is required."); }
public async Task Edit_PostAsyncCallWithConcurrency_ThrowDbConcurrencyException() { //Arrange var toDoList = ToDoListFactory.Create().Single(); await _fixture.DbContext.ToDoList.AddAsync(toDoList); await _fixture.DbContext.SaveChangesAsync(); var toDoListDb = await _fixture.DbContext.ToDoList.FirstOrDefaultAsync(x => x.Id == toDoList.Id); toDoListDb.Name = "Concurrency"; var formData = new Dictionary <string, string> { { "__RequestVerificationToken", await AntiForgeryHelper.EnsureAntiForgeryTokenAsync(_fixture.Client) }, { "id", toDoList.Id.ToString() }, { "Id", toDoList.Id.ToString() }, { "Name", "ToDoList Test 1" } }; //Act Func <Task <HttpResponseMessage> > action = () => _fixture.Client .PostAsync( "/ToDoList/Edit/", new FormUrlEncodedContent(formData)); //Assert action .Should() .Throw <DbUpdateConcurrencyException>(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); ToDoListFactory.Initialise(); }
public IToDoList CadastrarTarefa(TipoRepository tipoRepository, string textoTarefa) { var toDo = ToDoListFactory.CriarTodo(TipoToDo.Todo, tipoRepository, null, null, textoTarefa); GerenciadorTarefa gerenciadorTarefas = new GerenciadorTarefa(new AdicionarTarefa(RepositoryFactory.CriarRepository(tipoRepository), toDo), new RemoverTarefa(RepositoryFactory.CriarRepository(tipoRepository), toDo)); gerenciadorTarefas.Adicionar(); return(toDo); }
public void ApagarProjeto(TipoRepository tipoRepository, IToDoList toDo) { if (toDo == null) { toDo = ToDoListFactory.CriarTodo(TipoToDo.Projeto, tipoRepository, new List <IToDoList>(), string.Empty); } GerenciadorTarefa gerenciadorTarefas = new GerenciadorTarefa(new AdicionarTarefa(RepositoryFactory.CriarRepository(tipoRepository), toDo), new RemoverTarefa(RepositoryFactory.CriarRepository(tipoRepository), toDo)); gerenciadorTarefas.Remover(); }
public async Task ReturnAllToDoItemsForList() { for (int i = 0; i < 3; i++) { //seeding unrelated data to ensure it does not get returned await ToDoListFactory.GetPopulatedToDoList(); } var toDoList = await ToDoListFactory.GetPopulatedToDoList(); var toDoItems = await ToDoItemRepository.GetForList(toDoList.Id); Assert.All(toDoItems, toDoItem => Assert.Contains(toDoList.ToDoItems, listItem => listItem.Name == toDoItem.Name ) ); }
public IToDoList CadastrarProjeto(TipoRepository tipoRepository, string tituloProjeto, int quantidadeTarefas, List <string> textosTarefas) { var tarefas = new List <IToDoList>(); foreach (var textoTarefa in textosTarefas) { IToDoList toDo = ToDoListFactory.CriarTodo(TipoToDo.Todo, tipoRepository, null, null, textoTarefa); tarefas.Add(toDo); } var projeto = ToDoListFactory.CriarTodo(TipoToDo.Projeto, tipoRepository, tarefas, tituloProjeto); GerenciadorTarefa gerenciadorTarefas = new GerenciadorTarefa(new AdicionarTarefa(RepositoryFactory.CriarRepository(tipoRepository), projeto), new RemoverTarefa(RepositoryFactory.CriarRepository(tipoRepository), projeto)); gerenciadorTarefas.Adicionar(); return(projeto); }
public async Task Index_GetAsyncCall_ReturnNewToDoListToView() { //Arrange var toDoList = ToDoListFactory.Create().Single(); await _fixture.DbContext.ToDoList.AddAsync(toDoList); await _fixture.DbContext.SaveChangesAsync(); //Act var response = await _fixture.Client.GetAsync("/"); //Assert response .Content .ReadAsStringAsync() .Result .Should() .Contain(toDoList.Name); }
public async Task Edit_GetAsyncCallWithNewToDoListId_ReturnToDoListToView() { //Arrange var toDoList = ToDoListFactory.Create().Single(); await _fixture.DbContext.ToDoList.AddAsync(toDoList); await _fixture.DbContext.SaveChangesAsync(); //Act var response = await _fixture.Client.GetAsync($"/ToDoList/Edit/{toDoList.Id}"); //Assert response .Content .ReadAsStringAsync() .Result .Should() .Contain(toDoList.Id.ToString()); }
public async Task <ToDoList> GetExistingToDoList() { var toDoListFactory = new ToDoListFactory(GetDataContext(), GetUserService().GetUserAuthContext()); return(await toDoListFactory.GetPopulatedToDoList()); }