public void Create_Should_Create_A_New_Instance() { // arrange DateTime date = DateTime.Today; // act WorkshopPlanning sut = WorkshopPlanning.Create(date); IEnumerable <Event> events = sut.GetEvents(); // assert Assert.NotNull(sut); Assert.NotNull(sut.Id); Assert.Equal(date, sut.Id); Assert.Equal(0, sut.OriginalVersion); Assert.Equal(1, sut.Version); Assert.Empty(sut.Jobs); Assert.Collection(events, item0 => Assert.IsAssignableFrom <WorkshopPlanningCreated>(item0)); }
public async Task <IActionResult> RegisterAsync(DateTime date) { try { // insert planning WorkshopPlanning planning = new WorkshopPlanning(); IEnumerable <Event> events = planning.Create(date); await _planningRepo.SaveWorkshopPlanningAsync(planning, events); // return result return(CreatedAtRoute("GetByDate", new { date = planning.Date }, planning)); } catch (ConcurrencyException) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); return(StatusCode(StatusCodes.Status500InternalServerError)); } }