public void CreateAsyncWithParameters(int id, int sprintId, string assignedUserId, string name, string description, int statudId, int typeId) { var cls = new InMemoryAppDbContext(); using (var context = cls.GetEmptyContextInMemory()) { IItemRepository repository = new ItemRepository(context); Item item = new Item { Id = id, SprintId = sprintId, AssignedUserId = assignedUserId, Name = name, Description = description, StatusId = statudId, TypeId = typeId }; repository.CreateAsync(item); var actual = context.Items.Find(id); Assert.NotNull(actual); Assert.Equal(item.Id, actual.Id); context.Database.EnsureDeleted(); } }
public async Task DeleteItemCorrect() { //Arrange var cls = new InMemoryAppDbContext(); Item item1 = new Item { Id = 2, SprintId = 1, AssignedUserId = "2138b181-4cee-4b85-9f16-18df308f387d", Name = "Item Name1", Description = "Description Item1", StatusId = 1, TypeId = 1, IsArchived = false, ParentId = 1, StoryPoint = 2 }; using (var context = cls.GetEmptyContextInMemory()) { IItemRepository repo = new ItemRepository(context); context.Items.Add(item1); context.SaveChanges(); var added = context.Items.Find(item1.Id); await repo.DeleteAsync(item1.Id); var searched = await repo.ReadAsync(item1.Id); //Assert Assert.NotNull(added); Assert.Null(searched); context.Database.EnsureDeleted(); } }
public async void CreateAsyncDefault() { var cls = new InMemoryAppDbContext(); using (var context = cls.GetEmptyContextInMemory()) { IItemRepository repository = new ItemRepository(context); Item item = new Item { Id = 5, SprintId = 1, AssignedUserId = "d7f1b614-bf60-4340-9daa-c8dce98fd400", Name = "Item Name5", Description = "Description Item1", StatusId = 1, TypeId = 1 }; await repository.CreateAsync(item); var actual = context.Items.Find(5); Assert.NotNull(actual); Assert.Equal(item.Id, actual.Id); context.Database.EnsureDeleted(); } }