public void CreateAsync_ShouldWork(int id, int projectId) { //Arrange var cls = new InMemoryAppDbContext(); var context = cls.GetContextWithData(); try { ISprintRepository repository = new SprintRepository(context); //Act Sprint sprint = new Sprint { Id = id, ProjectId = projectId }; repository.CreateAsync(sprint); var actual = context.Sprints.Find(id); //Assert Assert.NotNull(actual); Assert.Equal(sprint.Id, actual.Id); Assert.Equal(sprint.ProjectId, actual.ProjectId); } finally { context.Database.EnsureDeleted(); context.Dispose(); } }
public void CreateAsync_ShouldCreateManySprints(int id, int projectId) { //Arrange var cls = new InMemoryAppDbContext(); var context = cls.GetContextWithData(); try { ISprintRepository repository = new SprintRepository(context); Sprint sprint = new Sprint { Id = id, ProjectId = projectId, StartDate = new DateTime(2020, 4, 23), EndDate = new DateTime(2020, 5, 23) }; //Act repository.CreateAsync(sprint); var actual = context.Sprints.Find(id); //Assert Assert.Equal(sprint.Id, actual.Id); Assert.Equal(sprint.ProjectId, actual.ProjectId); Assert.Equal(sprint.StartDate, actual.StartDate); Assert.Equal(sprint.EndDate, actual.EndDate); } finally { context.Database.EnsureDeleted(); context.Dispose(); } }