public async Task AddSubmission_AddsToDb() { // Act var lResult = await submissionRepository.Add(new SubmissionEntity { Notes = "test", SalonYear = EntitiesHelper.GetSalonYear(), Person = EntitiesHelper.GetPerson() }); // Assert Assert.IsTrue(lResult.Id > 0); var lCreatedEntity = await submissionRepository.GetById(lResult.Id); Assert.IsNotNull(lCreatedEntity); Assert.AreEqual("test", lCreatedEntity.Notes); Assert.IsTrue(lCreatedEntity.Id > 0); }
public void UpdateSubmissiontReturnsNewSubmission() { var options = new DbContextOptionsBuilder <EvaluationContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using (var memoryContext = new EvaluationContext(options)) { //Arrange ISubmissionRepository submissionRepository = new SubmissionRepository(memoryContext); #region Submission var submission1 = new SubmissionTO { SessionId = 30, AttendeeId = 1012, Date = DateTime.Today, }; var submission2 = new SubmissionTO { SessionId = 31, AttendeeId = 2607, Date = DateTime.Today, }; var submission3 = new SubmissionTO { SessionId = 2, AttendeeId = 1612, Date = DateTime.Today, }; var submissionAdded1 = submissionRepository.Add(submission1); var submissionAdded2 = submissionRepository.Add(submission2); memoryContext.SaveChanges(); #endregion //Act var idSub = submissionAdded1.Id; var submissionToUpdate = new SubmissionTO { Id = idSub, Date = DateTime.Today, AttendeeId = 132, SessionId = 456 }; var updatedSubmission = submissionRepository.Update(submissionToUpdate); memoryContext.SaveChanges(); var result = submissionRepository.GetById(updatedSubmission.Id); //Assert Assert.AreEqual(456, result.SessionId); } }
public void AdddNewSubmissionThenRetrieveItIsNotNull() { var options = new DbContextOptionsBuilder <EvaluationContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using (var memoryContext = new EvaluationContext(options)) { //Arrange ISubmissionRepository submissionRepository = new SubmissionRepository(memoryContext); //Act #region Submission var submission1 = new SubmissionTO { SessionId = 30, AttendeeId = 1012, Date = DateTime.Today, }; var submission2 = new SubmissionTO { SessionId = 31, AttendeeId = 2607, Date = DateTime.Today, }; var submissionAdded1 = submissionRepository.Add(submission1); var submissionAdded2 = submissionRepository.Add(submission2); memoryContext.SaveChanges(); #endregion var result = submissionRepository.GetById(submissionAdded2.Id); //Assert Assert.IsNotNull(result); Assert.AreEqual(2607, result.AttendeeId); } }